A data query method, device, apparatus and storage medium

By calculating the height of unscanned blocks in the blockchain and the query step size, a query range is generated and filtering conditions are added, which solves the problems of low query efficiency and limited content in blockchain transaction data, and achieves efficient and comprehensive data acquisition.

CN117056353BActive Publication Date: 2026-04-21CHANGCHUN JIDA ZHENGYUAN INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHANGCHUN JIDA ZHENGYUAN INFORMATION TECH CO LTD
Filing Date
2023-08-16
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

In existing technologies, blockchain transaction data query efficiency is low, easily exceeding the query rate per second (QPS) limit, and the query content is limited, unable to obtain information such as the initiator address of the contract transaction, requiring a secondary query.

Method used

By calculating the difference between the height of scanned blocks and the height of the latest block, the height of unscanned blocks is determined. The query step size is determined based on the transaction frequency and the number of truncations in the query interface, generating the query range. Filtering conditions are added to the query request to reduce the frequency of access to the server and improve query efficiency.

Benefits of technology

It reduces the limitations of QPS on query efficiency, improves query efficiency, and includes information such as the initiator address of the contract transaction in the query results, eliminating the need for secondary queries and achieving more efficient data acquisition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117056353B_ABST
    Figure CN117056353B_ABST
Patent Text Reader

Abstract

The present disclosure provides a data query method and device, equipment and a storage medium, relating to the technical field of computer. A data query method comprises: obtaining a first block height and a second block height, the first block height being a block height of a scanned block on a block chain, and the second block height being a block height of a latest block on the block chain; calculating a difference between the first block height and the second block height to obtain an unscanned block height on the block chain; determining a query step length according to a transaction frequency of a queried transaction and a truncation number of a query interface; determining a query range according to the unscanned block height and the query step length; generating a query request according to the query range and a screening condition corresponding to the queried transaction, and sending the query request to a server; and receiving a query result obtained by the server scanning according to the query request.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a data query method, apparatus, device, and storage medium. Background Technology

[0002] Blockchain generates a large amount of transaction data during its use. For a querying end to retrieve this data, it needs to frequently send query commands to the server to obtain data information from newly generated nodes on the server side. Current technologies primarily obtain transaction data through a block-based query interface provided by the server. However, this interface not only requires frequent query commands but is also limited by the query rate per second (QPS). Querying large amounts of data on the blockchain can easily exceed the QPS limit, resulting in low query efficiency. Furthermore, the block-based query interface has limitations on the query content; for example, it cannot retrieve information such as the initiator's address of a contract transaction. It requires first retrieving the contract transaction account and then performing a secondary query for the initiator's address and other information based on that account. Summary of the Invention

[0003] This disclosure provides a data query method, apparatus, device, and storage medium to at least solve the above-mentioned technical problems existing in the prior art.

[0004] According to a first aspect of this disclosure, a data query method is provided, the method comprising: obtaining a first block height and a second block height, wherein the first block height is the block height of scanned blocks on the blockchain, and the second block height is the block height of the latest block on the blockchain; calculating the difference between the first block height and the second block height to obtain the height of unscanned blocks on the blockchain; determining a query step size based on the transaction frequency of the queried transaction and the truncation number of the query interface; determining a query range based on the unscanned block height and the query step size; generating a query request based on the query range and the filtering conditions corresponding to the queried transaction, and sending the query request to a server; and receiving the query results obtained by the server based on the query request.

[0005] In one possible implementation, obtaining the first block height and the second block height includes: querying the first block height based on a scan record, wherein the scan record is used to record the block heights of scanned blocks on the blockchain; and obtaining the second block height returned by a detection thread, wherein the detection thread is used to send a height query instruction to the server at target intervals to obtain the block height of the latest block on the blockchain.

[0006] In one possible implementation, determining the query step size based on the transaction frequency of the queried transaction and the truncation number of the query interface includes: calculating the quotient of the truncation number and the transaction frequency to obtain the time required for the number of transactions of the queried transaction to reach the truncation number; calculating the product of the block generation rate on the blockchain and the time to obtain the maximum step size; and determining the query step size based on the maximum step size, wherein the query step size is less than or equal to the maximum step size.

[0007] In one possible implementation, determining the query range based on the height of the unscanned block and the query step size includes: if the height of the unscanned block is greater than or equal to the query step size, then the blocks within a query step size range starting from the last scanned block are determined as the query range; if the height of the unscanned block is less than the query step size but greater than 1, then the range from the last scanned block to the latest block is determined as the query range; if the height of the unscanned block is less than the query step size but equal to 1, then the latest block is determined as the query range.

[0008] In one possible implementation, generating a query request based on the query range and the filtering conditions corresponding to the queried transaction includes: if the number of blocks corresponding to the query range is greater than 1, then determining the query range parameter of the query interface corresponding to the server; if the query range parameter is a height parameter, then generating the query request based on the start and end block heights corresponding to the query range and the filtering conditions corresponding to the queried transaction; if the query range parameter is a time parameter, then converting the start and end block heights corresponding to the query range into start and end timestamps, and generating the query request based on the start and end timestamps and the filtering conditions corresponding to the queried transaction; if the number of blocks corresponding to the query range is 1, then generating the query request based on the block height of the latest block and the filtering conditions corresponding to the queried transaction.

[0009] In one possible implementation, the filtering criteria include at least one of the following: the account information corresponding to the queried transaction, the contract address of the queried transaction, and the transaction type of the queried transaction.

[0010] In one possible implementation, generating a query request based on the query range and the filtering conditions corresponding to the queried transaction further includes: generating query requests corresponding to all query ranges in sequence based on all query ranges corresponding to unscanned blocks on the blockchain and the filtering conditions corresponding to the queried transaction; correspondingly, sending the query requests to the server includes: sending all the query requests to the server in sequence; or, sending all the query requests to the server simultaneously.

[0011] In one embodiment, a data query method further includes: parsing the actual data needed from the query results; and saving the actual data needed uniquely to a storage structure according to the transaction account.

[0012] According to a second aspect of this disclosure, a data query apparatus is provided, comprising: an acquisition module for acquiring a first block height and a second block height, wherein the first block height is the block height of scanned blocks on the blockchain, and the second block height is the block height of the latest block on the blockchain; a calculation module for calculating the difference between the first block height and the second block height to obtain the height of unscanned blocks on the blockchain; a first determination module for determining a query step size based on the transaction frequency of the queried transaction and the truncation number of the query interface; a second determination module for determining a query range based on the unscanned block height and the query step size; a generation module for generating a query request based on the query range and the filtering conditions corresponding to the queried transaction; a sending module for sending the query request to a server; and a receiving module for receiving the query results obtained by the server based on the query request.

[0013] According to a third aspect of this disclosure, an electronic device is provided, comprising:

[0014] At least one processor; and

[0015] A memory communicatively connected to the at least one processor; wherein,

[0016] The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the methods described in this disclosure.

[0017] According to a fourth aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions for causing the computer to perform the methods described in this disclosure.

[0018] This disclosure discloses a data query method, apparatus, device, and storage medium. First, it calculates the difference between the height of the first scanned block and the height of the second latest block to obtain the height of the unscanned blocks on the blockchain. Then, based on the transaction frequency of the queried transaction and the truncation number of the query interface, it determines the query step size. Next, it determines the query range based on the unscanned block height and the query step size. Finally, it generates a query request based on the query range and the filtering conditions corresponding to the queried transaction, and sends the query request to the server. Finally, it receives the query results obtained by the server based on the query request. Therefore, this data query method, by determining the query range based on the unscanned block height and the query step size, reduces the frequency of server access compared to block-based queries, lowers the QPS limitation on query efficiency, and thus improves query efficiency. Furthermore, by adding filtering conditions corresponding to the queried transaction to the query request, the server can query any data corresponding to the filtering conditions within the query range, including information such as the initiator address of contract transactions, without being limited by the query content.

[0019] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description

[0020] The above and other objects, features, and advantages of this disclosure will become readily apparent from the following detailed description of exemplary embodiments, taken in conjunction with the accompanying drawings. Several embodiments of this disclosure are illustrated in the drawings by way of example and not limitation, in which:

[0021] In the accompanying drawings, the same or corresponding reference numerals indicate the same or corresponding parts.

[0022] Figure 1 A flowchart illustrating a data query method according to a first embodiment of this disclosure is shown;

[0023] Figure 2 A flowchart illustrating a data query method according to a second embodiment of this disclosure is shown;

[0024] Figure 3 A flowchart illustrating a data query method according to a third embodiment of this disclosure is shown;

[0025] Figure 4 A flowchart illustrating a data query method according to a fifth embodiment of this disclosure is shown;

[0026] Figure 5 A schematic diagram of the structure of a data query device according to the sixth embodiment of this disclosure is shown;

[0027] Figure 6A schematic diagram of the composition structure of an electronic device according to an embodiment of the present disclosure is shown. Detailed Implementation

[0028] To make the objectives, features, and advantages of this disclosure more apparent and understandable, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without creative effort are within the scope of protection of this disclosure.

[0029] Figure 1 A flowchart illustrating a data query method according to a first embodiment of this disclosure is shown, as follows: Figure 1 As shown, a data query method includes:

[0030] Step S101: Obtain the height of the first block and the height of the second block.

[0031] Step S102: Calculate the difference between the height of the first block and the height of the second block to obtain the height of the unscanned block on the blockchain.

[0032] In this embodiment, the first block height is the height of the scanned blocks on the blockchain, that is, the height of the blocks on the blockchain whose data has been synchronized by the query end. The second block height is the height of the latest block on the blockchain. The difference between the first block height and the second block height is the height of the unscanned blocks on the blockchain, that is, the height of the blocks on the blockchain whose data has not yet been synchronized by the query end. For example, if the height H1 of the scanned blocks on the blockchain is 100, and the height H2 of the latest block is 2000, then the height H of the unscanned blocks on the blockchain is 1900.

[0033] In one possible implementation, the first block height and the second block height are obtained as follows: The first block height is queried based on a scan record, which records the block heights of scanned blocks on the blockchain; the second block height is obtained from a detection thread, which sends a height query command to the server every target time interval to obtain the block height of the latest block on the blockchain. Specifically, the querying party can query the first block height of scanned blocks on the blockchain from the scan record. Simultaneously, the querying party can maintain a detection thread, which sends a height query command to the server every target time interval. The server, based on this height query command, queries the second block height of the latest block on the blockchain and returns the second block height to the querying party through the detection thread. The target time interval can be 3 seconds, meaning the detection thread sends a height query command to the server every 3 seconds.

[0034] Step S103: Determine the query step size based on the transaction frequency of the queried transaction and the number of truncations in the query interface.

[0035] In this embodiment, the queried transaction is the transaction that the querying party needs to query. For example, if the querying party needs to query and track a certain contract transaction of a certain account, then that contract transaction is the queried transaction. The query interface is an interface provided by the server for querying data on the blockchain. The query interface can be an interface provided by the server based on the Tron chain, etc. The query interface generally determines the truncation number based on the number of blocks and the total number of bytes. If the result set in the query result exceeds the truncation number, the query interface will truncate the query result. For example, if the truncation number is 50 and the result set in the query result is 60, then the query interface will truncate the query result from the 50th result set and only return the 1st to 50th result sets to the querying party. The query step size is the number of blocks queried each time.

[0036] In one possible implementation, step S103 specifically includes: calculating the quotient of the truncation quantity and the transaction frequency to obtain the time required for the number of transactions of the queried transaction to reach the truncation quantity; calculating the product of the block generation rate on the blockchain and the time to obtain the maximum step size; determining the query step size based on the maximum step size, wherein the query step size is less than or equal to the maximum step size. Specifically, the quotient of the truncation quantity and the transaction frequency is the time required for the number of queried transactions to reach the truncation quantity. For example, if the truncation quantity is 50 and the transaction frequency is 1 transaction / minute, then the time required to reach 50 transactions is 50 minutes. The product of the block generation rate on the blockchain and the time is the maximum step size. For example, according to the Tron blockchain's rule of generating one block every 3 seconds, the block generation rate on the blockchain is 20 blocks / minute. Within 50 minutes, 1000 blocks can be generated on the blockchain, meaning the maximum step size is 1000. The query step size only needs to be less than or equal to the maximum step size to ensure that the result set in each query does not exceed the truncation quantity. For example, the query step size can be determined to be 800 blocks.

[0037] Step S104: Determine the query range based on the height of the unscanned block and the query step size.

[0038] In this embodiment, the query range is determined based on the height of the unscanned blocks and the size of the query step. Specifically, if the height of the unscanned blocks is greater than or equal to the query step, the blocks within a query step range starting from the last scanned block are determined as the query range; if the height of the unscanned blocks is less than the query step, the range from the last scanned block to the latest block is determined as the query range, that is, all unscanned blocks are used as the query range.

[0039] Step S105: Generate a query request based on the query scope and the filtering conditions corresponding to the queryed transaction, and send the query request to the server.

[0040] Step S106: Receive the query results obtained by the server based on the query request.

[0041] In this embodiment, the filtering conditions corresponding to the queried transaction are used to filter the data types that the querying party wants to query. The filtering conditions may include the account information corresponding to the queried transaction, the contract address of the queried transaction, and the transaction type of the queried transaction. A query request is generated according to the query scope and the filtering conditions corresponding to the queried transaction, and the query request is sent to the server. The server can perform a query within the query scope according to the filtering conditions and send the query results to the querying party. The querying party receives the query results obtained by the server based on the query request.

[0042] In the first embodiment of this disclosure, the query range is determined based on the height of the unscanned block and the query step size. The query range can include multiple blocks. Therefore, compared with the block-based query method, it can reduce the frequency of access to the server and reduce the limitation of QPS on query efficiency, thereby improving query efficiency. In addition, the query request includes a filter condition corresponding to the queried transaction. The server can query any data corresponding to the filter condition within the query range. Moreover, the existence of the filter condition reduces the amount of data in the query results. Therefore, the server can return the query results as a whole to the query client, including information such as the initiator address of the contract transaction, without needing to perform a secondary query for the initiator address and other information based on the contract transaction account, and is not limited by the query content.

[0043] Figure 2 A flowchart illustrating a data query method according to a second embodiment of this disclosure is shown, as follows: Figure 2 As shown, step S104 determines the query range based on the height of the unscanned block and the query step size, specifically including:

[0044] In step S201, if the height of the unscanned block is greater than or equal to the query step size, then the block range within one query step size starting from the last scanned block is determined as the query range.

[0045] In this embodiment, if the height of the unscanned block is greater than or equal to the query step size, the query range is determined from the last scanned block within a query step size range. For example, if the height H of the unscanned block is 1900, the query step size is 800 blocks, the height of the first scanned block on the blockchain is 100, and the height of the second block of the latest block is 2000, then the 800 blocks after the block with a height of 100 are determined as the query range, that is, the blocks with a height of 101 to 900 are determined as the query range.

[0046] In step S202, if the height of the unscanned block is less than the query step size but greater than 1, then the range from the last scanned block to the latest block is determined as the query range.

[0047] In this embodiment, if the height of an unscanned block is less than the query step size but greater than 1, the range from the last scanned block to the latest block is determined as the query range. For example, if the height H of the unscanned block is 300, the query step size is 800 blocks, the height of the first scanned block on the blockchain is 1700, and the height of the second scanned block is 2000, then the range from the block with a height of 1700 to the latest block is determined as the query range, that is, the blocks with heights of 1701 to 2000 are determined as the query range.

[0048] In step S203, if the height of the unscanned block is less than the query step size and equal to 1, then the latest block is determined as the query range.

[0049] In this embodiment, if the height of the unscanned block is less than the query step size and equal to 1, then the latest block is determined as the query range. For example, if the height H of the unscanned block is 1, the height of the second block of the latest block is 2000, and the query step size is 800 blocks, then the latest block is determined as the query range.

[0050] In the second embodiment of this disclosure, the query range is dynamically adjusted according to the height of the unscanned block and the size of the query step. Even when the height of the unscanned block is small, the unscanned block can still be queried in real time without waiting for the height of the unscanned block to reach the query step. This not only reduces the frequency of access to the server and reduces the limitation of QPS on query efficiency, thus improving query efficiency, but also ensures the real-time nature of the latest transaction queries.

[0051] Figure 3 A flowchart illustrating a data query method according to a third embodiment of this disclosure is shown, as follows: Figure 3 As shown, step S105, which generates a query request based on the query scope and the filtering conditions corresponding to the queried transaction, includes:

[0052] If the number of blocks corresponding to the query range is greater than 1, proceed to step S301 to determine the query range parameters of the corresponding query interface on the server.

[0053] The query range parameter is a height parameter. Step S302 is executed to generate a query request based on the start and end block heights corresponding to the query range and the filtering conditions corresponding to the queried transaction.

[0054] The query range parameter is a time parameter. Step S303 is executed to convert the start and end block heights corresponding to the query range into start and end timestamps, and generate a query request based on the start and end timestamps and the filtering conditions corresponding to the queried transaction.

[0055] If the number of blocks corresponding to the query range is 1, proceed to step S304 to generate a query request based on the block height of the latest block and the filtering conditions corresponding to the queried transaction.

[0056] In this embodiment, when the number of blocks corresponding to the query range is greater than 1, it is necessary to determine the query range parameter of the corresponding query interface on the server. If the query range parameter is a height parameter, the query range needs to be represented by the block height. Therefore, a query request is generated based on the start and end block heights corresponding to the query range and the filtering conditions corresponding to the queried transaction. If the query range parameter is a time parameter, the query range needs to be represented by the block generation time. Therefore, it is necessary to first convert the start and end block heights corresponding to the query range into start and end timestamps, and then generate a query request based on the start and end timestamps and the filtering conditions corresponding to the queried transaction. Specifically, the start and end timestamps corresponding to the start and end block heights corresponding to the query range can be retrieved by accessing the block header query interface on the server.

[0057] In this embodiment, when the number of blocks corresponding to the query range is 1, the query can be performed directly by searching by block. Therefore, a query request is generated based on the block height of the latest block and the filtering conditions corresponding to the queried transaction.

[0058] In the third embodiment of this disclosure, when the number of blocks corresponding to the query range is greater than 1, the representation of the query range is determined according to the query range parameter of the query interface, and then a query request is generated with the query range and filtering conditions in the representation, thereby ensuring that the query range in the query request corresponds to the query range parameter of the query interface. In addition, when the number of blocks corresponding to the query range is 1, the query can be performed directly in a block-by-block query manner, thereby improving query efficiency.

[0059] In the fourth embodiment of this disclosure, step S105, generating a query request based on the query scope and the filtering conditions corresponding to the queried transaction, further includes:

[0060] Based on all query ranges corresponding to unscanned blocks on the blockchain and the filtering conditions corresponding to the queried transactions, query requests corresponding to all query ranges are generated sequentially; accordingly, the query requests are sent to the server, including: sending all query requests to the server sequentially; or, sending all query requests to the server simultaneously.

[0061] To facilitate understanding of the fourth embodiment of this disclosure, a specific example is provided below to illustrate the fourth embodiment:

[0062] 1. If the height of the first block H1 is 100 and the height of the second block H2 is 2000, then the height of the unscanned block on the blockchain is 1900, and the query step size S is set to 800.

[0063] 2. Generate query request Q1: Since the height H of the unscanned block is greater than the query step size S, the 800 blocks after the block with a height of 100 are determined as the query range, that is, the blocks with a height of 101 to 900 are determined as the query range A1, and the query request Q1 is generated based on the query range A1 and the filtering conditions.

[0064] 3. Generate query request Q2: At this time, the height H of the unscanned block becomes 1100, which is greater than the query step size S. Therefore, the blocks with a height of 901 to 1700 are determined as the query range A2, and query request Q2 is generated based on the query range A2 and the filtering conditions.

[0065] 4. Generate query request Q3: At this time, the height H of the unscanned block becomes 300, which is less than the query step size S and greater than 1. Therefore, the block with a height of 1701 to 2000 is determined as the query range A3, and query request Q3 is generated based on the query range A3 and the filtering conditions.

[0066] In this context, query ranges A1, A2, and A3 represent all query ranges corresponding to the unscanned blocks on the blockchain. Based on query ranges A1, A2, and A3, and the filtering conditions, query requests corresponding to all query ranges can be generated sequentially, namely query request Q1, query request Q2, and query request Q3. The querying client can send query requests Q1, Q2, and Q3 to the server sequentially, or simultaneously. It's important to note that after generating query request Q3, if a new block 2001 is generated on the blockchain (i.e., the height of the unscanned block is less than the query step size and equal to 1), then block 2001 is directly designated as query range Q4, and query request Q4 is generated based on query range Q4 and the filtering conditions, without waiting for the height of the unscanned block to reach the query step size before performing the query.

[0067] Figure 4 A flowchart illustrating a data query method according to a fifth embodiment of this disclosure is shown, as follows: Figure 4 As shown, after step S106, a data query method further includes:

[0068] Step S107: Parse the actual data needed from the query results.

[0069] Step S108: Save the actual required data to the storage structure uniquely according to the transaction account.

[0070] In this embodiment, after receiving the query results, the querying party can parse out the actual data needed from the query results, and then save the actual data needed to the storage structure uniquely according to the transaction account. Thus, if the actual data needed is queried again in the future, it can be determined whether it has been saved according to the transaction account. If it has been saved, there is no need to save it again, thereby ensuring the uniqueness of the data in the storage structure.

[0071] Figure 5 A schematic diagram of the structure of a data query device according to the sixth embodiment of this disclosure is shown, as follows: Figure 5 As shown, a data query device includes:

[0072] The module 10 is used to obtain the height of the first block and the height of the second block. The first block height is the height of the scanned blocks on the blockchain, and the second block height is the height of the latest block on the blockchain. The module 11 is used to calculate the difference between the first block height and the second block height to obtain the height of the unscanned blocks on the blockchain. The first determination module 12 is used to determine the query step size based on the transaction frequency of the queried transaction and the truncation number of the query interface. The second determination module 13 is used to determine the query range based on the height of the unscanned blocks and the query step size. The generation module 14 is used to generate a query request based on the query range and the filtering conditions corresponding to the queried transaction. The sending module 15 is used to send the query request to the server. The receiving module 16 is used to receive the query results obtained by the server based on the query request.

[0073] In one embodiment, the acquisition module 10 is further configured to: query the first block height based on the scan record, the scan record being used to record the block height of scanned blocks on the blockchain; and acquire the second block height returned by the detection thread, the detection thread being used to send a height query instruction to the server every target time to obtain the block height of the latest block on the blockchain.

[0074] In one embodiment, the first determining module 12 is further configured to: calculate the quotient of the truncation quantity and the transaction frequency to obtain the time required for the number of transactions of the queried transaction to reach the truncation quantity; calculate the product of the block generation rate and the time on the blockchain to obtain the maximum step size; and determine the query step size based on the maximum step size, wherein the query step size is less than or equal to the maximum step size.

[0075] In one possible implementation, the second determining module 13 is further configured to: if the height of an unscanned block is greater than or equal to the query step size, then the blocks within a query step size range starting from the last scanned block are determined as the query range; if the height of an unscanned block is less than the query step size but greater than 1, then the range from the last scanned block to the latest block is determined as the query range; if the height of an unscanned block is less than the query step size but equal to 1, then the latest block is determined as the query range.

[0076] In one embodiment, the generation module 14 is further configured to: determine the query range parameters of the query interface corresponding to the server if the number of blocks corresponding to the query range is greater than 1; generate a query request based on the start and end block heights corresponding to the query range and the filtering conditions corresponding to the queried transaction if the query range parameter is a height parameter; convert the start and end block heights corresponding to the query range into start and end timestamps and generate a query request based on the start and end timestamps and the filtering conditions corresponding to the queried transaction if the number of blocks corresponding to the query range is 1; generate a query request based on the block height of the latest block and the filtering conditions corresponding to the queried transaction; the filtering conditions include at least one of the following: account information corresponding to the queried transaction, contract address of the queried transaction, and transaction type of the queried transaction.

[0077] In one embodiment, the generation module 14 is further configured to: generate query requests corresponding to all query ranges in sequence according to all query ranges corresponding to unscanned blocks on the blockchain and the filtering conditions corresponding to query transactions; correspondingly, the sending module 15 is further configured to: send all query requests to the server in sequence; or, send all query requests to the server simultaneously.

[0078] In one embodiment, a data query device further includes: a parsing module for parsing the actual data needed from the query results; and a saving module for saving the actual data needed to a storage structure uniquely according to the transaction account.

[0079] According to embodiments of this disclosure, this disclosure also provides an electronic device and a readable storage medium.

[0080] Figure 6 A schematic block diagram of an example electronic device 800 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0081] like Figure 6As shown, device 800 includes a computing unit 801, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 802 or a computer program loaded from storage unit 808 into random access memory (RAM) 803. RAM 803 may also store various programs and data required for the operation of device 800. The computing unit 801, ROM 802, and RAM 803 are interconnected via bus 804. Input / output (I / O) interface 805 is also connected to bus 804.

[0082] Multiple components in device 800 are connected to I / O interface 805, including: input unit 806, such as keyboard, mouse, etc.; output unit 807, such as various types of monitors, speakers, etc.; storage unit 808, such as disk, optical disk, etc.; and communication unit 809, such as network card, modem, wireless transceiver, etc. Communication unit 809 allows device 800 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0083] The computing unit 801 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 801 performs the various methods and processes described above, such as a data query method. For example, in some embodiments, a data query method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 808. In some embodiments, part or all of the computer program may be loaded and / or installed on device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by the computing unit 801, one or more steps of a data query method described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to perform a data query method by any other suitable means (e.g., by means of firmware).

[0084] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0085] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0086] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0087] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0088] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.

[0089] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.

[0090] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.

[0091] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this disclosure, "a plurality of" means two or more, unless otherwise explicitly specified.

[0092] The above description is merely a specific embodiment of this disclosure, but the scope of protection of this disclosure is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this disclosure should be included within the scope of protection of this disclosure. Therefore, the scope of protection of this disclosure should be determined by the scope of the claims.

Claims

1. A data query method, characterized in that, The method includes: Obtain the first block height and the second block height, where the first block height is the block height of the scanned blocks on the blockchain, and the second block height is the block height of the latest block on the blockchain; Calculate the difference between the height of the first block and the height of the second block to obtain the height of the unscanned block on the blockchain; The query step size is determined based on the transaction frequency of the queried transaction and the number of segments truncated by the query interface. The query range is determined based on the height of the unscanned block and the query step size; Based on the query scope and the filtering conditions corresponding to the queried transaction, a query request is generated and sent to the server. Receive the query results obtained by the server based on the query request; The step of determining the query step size based on the transaction frequency of the queried transaction and the truncation number of the query interface includes: calculating the quotient of the truncation number and the transaction frequency to obtain the time required for the number of transactions of the queried transaction to reach the truncation number; calculating the product of the block generation rate on the blockchain and the time to obtain the maximum step size; and determining the query step size based on the maximum step size, wherein the query step size is less than or equal to the maximum step size.

2. The method according to claim 1, characterized in that, Obtaining the height of the first block and the height of the second block includes: The height of the first block is queried based on the scan record, wherein the scan record is used to record the block height of scanned blocks on the blockchain; The detection thread retrieves the second block height returned by the detection thread, which sends a height query command to the server at target intervals to obtain the block height of the latest block on the blockchain.

3. The method according to claim 1, characterized in that, The step of determining the query range based on the height of the unscanned block and the query step size includes: If the height of the unscanned block is greater than or equal to the query step size, then the block range within one query step size starting from the last scanned block is determined as the query range; If the height of the unscanned block is less than the query step size but greater than 1, then the range from the last scanned block to the latest block is determined as the query range. If the height of the unscanned block is less than the query step size and equal to 1, then the latest block is determined as the query range.

4. The method according to claim 3, characterized in that, The step of generating a query request based on the query range and the filtering conditions corresponding to the queried transaction includes: If the number of blocks corresponding to the query range is greater than 1, then the query range parameter of the query interface corresponding to the server is determined. If the query range parameter is a height parameter, then the query request is generated based on the start and end block heights corresponding to the query range and the filtering conditions corresponding to the queried transaction. If the query range parameter is a time parameter, then the start and end block heights corresponding to the query range are converted into start and end timestamps, and the query request is generated based on the start and end timestamps and the filtering conditions corresponding to the queried transaction. If the number of blocks corresponding to the query range is 1, then the query request is generated based on the block height of the latest block and the filtering conditions corresponding to the queried transaction.

5. The method according to claim 4, characterized in that, The filtering criteria include at least one of the following: the account information corresponding to the queried transaction, the contract address of the queried transaction, and the transaction type of the queried transaction.

6. The method according to claim 3, characterized in that, The step of generating a query request based on the query range and the filtering conditions corresponding to the queried transaction further includes: Based on all query ranges corresponding to unscanned blocks on the blockchain and the filtering conditions corresponding to the queried transaction, query requests corresponding to all query ranges are generated sequentially. Accordingly, sending the query request to the server includes: All the query requests are sent to the server in sequence; or, At the same time, all the query requests are sent to the server.

7. The method according to any one of claims 1 to 6, characterized in that, Also includes: Extract the actual data needed from the query results; The actual required data is uniquely saved to the storage structure according to the transaction account.

8. A data query device, characterized in that, The device includes: The acquisition module is used to acquire the first block height and the second block height, wherein the first block height is the block height of the scanned blocks on the blockchain, and the second block height is the block height of the latest block on the blockchain; The calculation module is used to calculate the difference between the height of the first block and the height of the second block to obtain the height of the unscanned block on the blockchain; The first determining module is used to determine the query step size based on the transaction frequency of the queried transaction and the number of truncations in the query interface; The second determining module is used to determine the query range based on the height of the unscanned block and the query step size; The generation module is used to generate a query request based on the query range and the filtering conditions corresponding to the queried transaction; The sending module is used to send the query request to the server. The receiving module is used to receive the query results obtained by the server based on the query request. The first determining module is further configured to calculate the quotient of the truncation quantity and the transaction frequency to obtain the time required for the number of transactions of the queried transaction to reach the truncation quantity; calculate the product of the block generation rate on the blockchain and the time to obtain the maximum step size; and determine the query step size based on the maximum step size, wherein the query step size is less than or equal to the maximum step size.

9. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-7.

10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Image edge extraction method and device, equipment and medium

    CN116228801A