Blockchain Transaction Statistics Method and Device
By setting the number base for storing and querying data, a thread is established to perform blockchain transaction data statistics, solving the problem of quickly compiling large amounts of transaction data and improving both accuracy and speed.
Patent Information
- Application Number
- CN202210302340.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-25
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2042-03-25
AI Technical Summary
How to quickly analyze large amounts of transaction data on blockchains and avoid omissions and duplicates.
By storing the receiving account address in the transaction data in a set number format, determining the number of digits for querying and establishing a corresponding thread, using the thread as the query condition to perform transaction data statistics, and integrating the statistical results of each thread.
It enables fast and accurate statistics of blockchain transaction data, avoiding omissions and duplications, and improving the speed of transaction data statistics.
Smart Images

Figure CN114661791B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of blockchain technology, and more specifically, to a blockchain transaction statistics method and apparatus. Background Technology
[0002] With the development and implementation of blockchain technology, a large number of blockchain applications have emerged in the market, including financial services, public services, and the Internet of Things.
[0003] Currently, many new blockchain applications have emerged, each corresponding to a large amount of transaction data. Statistical analysis of this transaction data is frequently required within the blockchain ecosystem. Therefore, how to quickly analyze large volumes of blockchain transaction data has become a key focus.
[0004] In conclusion, there is an urgent need for a blockchain transaction statistics method to quickly analyze large amounts of blockchain transaction data. Summary of the Invention
[0005] In view of this, this application provides a blockchain transaction statistics method and apparatus for quickly counting large amounts of blockchain transaction data.
[0006] To achieve the above objectives, the following solution is proposed:
[0007] A blockchain transaction statistics method, comprising:
[0008] Acquire transaction data on the blockchain and store the transaction data, wherein the receiving account address in the transaction data is stored in a set number format;
[0009] Determine the number of query bits to distinguish the receiving transaction account address, and determine the types of all character combinations of the first query bits of the receiving transaction account address stored in the set base form, and establish a thread corresponding to each type of character combination;
[0010] Each thread is invoked, and the character combination corresponding to the thread is used as the query condition to query the matching transaction data. The matching transaction data is then used to complete the transaction statistics results for each thread.
[0011] The transaction statistics results for each thread are integrated to obtain the final blockchain transaction statistics results.
[0012] A blockchain transaction statistics device, comprising:
[0013] An acquisition unit is used to acquire transaction data on the blockchain and store the transaction data, wherein the receiving account address in the transaction data is stored in a set number format;
[0014] The determining unit is used to determine the number of query bits that distinguish the receiving transaction account address, and to determine the type of all character combinations of the first query bits of the receiving transaction account address stored in the set base form, and to establish a thread corresponding to each type of character combination.
[0015] The calling unit is used to call each thread, using the character combination corresponding to the thread as the query condition to query the matching transaction data, and use the matching transaction data to complete the transaction statistics results corresponding to each thread.
[0016] The integration unit is used to integrate the transaction statistics results corresponding to each thread to obtain the final blockchain transaction statistics results.
[0017] As can be seen from the above technical solution, the blockchain transaction statistics method provided in this application requires first obtaining transaction data from the blockchain and storing this transaction data that needs to be statistically analyzed. Specifically, the receiving transaction account address in the transaction data is stored in a set base format, which can be binary, octal, decimal, or hexadecimal. Subsequently, the query bits for distinguishing the receiving transaction account address can be determined, and the types of all character combinations of the receiving transaction account address stored in the set base format can be determined. A thread corresponding to each type of character combination is then established. This allows for the creation of threads matching the number of character combination types, and each thread has a unique corresponding character combination, ensuring that no receiving transaction account address is missed, i.e., no transaction data is missed. Furthermore, each transaction data has a unique corresponding thread, avoiding duplicate statistics. When each thread has a corresponding query condition, the query condition can be used to query matching transaction data in the stored transaction data and perform transaction statistics. Thus, each thread can perform transaction statistics simultaneously and obtain the transaction statistics result corresponding to each thread. The simultaneous performance of transaction statistics by multiple threads can improve the speed of transaction data statistics. Once the transaction statistics results for each thread are obtained, they can be integrated to obtain the final transaction statistics result. Therefore, the blockchain transaction statistics method provided in this application not only avoids omitting transaction data that needs to be counted, but also avoids duplicate counting of transaction data. Furthermore, it can improve the speed of transaction data statistics. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0019] Figure 1This application discloses a flowchart of a blockchain transaction statistics method.
[0020] Figure 2 This application discloses a method for obtaining transaction statistics results using threads.
[0021] Figure 3 This application discloses another method for obtaining transaction statistics results using threads;
[0022] Figure 4 This is a structural block diagram of a blockchain transaction statistics device disclosed in this application. Detailed Implementation
[0023] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0024] Next, combine Figure 1 The blockchain transaction statistics method described in this application is detailed below, including the following steps:
[0025] Step S1: Obtain transaction data on the blockchain and store the transaction data, wherein the receiving account address in the transaction data is stored in a set number format.
[0026] Specifically, a blockchain client can be run to obtain or synchronize transaction data from the blockchain corresponding to the client, including transaction data of external transactions and transaction data of internal transactions. The receiving account address in the transaction data is converted into a set number system and then the converted transaction data is stored.
[0027] When storing data, transaction data can be stored in chronological order of transaction time.
[0028] The number system can be set by the user according to the needs of the actual scenario. Specifically, the number system can be binary, octal, decimal, or hexadecimal.
[0029] In addition, the address of the account that initiated the transaction in the transaction data can also be converted into a set number system for storage.
[0030] Users can set the storage location for transaction data according to the needs of the actual scenario. Transaction data can be stored in CSV files, text files, Excel spreadsheets, or database files.
[0031] Step S2: Determine the number of digits in the query to distinguish the receiving transaction account address, and determine the types of all character combinations of the first digits in the receiving transaction account address stored in the set base form, and establish a thread corresponding to each type of character combination.
[0032] Specifically, users can set the number of digits for distinguishing the receiving account address according to the needs of the actual scenario. For example, the number of digits can be set to 1, 2, 3, 4 or 5.
[0033] The number of character combinations is all possible combinations of the previously mentioned query bits in the receiving transaction account address stored in a set base format. With base M as the set base and N as the query bits, the number of character combinations is M raised to the power of N.
[0034] For example, using binary as the set base and 2 as the lookup bit, where binary is represented by 0 and 1, the first and second bits of the lookup bit can both be 0 or 1. Therefore, all possible combinations are listed as 00, 01, 10, and 11. That is, the types of character combinations are 00, 01, 10, and 11. Next, threads can be created corresponding to 00, 01, 10, and 11. Simultaneously, the threads and their corresponding character combinations can be stored in a table.
[0035] Step S3: Call each thread, use the character combination corresponding to the thread as the query condition to query the matching transaction data, and use the matching transaction data to complete the transaction statistics results corresponding to each thread.
[0036] Specifically, each thread can be invoked simultaneously to perform transaction data statistics.
[0037] Each thread reads the stored transaction data and determines whether the receiving account address in each transaction data is a corresponding character combination. If the receiving account address is a corresponding character combination, then the transaction data is the transaction data matched by that thread.
[0038] Each thread has a corresponding character combination, and the character combinations corresponding to each thread form the character combination of the previously queried bits of each receiving transaction account address. Therefore, each receiving transaction account address has a unique corresponding thread.
[0039] It is important to note that different number systems may correspond to different prefixes. When all the receiving transaction account addresses in this application are converted to the same type of set number system, the prefix may not be included in the lookup bit count. When distinguishing receiving transaction account addresses, the prefix can be ignored. For example, if hexadecimal is used as the set number system and the lookup bit count is 2, a certain receiving transaction account address could be 0x3d4f5e. In this case, 3d represents a certain type of character combination corresponding to a certain thread, and the transaction data corresponding to 0x3d4f5e is the transaction data matched by a certain thread.
[0040] Step S4: Integrate the transaction statistics results corresponding to each thread to obtain the final blockchain transaction statistics results.
[0041] Specifically, the transaction statistics results corresponding to each thread can be integrated, and the integrated transaction statistics results can be used as the final transaction statistics results of the blockchain.
[0042] The final blockchain transaction statistics can be stored in the output folder, and users can set the location of the output folder according to the needs of the actual scenario.
[0043] As can be seen from the above technical solution, the blockchain transaction statistics method provided in this application requires first obtaining transaction data from the blockchain and storing this transaction data that needs to be statistically analyzed. The receiving transaction account address in the transaction data is stored in a set base format, which can be binary, octal, decimal, or hexadecimal. Subsequently, the query bit length for distinguishing the receiving transaction account address can be determined, and the types of all character combinations of the receiving transaction account address stored in the set base format can be determined. A thread corresponding to each type of character combination is established. Thus, the number of threads can be consistent with the number of character combination types, and each thread has a unique corresponding character combination, ensuring that no receiving transaction account address is missed, i.e., no transaction data is missed, and each transaction data has a unique corresponding thread, avoiding duplicate statistics. When each thread has a corresponding query condition, the query condition can be used to query matching transaction data in the stored transaction data and perform transaction statistics. Thus, each thread can perform transaction statistics simultaneously and obtain the transaction statistics result corresponding to each thread. Multiple threads performing transaction statistics simultaneously can improve the speed of transaction data statistics. Once the transaction statistics results for each thread are obtained, they can be integrated to obtain the final transaction statistics result. Therefore, the blockchain transaction statistics method provided in this application not only avoids omitting transaction data that needs to be counted, but also avoids duplicate counting of transaction data. Furthermore, it can improve the speed of transaction data statistics.
[0044] In some embodiments of this application, considering that hexadecimal is used as the set base, the amount of resources occupied when storing transaction data can be effectively reduced. Based on this, the process of storing the transaction data in step S1 is described in detail below:
[0045] S10. Convert the storage format of the receiving transaction account address in the transaction data into hexadecimal, and write the converted transaction data line by line into the input set.
[0046] Specifically, the receiving account address in the transaction data can be converted to hexadecimal, and the converted hexadecimal receiving account address can replace the original receiving account address in the transaction data. When the transaction data contains the initiating account address, the initiating account address can also be converted to hexadecimal, and the converted hexadecimal initiating account address can replace the original initiating account address in the transaction data.
[0047] The replaced transaction data is written line by line to a file. Since it may contain a large amount of transaction data, it can be stored in multiple files. The input set consists of files containing the transaction data.
[0048] Based on this, a detailed explanation is provided for step S3, which involves calling each thread, using the character combination corresponding to the thread as the query condition to query matching transaction data, and using the matching transaction data to complete the transaction statistics results for each thread. The steps are as follows:
[0049] S30. Call each thread, using the character combination corresponding to the thread as the query condition, query the matching transaction data in the input set line by line, and use the matching transaction data to complete the transaction statistics results corresponding to each thread.
[0050] Specifically, each thread can be invoked, and each thread reads the receiving transaction account address from the transaction data line by line, and determines whether the first few digits of each receiving transaction account address are the same as the corresponding character combination. If they are the same, then the transaction data corresponding to that receiving transaction account address is the matching transaction data.
[0051] As can be seen from the above technical solution, this embodiment provides an optional method for storing transaction data, which can save storage space. Furthermore, storing and reading transaction data line by line avoids confusion between different transaction data, further ensuring the accuracy of transaction statistics results.
[0052] In some embodiments of this application, two implementation methods are provided: step S30, which involves calling each thread, using the character combination corresponding to the thread as the query condition, querying the matching transaction data in the input set line by line, and using the matching transaction data to complete the transaction statistics results corresponding to each thread. Next, we will combine... Figure 2-Figure 3 The processes of these two implementation methods are described in detail.
[0053] The first type
[0054] See Figure 2 This application discloses a flowchart of a method for obtaining transaction statistics results using threads.
[0055] S300. Create a statistical variable corresponding to each thread, wherein the statistical variable is used to record the transaction statistical results corresponding to the thread.
[0056] Specifically, a corresponding statistical variable can be created for each thread so that the transaction statistics results for that thread can be recorded in the statistical variable later.
[0057] At this point, you can retrieve the original transaction statistics from memory, store them in the statistical variables, and perform transaction statistics directly based on the original results, or you can start performing transaction statistics anew.
[0058] S301. Call each thread to sequentially read the transaction data of each row starting from the first row in the input set.
[0059] Specifically, each thread can be invoked so that each thread reads the transaction data of each row sequentially, starting from the first row of the input set, to avoid omissions.
[0060] S302. Using the thread, determine whether the first few digits of the received transaction account address in the current row of transaction data are the corresponding character combination. If yes, proceed to step S303; otherwise, proceed to step S305.
[0061] Specifically, it can be determined whether the current row of transaction data is a matching transaction data by judging whether the previously queried number of digits of the receiving transaction account address in the current row of transaction data is the corresponding character combination.
[0062] If the current row of transaction data is a matching transaction, proceed to step S303; if the current row of transaction data is not a matching transaction, proceed to step S305.
[0063] S303. Determine that the current row transaction data is the matching transaction data, and use the thread to update the statistical variables based on the current row transaction data.
[0064] Specifically, if the previously queried character combination of the receiving account address in the current row of transaction data matches, then the current row of transaction data can be confirmed as a matching transaction. Thus, the thread can use this thread to update the transaction statistics results in the corresponding statistical variables.
[0065] S304. Using the thread, read the transaction data of the next row in the input set and return to the execution step S302.
[0066] Specifically, once the update is complete, the thread can read the transaction data of the next row in the input set and return to execute step S302 until the thread reads the last row of the input set.
[0067] Specifically, if the current row of transaction data is not a matching transaction data, the thread can directly read the next row of the input set and return to execute step S302 until the thread reads the last row of the input set.
[0068] The second type
[0069] During the process of statistical analysis of transaction data, due to insufficient system resources, it is inevitable that the analysis will be interrupted. Therefore, it is necessary to record the current transaction statistical results of the thread. The following will combine... Figure 3 The process of recording the current transaction statistics of this thread is explained in detail, and the specific steps are as follows:
[0070] S305. Create a statistical variable corresponding to each thread, wherein the statistical variable is used to record the transaction statistical results corresponding to the thread.
[0071] S306. Call each thread to sequentially read the transaction data of each row starting from the first row in the input set.
[0072] S307. Using the thread, determine whether the first few digits of the received transaction account address in the current row of transaction data are the corresponding character combination. If yes, execute step S308; otherwise, directly execute step S309.
[0073] S308. Determine that the current row transaction data is matching transaction data, and use the thread to update the statistical variables based on the current row transaction data.
[0074] The steps S300-S303 described above correspond one-to-one with steps S305-S308 in the aforementioned embodiments. For details, please refer to the foregoing description, which will not be repeated here.
[0075] S309. Determine and record the number of threads currently allowed to run.
[0076] Specifically, the number of threads currently allowed to run can be determined in several ways. The number of threads can be calculated based on the amount of resources currently occupied by the threads and the amount of resources remaining available; or it can be determined based on the number of threads allowed to run simultaneously as set by the user.
[0077] S310. Record the position of the current line read by each thread, and determine whether the current line is the last line of the input set. If not, execute step S311; if yes, execute step S314.
[0078] Specifically, it can record the position read by each thread and determine whether each thread has completed the statistics.
[0079] S311. Determine that the thread is an incomplete thread.
[0080] Specifically, when a thread has not completed its statistics, it can be confirmed that the thread is an incomplete thread.
[0081] S312. Determine whether the number of currently allowed running threads is less than the number of incomplete threads. If yes, proceed to step S313. If no, return directly to step S318.
[0082] Specifically, it can be determined whether the current capacity is sufficient to run all incomplete threads simultaneously. If the number of threads currently allowed to run is less than the number of incomplete threads, step S313 is executed. If the number of threads currently allowed to run is greater than or equal to the number of incomplete threads, it means that all threads can start simultaneously, and therefore, the process can directly return to step S318.
[0083] S313. According to the preset pause rules, determine the set of stopped threads to be paused, and store the current transaction statistics results in the statistical variables corresponding to each stopped thread in the set of stopped threads in a temporary folder. The threads in the incomplete threads other than the set of stopped threads are regarded as new incomplete threads.
[0084] Specifically, the preset pause rule can be to pause the thread with the larger value among multiple character combinations. Furthermore, since the number of threads is always a multiple of 2 regardless of whether the set base is binary, octal, decimal, or hexadecimal, it can be determined to pause half of the unfinished threads for ease of calculation.
[0085] Of course, you can also pause 1 / 3 or 1 / 5 of the remaining unfinished threads, or pause the threads with smaller values in the character combinations. The pause rules can be adjusted adaptively according to the specific situation, and this application does not impose any restrictions.
[0086] S314. Determine that the thread is a completed thread.
[0087] Specifically, when the thread has read the last line of the input set and determined whether the last line of transaction data is a matching transaction data, and if the last line of transaction data is a matching transaction data, and has also used the last line of transaction data to update the transaction statistics result in the statistical variable, then the thread is considered a completed thread and has completed the task of statistical analysis of the transaction data.
[0088] It should be noted that each row of transaction data in this application has one and only one corresponding thread.
[0089] S315. Determine if there is a set of stopped threads. If yes, proceed to step S316. If no, proceed directly to step S318.
[0090] Specifically, when one thread completes the statistics, a paused thread can be selected to continue running.
[0091] S316. Select a stopped thread from the stopped thread set as the target thread, and delete the target thread from the stopped thread set.
[0092] Specifically, when a set of stopped threads exists, it can be determined that there are currently stopped threads that have not completed their statistics and are in a paused state. In this case, a stopped thread can be selected from the set of stopped threads as the target thread and restarted.
[0093] S317. Obtain the current transaction statistics result corresponding to the target thread from the temporary folder, store it in the statistical variable corresponding to the target thread, and treat the target thread as an incomplete thread.
[0094] Specifically, the current transaction statistics results matched by the target thread can be obtained directly from the temporary folder.
[0095] S318. Call the unfinished thread, read the transaction data of the next row in the input set, and return to execute step S307.
[0096] Specifically, since the current transaction statistics of each paused thread has been stored in a temporary folder in step S313, and the position of the current line read by each thread has been recorded, when the target thread restarts, it can skip the transaction data read before the pause and start counting the transaction data that has not been read.
[0097] As can be seen from the above technical solutions, when the first implementation method is adopted, each thread reads and judges whether the transaction data is matching transaction data line by line, which further avoids missing transaction data. Moreover, all threads can read each line of transaction data in the input set at the same time without affecting each other, which further improves the speed of transaction data statistics.
[0098] In the second implementation method, each thread in this application can pause the statistics, and when the paused thread is restarted, it can skip the already read transaction data and start execution from the unread transaction data, so that each thread will not read the same transaction data repeatedly.
[0099] Furthermore, this application reads transaction data line by line, which avoids missing any transaction data that needs to be counted and does not disrupt the order in which transactions occurred. This application records the position read by each thread, so that even if a thread is interrupted during the counting process, it can still resume from the interrupted position when restarted.
[0100] In addition, when new subsequent transaction data is generated, the new transaction data can be written directly to the input set line by line. At this time, the data statistics can still be continued using the currently created thread.
[0101] In some embodiments of this application, the process of S309, determining and recording the number of threads currently allowed to run, is described in detail, and the specific steps are as follows:
[0102] S3090. Monitor the current resource usage and, based on the current resource usage, determine and record the number of threads currently allowed to run.
[0103] Specifically, the current resource consumption can be monitored. If the remaining memory is less than 5%, a temporary interruption scheme can be initiated. The number of threads currently allowed to run can be determined and recorded as 1 / n of the number of character combinations in step S2, where n can be any integer, such as 2, 3, 4, etc. That is, when the remaining memory is small, the number of threads currently allowed to run can be determined as 1 / 2, 1 / 3, or 1 / 4 of the number of character combinations in step S2, etc.
[0104] For example, if we use hexadecimal as the set base and 2 as the lookup bit, then the number of threads created is 256, and all 256 threads are incomplete. When the temporary interrupt scheme is activated, we can determine that 128 threads are the currently allowed number of running threads.
[0105] When it is necessary to stop 128 threads, the thread corresponding to the character combination with the larger value can be paused and the memory corresponding to that thread can be closed to avoid the paused thread consuming resources.
[0106] In addition, the relationship between resource usage and the number of threads can be set, with different amounts of remaining resources corresponding to different numbers of threads allowed to run.
[0107] As can be seen from the above technical solution, this embodiment provides an optional method for determining the number of threads currently allowed to run. That is, the number of threads currently allowed to run can be determined based on the current resource consumption. Therefore, the above method for determining the number of threads currently allowed to run is more scientific, can avoid the situation where paused threads occupy resources, and can better complete the statistical analysis of transaction data.
[0108] In some embodiments of this application, three methods are provided for implementing step S303: determining that the current row transaction data is matching transaction data, and updating the statistical variable using the thread based on the current row transaction data. These three methods will be described in detail below:
[0109] The first type
[0110] The transaction statistics for each thread include: the number of transactions, transaction resources, first transaction block number, and last transaction block number between each type of initiating account address and other receiving account addresses in the transaction data matched by the thread; and the number of transactions, transaction resources, first transaction block number, and last transaction block number between each type of receiving account address and other initiating account addresses. The specific implementation process is as follows:
[0111] S3030, Using the thread, determine the target transaction time, target receiving account address, target initiating account address, target transaction resource quantity, and target block number of the current row of transaction data.
[0112] Specifically, the current transaction data may include the address of the account that initiated the transaction, the address of the account that received the transaction, whether the address of the account that initiated the transaction is a contract address, whether the address of the account that received the transaction is a contract address, the block number on which the transaction occurred, whether it is a block reward, the amount of transaction resources, and the transaction number.
[0113] Therefore, when the current row of transaction data read by this thread is a matching transaction data, the thread can be used to determine the target transaction time, target receiving account address, target initiating account address, target transaction resource quantity, and target block number of the current row of transaction data.
[0114] It should be noted that if the current transaction data is a block reward, the target initiating account address does not exist. In this case, you can only read the target transaction time, the target receiving account address, the target transaction resource amount, and the target block number.
[0115] S3031. Using the thread, determine whether the statistical variable contains transaction statistics between the target receiving transaction account address and the target initiating transaction account address. If yes, proceed to step S3032; otherwise, proceed to step S3036.
[0116] Specifically, the thread is used to determine whether the statistical variable contains transaction statistics between the target receiving account address and the target initiating account address.
[0117] If the current transaction data is a block reward, it can be determined whether the statistical variables contain transaction statistics between the target receiving account address and other initiating account addresses.
[0118] S3032. Using the thread, increment the number of transactions between the target receiving account address and the target initiating account address in the statistical variables by 1.
[0119] Specifically, this thread can be used to directly add the number of transactions between the target receiving account address and the target initiating account address to the corresponding statistical variables.
[0120] If the current transaction data is a block reward, the number of block rewards for the target receiving transaction account address in the statistical variables can be directly incremented by 1.
[0121] S3033. Using the thread, update the transaction resource quantity between the target receiving transaction account address and the target initiating transaction account address in the statistical variables to the original transaction resource quantity plus the target transaction resource quantity.
[0122] Specifically, using this thread, the original transaction resource quantity between the target receiving transaction account address and the target initiating transaction account address in the statistical variables is obtained, the sum of the original transaction resource quantity and the target transaction resource quantity is calculated, and the sum of the original transaction resource quantity and the target transaction resource quantity is used to replace the original transaction resource quantity.
[0123] If the current transaction data is a block reward, the block reward amount of the target receiving transaction account address in the statistical variables can be directly updated to the original block reward amount plus the target transaction resource amount.
[0124] S3034. Using the thread, determine whether the transaction time corresponding to the first transaction block number between the target receiving transaction account address and the target initiating transaction account address in the statistical variables is earlier than the target transaction time. If it is not earlier than the target transaction time, then the target block number is used as the first transaction block number in the statistical variables.
[0125] Specifically, the thread can be used to obtain the transaction time corresponding to the first transaction block number recorded in the statistical variables and compare it with the transaction time in the current row of transaction data. If it is earlier than the transaction time in the current row of transaction data, there is no need to update the first transaction block number in the statistical variables. If it is later than the transaction time in the current row of transaction data, the target block number is used as the first transaction block number.
[0126] S3035. Using the thread, determine whether the transaction time corresponding to the last transaction block number between the target receiving transaction account address and the target initiating transaction account address in the statistical variables is later than the target transaction time. If it is not later than the target transaction time, then use the target block number as the last transaction block number in the statistical variables.
[0127] Specifically, the thread can be used to obtain the transaction time corresponding to the latest transaction block number recorded in the statistical variables and compare it with the transaction time in the current row of transaction data. If it is later than the transaction time in the current row of transaction data, there is no need to update the last transaction block number in the statistical variables. If it is earlier than the transaction time in the current row of transaction data, the target block number is used as the last transaction block number.
[0128] The statistical variables can also store the transaction time corresponding to the last transaction.
[0129] S3036. Using the thread, add the transaction statistics result between the target receiving transaction account address and the target initiating transaction account address to the statistical variables, and set the number of transactions to 1, the transaction resource amount to the target transaction resource amount, and the block number of the first transaction and the block number of the last transaction to the target block number.
[0130] Specifically, when the statistical variables do not record the transaction statistics between the target receiving account address and the target initiating account address, the transaction statistics can be added directly to the statistical variables. In this case, the number of transactions in the transaction statistics will be 1, the transaction resource amount will be the target transaction resource amount, and the block number of the first transaction and the block number of the last transaction will both be the target block number.
[0131] The second type
[0132] The transaction statistics for each thread can include: the N1 most recent transactions from each type of initiating account address within the thread's matched transaction data, and the N2 most recent transactions from each type of receiving account address within the thread's matched transaction data. The specific implementation process is as follows:
[0133] S3037. Determine the target transaction time, target initiating account address, and target receiving account address of the current row of transaction data read by the thread.
[0134] Specifically, the transaction data may include the address of the receiving account, the address of the initiating account, and the transaction time.
[0135] If the current transaction data is a block reward, the target transaction time and the target receiving account address of the current transaction data can be determined.
[0136] S3038. Using the thread, sort the transaction times of the target transaction time and the transaction times of the transaction data corresponding to the target initiating account address in the statistical variables, and select N1 transaction data with the later transaction times. Also, sort the transaction times of the target transaction time and the transaction times of the transaction data corresponding to the target receiving account address in the statistical variables, and select N2 transaction data with the later transaction times.
[0137] Specifically, due to the large volume of transaction data and the potential for excessive transactions from a single account address, it is necessary to make certain selections in the transaction data. This involves determining whether to retain all transactions or only the most recent ones.
[0138] The sizes of N1 and N2 are primarily determined by the use case. Generally, if all transactions with a specific account address are required, all transactions need to be retained, which consumes a significant amount of storage space. The account address can be either the receiving account address or the initiating account address. If only recent transactions are needed, then only a few dozen or a few hundred recent transactions need to be retained. If it's unclear whether only recent transactions are needed, it's generally considered that N1 and N2 should be designed to be larger when the transaction data volume exceeds 100 million; otherwise, all transactions should be retained.
[0139] The values of N1 and N2 can be the same or different.
[0140] S3039. Using the thread, replace the existing transaction data of the target initiating transaction account address in the statistical variables with the selected N1 transaction data.
[0141] Specifically, this thread can be used to store the N1 most recent transaction data entries in the corresponding statistical variables. To save space, the hash values corresponding to the N1 transaction data entries can be stored during storage.
[0142] S3040. Using the thread, replace the existing transaction data of the target receiving transaction account address in the statistical variable with the selected N2 transaction data.
[0143] Specifically, this thread can be used to store the recent N2 transaction data points in the corresponding statistical variables. To save space, the hash values corresponding to the N2 transaction data points can be stored during storage.
[0144] The third type
[0145] The transaction statistics for each thread include not only the number of transactions, transaction resources, first transaction block number, and last transaction block number between each type of initiating account address and other receiving account addresses in the transaction data matched by the thread, but also the number of transactions, transaction resources, first transaction block number, and last transaction block number between each type of receiving account address and other initiating account addresses, as well as the N1 transaction data entries with the latest transaction time in the transaction data of each type of initiating account address, and the N2 transaction data entries with the latest transaction time in the transaction data of each type of receiving account address.
[0146] The specific implementation steps can be referred to the first and second methods mentioned above, and will not be repeated here.
[0147] As can be seen from the above technical solutions, this embodiment provides three optional methods for obtaining the transaction statistics results corresponding to each thread. Through the above methods, it is possible to use threads to count the matching transaction data in the corresponding statistical variables, so as to simplify the massive transaction data into transaction statistics results, save storage space, and facilitate viewing the transaction status between account addresses.
[0148] Based on this, some embodiments of this application provide three implementation methods for step S4: integrating the transaction statistics results corresponding to each thread to obtain the final blockchain transaction statistics results. The processes of these three implementation methods will be described in detail below:
[0149] The first type
[0150] The transaction statistics for each thread include: the number of transactions, transaction resources, first transaction block number, and last transaction block number between each type of initiating account address and other receiving account addresses in the matched transaction data; and the number of transactions, transaction resources, first transaction block number, and last transaction block number between each type of receiving account address and other initiating account addresses. The specific steps for integrating the transaction statistics are as follows:
[0151] S40. Add the number of transactions for the same receiving account address and the same initiating account address in each statistical variable to get the final number of transactions.
[0152] Specifically, each statistical variable contains the number of transactions, transaction resources, first transaction block number, and last transaction block number between each type of initiating transaction account address and other receiving transaction account addresses, as well as the number of transactions, transaction resources, first transaction block number, and last transaction block number between each type of receiving transaction account address and other initiating transaction account addresses.
[0153] The same account address is not necessarily of the same type in the various statistical variables. That is, the same account address can be the account address that receives the transaction or the account address that initiates the transaction. The account address that receives the transaction can be used as the account address that initiates the transaction, and the account address that initiates the transaction can also be used as the account address that receives the transaction.
[0154] By adding up the number of transactions between the same receiving account address and the same initiating account address among the various statistical variables, we can obtain the total number of transactions between the receiving account address and the initiating account address.
[0155] It is possible to calculate the number of transactions between the same account address as the receiving account address and the same initiating account address, as well as the number of transactions between the same account address as the initiating account address and the same receiving account address.
[0156] S41. Add the transaction resource amounts of the same receiving transaction account address and the same initiating transaction account address in each statistical variable to obtain the final transaction resource amount.
[0157] Specifically, by adding up the transaction resource amounts between the same receiving account address and the same initiating account address among the various statistical variables, the total transaction resource amount between the receiving account address and the initiating account address can be obtained.
[0158] It is possible to calculate the amount of resources spent when the same account address is used as the account address initiating a transaction, and the amount of resources gained when it is used as the account address receiving a transaction.
[0159] S42. Sort the transaction times corresponding to the first transaction block number of the same receiving transaction account address and the same initiating transaction account address in each statistical variable, and select the block number with the earliest transaction time as the final first transaction block number.
[0160] Specifically, the block number where the first transaction occurred can be selected from the same receiving account address and the same initiating account address.
[0161] S43. Sort the transaction times corresponding to the last transaction block number in each statistical variable for the same receiving transaction account address and the same initiating transaction account address, and select the block number with the latest transaction time as the final last transaction block number. The transaction statistics result includes the final number of transactions, the final transaction resource amount, the final first transaction block number, and the final first transaction block number.
[0162] Specifically, the block number of the latest transaction from the same receiving account address and the same initiating account address can be selected.
[0163] Once the integration is complete, the transaction data to be analyzed is compiled into transaction statistics, including: the final number of transactions between each type of receiving account address and each initiating account address, the final transaction resource amount, the final first transaction block number, and the final first transaction block number. At this point, transaction data retrieved from the blockchain can be deleted to save space.
[0164] The second type
[0165] The transaction statistics results corresponding to each thread include: the N1 transactions with the latest transaction time from each type of initiating account address in the transaction data matched by the thread, and the N2 transactions with the latest transaction time from each type of receiving account address in the transaction data. The specific steps for integrating the transaction statistics results are as follows:
[0166] S44. Sort the transaction times of the same account address in each statistical variable according to their transaction times, and select the N1 transaction data with the latest transaction time.
[0167] Specifically, N1 transaction data points corresponding to the same account address that initiated the transaction can be obtained from each statistical variable. The transaction data points are then sorted according to their transaction time, and the N1 transaction data points with the later transaction time are selected as the final transaction data points corresponding to the account address that initiated the transaction.
[0168] To save space, only the hash value of the final corresponding transaction data can be stored.
[0169] S45. Sort the transaction times of the same receiving account address in each statistical variable according to their order, and select the N2 transaction data with the latest transaction time.
[0170] Specifically, N2 transaction data corresponding to the same receiving account address can be obtained from each statistical variable, and the transaction data can be sorted according to the transaction time. The N2 transaction data with the later transaction time can be selected as the final transaction data corresponding to the receiving account address.
[0171] To save space, only the hash value of the final corresponding transaction data can be stored.
[0172] After integration, the transaction data to be analyzed is compiled into transaction statistics, including: N1 transaction records corresponding to the receiving account address for each type of transaction, and N2 transaction records corresponding to the initiating account address for each type of transaction. At this point, transaction data retrieved from the blockchain can be deleted to save space.
[0173] The third type
[0174] The transaction statistics for each thread include not only the number of transactions, transaction resources, first transaction block number, and last transaction block number between each type of initiating account address and other receiving account addresses in the transaction data matched by the thread, but also the number of transactions, transaction resources, first transaction block number, and last transaction block number between each type of receiving account address and other initiating account addresses, as well as the N1 transaction data entries with the latest transaction time in the transaction data of each type of initiating account address, and the N2 transaction data entries with the latest transaction time in the transaction data of each type of receiving account address.
[0175] The specific implementation steps can be referred to the first and second methods mentioned above, and will not be repeated here.
[0176] After integration, the transaction data to be statistically analyzed is compiled into transaction statistics, including: the final number of transactions between each type of receiving account address and each initiating account address, the final transaction resource amount, the final first transaction block number, and N2 transaction records; and the final number of transactions between each type of initiating account address and each receiving account address, the final transaction resource amount, the final first transaction block number, and N1 transaction records. At this point, transaction data retrieved from the blockchain can be deleted to save space.
[0177] As can be seen from the above technical solutions, this embodiment provides three optional methods for integrating the transaction statistics results corresponding to each thread. Through the above process, the complex transaction data can be simplified into transaction statistics results between each account address, making the transaction situation between each account address clear and concise, saving storage space, improving the efficiency of querying transaction data, and integrating the transaction statistics results corresponding to each thread that is executed at the same time, thereby improving work efficiency.
[0178] Next, the blockchain transaction statistics device provided in this application will be described in detail. The blockchain transaction statistics device described below can be referred to in correspondence with the blockchain transaction statistics method described above.
[0179] See Figure 3 , Figure 3 This is a schematic diagram of the structure of a blockchain transaction statistics device disclosed in this application.
[0180] Acquisition unit 1 is used to acquire transaction data on the blockchain and store the transaction data, wherein the receiving account address in the transaction data is stored in a set number format;
[0181] The determining unit 2 is used to determine the number of query bits that distinguish the receiving transaction account address, and to determine the type of all character combinations of the first query bits of the receiving transaction account address stored in the set base form, and to establish a thread corresponding to each type of character combination.
[0182] Calling unit 3 is used to call each thread, using the character combination corresponding to the thread as the query condition to query the matching transaction data, and use the matching transaction data to complete the transaction statistics results corresponding to each thread.
[0183] Integration unit 4 is used to integrate the transaction statistics results corresponding to each thread to obtain the final blockchain transaction statistics results.
[0184] Furthermore, the acquisition unit may include:
[0185] The transaction data writing unit is used to convert the storage format of the receiving transaction account address in the transaction data into hexadecimal, and write the converted transaction data line by line into the input set;
[0186] Based on this, the calling unit may include:
[0187] The thread query unit is used to call each thread, using the character combination corresponding to the thread as the query condition, to query the matching transaction data in the input set line by line, and to use the matching transaction data to complete the transaction statistics results corresponding to each thread.
[0188] Furthermore, the thread query unit may include:
[0189] A variable creation unit is used to create statistical variables corresponding to each thread, and the statistical variables are used to record the transaction statistical results corresponding to the thread.
[0190] A thread sequential reading unit is used to sequentially read transaction data from the first row of the input set using each thread.
[0191] A thread utilization unit is used to use the thread to determine whether the first few queried bits of the receiving transaction account address in the current row of transaction data are a corresponding character combination.
[0192] The variable update unit is used to determine that the current row of transaction data is matching transaction data if the first few queried digits of the receiving transaction account address in the current row of transaction data are the corresponding character combination, and to update the statistical variable according to the current row of transaction data using the thread;
[0193] The next line reading unit is used to read the transaction data of the next line in the input set after the update is completed, using the thread, and return to the step of determining whether the queried digits of the receiving transaction account address in the current line of transaction data are the corresponding character combination;
[0194] The set reading unit is used to read the next row of transaction data in the input set using the thread if the first queried digits of the receiving transaction account address in the current row of transaction data are not the corresponding character combination, and then return to execute the step of determining whether the first queried digits of the receiving transaction account address in the current row of transaction data are the corresponding character combination.
[0195] Furthermore, the blockchain transaction statistics device may also include:
[0196] The quantity determination unit is used to determine and record the number of threads currently allowed to run;
[0197] The position recording unit is used to record the position of the current line read by each thread and to determine whether the current line is the last line of the input set;
[0198] An incomplete thread determination unit is used to determine that a thread is an incomplete thread when the position is not the last row of the input set;
[0199] The pause thread unit is used to determine the set of stopped threads to be paused according to a preset pause rule when the number of currently allowed running threads is less than the number of unfinished threads, and to store the current transaction statistics result in the statistical variables corresponding to each stopped thread in the stop thread set in a temporary folder;
[0200] The remaining unfinished thread call unit is used to call the remaining unfinished threads other than the stopped thread set, and return to the step of reading the transaction data of the next row in the input set;
[0201] The thread deletion unit is used to select a stopped thread as the target thread and delete the target thread from the set of stopped threads when the current behavior of any of the remaining unfinished threads reads the last line of the current behavior.
[0202] The target thread invocation unit is used to invoke the target thread, obtain the current transaction statistics result corresponding to the target thread from the temporary folder, store it in the statistical variable corresponding to the target thread, and invoke the target thread to return to execute the step of reading the transaction data of the next row in the input set.
[0203] Furthermore, the quantity determination unit may include:
[0204] The resource monitoring unit is used to monitor the current resource usage and, based on the current resource usage, determine and record the number of threads that are currently allowed to run.
[0205] Furthermore, the variable update unit may include:
[0206] The first variable update unit is used to determine the target transaction time, target receiving transaction account address, target initiating transaction account address, target transaction resource quantity, and target block number of the current row of transaction data using the thread.
[0207] The second variable update unit is used to use the thread to determine whether the statistical variable contains the transaction statistics between the target receiving account address and the target initiating account address;
[0208] The third variable update unit is used to increment the number of transactions between the target receiving account address and the target initiating account address in the statistical variable by 1 if there are transaction statistics between the target receiving account address and the target initiating account address.
[0209] The fourth variable update unit is used to update the transaction resource amount between the target receiving transaction account address and the target initiating transaction account address in the statistical variable to the original transaction resource amount plus the target transaction resource amount using the thread.
[0210] The fifth variable update unit is used to use the thread to determine whether the transaction time corresponding to the first transaction block number between the target receiving transaction account address and the target initiating transaction account address in the statistical variable is earlier than the target transaction time. If it is not earlier than the target transaction time, the target block number is used as the first transaction block number in the statistical variable.
[0211] The sixth variable update unit is used to use the thread to determine whether the transaction time corresponding to the last transaction block number between the target receiving transaction account address and the target initiating transaction account address in the statistical variable is later than the target transaction time. If it is not later than the target transaction time, the target block number is used as the last transaction block number in the statistical variable.
[0212] The seventh variable update unit is used to add the transaction statistics between the target receiving transaction account address and the target initiating transaction account address to the statistical variables if there is no transaction statistics between the target receiving transaction account address and the target initiating transaction account address. The transaction count is set to 1, the transaction resource amount is the target transaction resource amount, and the block number of the first transaction and the block number of the last transaction are both the target block number.
[0213] Furthermore, the variable update unit may include:
[0214] The eighth variable update unit is used to use the thread to sort the transaction times of the target transaction time and the transaction times of the transaction data corresponding to the target initiating account address in the statistical variables, and select the N1 transaction data with the later transaction times; and to sort the transaction times of the target transaction time and the transaction times of the transaction data corresponding to the target receiving account address in the statistical variables, and select the N2 transaction data with the later transaction times.
[0215] The ninth variable update unit is used to replace the existing transaction data of the target initiating transaction account address in the statistical variables with the selected N1 transaction data using the thread.
[0216] The tenth variable update unit is used to replace the existing transaction data of the target receiving transaction account address in the statistical variables with the selected N2 transaction data using the thread.
[0217] Furthermore, the integration unit may include:
[0218] The first integration unit is used to add the number of transactions for the same receiving account address and the same initiating account address in each statistical variable, and use this as the final number of transactions.
[0219] The second integration unit is used to add the transaction resource amounts of the same receiving transaction account address and the same initiating transaction account address in each statistical variable to obtain the final transaction resource amount.
[0220] The third integration unit is used to sort the transaction times corresponding to the first transaction block number of the same receiving transaction account address and the same initiating transaction account address in each statistical variable, and select the block number with the earliest transaction time as the final first transaction block number.
[0221] The fourth integration unit is used to sort the transaction times corresponding to the last transaction block number of the same receiving transaction account address and the same initiating transaction account address in each statistical variable, and select the block number with the latest transaction time as the final last transaction block number. The transaction statistics results include the final number of transactions, the final transaction resource amount, the final first transaction block number, and the final first transaction block number.
[0222] Furthermore, the integration unit may include:
[0223] The fifth integration unit is used to sort the transaction times of the same account address in each statistical variable and select the N1 transaction data with the latest transaction time.
[0224] The sixth integration unit is used to sort the transaction times of the same receiving account address in each statistical variable and select the N2 transaction data with the later transaction times.
[0225] Optionally, the refined and extended functions of the program can be referred to the above description.
[0226] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0227] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0228] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. The various embodiments of this application can be combined with each other. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A blockchain transaction statistics method, characterized in that, include: Obtain transaction data from the blockchain, convert the storage format of the receiving transaction account address in the transaction data into hexadecimal, and write the converted transaction data line by line into the input set; Determine the number of query bits to distinguish the receiving transaction account address, and determine the types of all character combinations of the first query bits of the receiving transaction account address stored in the hexadecimal form, and establish a thread corresponding to each type of character combination; Create a statistical variable corresponding to each thread, which is used to record the transaction statistics results corresponding to the thread; call each thread to read the transaction data of each row sequentially starting from the first row in the input set; Using the aforementioned thread, determine whether the first few digits of the received transaction account address in the current row of transaction data match the corresponding character combination; If so, the current row transaction data is determined to be matching transaction data, and the thread is used to update the statistical variables based on the current row transaction data; After the update is completed, the thread is used to read the transaction data of the next row in the input set, and then returns to the step of determining whether the queried digits of the receiving account address in the current row of transaction data are the corresponding character combination; If not, then the thread is used to read the transaction data of the next row in the input set, and the process returns to the step of determining whether the queried digits of the receiving account address in the current row of transaction data are the corresponding character combination; The transaction statistics results for each thread are integrated to obtain the final blockchain transaction statistics results.
2. The method according to claim 1, characterized in that, Before reading the transaction data of the next row in the input set, the process also includes: Determine and record the number of threads currently allowed to run; Record the position of the current line read by each thread, and determine whether the current line is the last line of the input set; When the position is not the last row of the input set, the thread is determined to be an incomplete thread; When the number of currently allowed running threads is less than the number of incomplete threads, a set of stopped threads is determined according to the preset pause rules, and the current transaction statistics result in the statistical variables corresponding to each stopped thread in the stopped thread set is stored in a temporary folder; Call the remaining unfinished threads in the unfinished threads list, excluding the stopped thread set, and return to the step of reading the transaction data of the next row in the input set; When any of the remaining unfinished threads reads the last line of the current behavior, select a stopped thread as the target thread and remove the target thread from the set of stopped threads; The target thread is invoked to retrieve the current transaction statistics result corresponding to the target thread from the temporary folder, store it in the statistical variable corresponding to the target thread, and then the target thread is invoked to return and execute the step of reading the transaction data of the next row in the input set.
3. The method according to claim 2, characterized in that, Determine and record the current number of threads allowed to run, including: Monitor current resource usage and, based on the current resource usage, determine and record the number of threads currently allowed to run.
4. The method according to claim 1, characterized in that, The transaction data also includes the transaction time, the address of the account initiating the transaction, the amount of transaction resources, and the block number on which the transaction occurred; the transaction statistics results corresponding to the thread include: in each transaction data matched by the thread, the number of transactions, the amount of transaction resources, the block number on which the first transaction occurred, and the block number on which the last transaction occurred for each type of initiating account address and other receiving account addresses, as well as the number of transactions, the amount of transaction resources, the block number on which the first transaction occurred, and the block number on which the last transaction occurred for each type of receiving account address and other initiating account addresses; The step of updating the statistical variables using the thread based on the current row of transaction data includes: The thread is used to determine the target transaction time, target receiving account address, target initiating account address, target transaction resource quantity, and target block number of the current row of transaction data. Using the thread, determine whether the statistical variable contains transaction statistics between the target receiving account address and the target initiating account address; If there are transaction statistics between the target receiving account address and the target initiating account address, then the thread is used to increment the number of transactions between the target receiving account address and the target initiating account address in the statistics variable by 1. Using the thread, the transaction resource amount between the target receiving transaction account address and the target initiating transaction account address in the statistical variables is updated to the original transaction resource amount plus the target transaction resource amount; Using the thread, determine whether the transaction time corresponding to the first transaction block number between the target receiving transaction account address and the target initiating transaction account address in the statistical variables is earlier than the target transaction time. If it is not earlier than the target transaction time, then the target block number is used as the first transaction block number in the statistical variables. Using the thread, determine whether the transaction time corresponding to the last transaction block number between the target receiving account address and the target initiating account address in the statistical variables is later than the target transaction time. If it is not later than the target transaction time, then the target block number is used as the last transaction block number in the statistical variables. If no transaction statistics result exists between the target receiving transaction account address and the target initiating transaction account address, then the thread is used to add the transaction statistics result between the target receiving transaction account address and the target initiating transaction account address to the statistical variables, and the number of transactions is set to 1, the transaction resource amount is the target transaction resource amount, and the block number of the first transaction and the block number of the last transaction are both the target block number.
5. The method according to claim 4, characterized in that, The transaction statistics results for each thread are integrated to obtain the final blockchain transaction statistics results, including: The number of transactions for the same receiving account address and the same initiating account address in each statistical variable is added together to obtain the final number of transactions. The transaction resource amounts of the same receiving account address and the same initiating account address in each statistical variable are added together to obtain the final transaction resource amount. The transaction times corresponding to the first transaction in each statistical variable for the same receiving account address and the same initiating account address are sorted sequentially, and the block number with the earliest transaction time is selected as the final first transaction block number. The transaction times corresponding to the last transaction block number of the same receiving transaction account address and the same initiating transaction account address in each statistical variable are sorted in order, and the block number with the latest transaction time is selected as the final last transaction block number. The transaction statistics result includes the final number of transactions, the final transaction resource amount, the final first transaction block number, and the final first transaction block number.
6. The method according to claim 1, characterized in that, The transaction data also includes the address of the account that initiated the transaction and the transaction time; The transaction statistics results corresponding to the thread include: N1 transaction data with the latest transaction time in each type of transaction data of the initiating account address, and N2 transaction data with the latest transaction time in each type of transaction data of the receiving account address. The thread updates the statistical variables based on the current row of transaction data, including: Determine the target transaction time, target initiating account address, and target receiving account address of the current row of transaction data read by the thread; Using the thread, the transaction times of the target transaction time and the transaction times of the transaction data corresponding to the target initiating account address in the statistical variables are sorted sequentially, and N1 transaction data with the later transaction times are selected; and the transaction times of the target transaction time and the transaction times of the transaction data corresponding to the target receiving account address in the statistical variables are sorted sequentially, and N2 transaction data with the later transaction times are selected. Using the thread, the selected N1 transaction data will replace the existing transaction data of the target initiating account address in the statistical variables; Using the thread, the selected N2 transaction data are used to replace the existing transaction data of the target receiving transaction account address in the statistical variables.
7. The method according to claim 6, characterized in that, The transaction statistics results for each thread are integrated to obtain the final blockchain transaction statistics results, including: Sort the transaction data of the same account address that initiated the transaction in each statistical variable according to the transaction time, and select the N1 transaction data with the latest transaction time. The transaction times of the same receiving account address in each statistical variable are sorted sequentially, and the N2 transaction data with the latest transaction time are selected.
8. A blockchain transaction statistics device, characterized in that, include: The acquisition unit is used to acquire transaction data on the blockchain, convert the storage format of the receiving transaction account address in the transaction data into hexadecimal, and write the converted transaction data line by line into the input set; The determining unit is used to determine the number of query bits that distinguish the receiving transaction account address, and to determine the type of all character combinations of the first query bits of the receiving transaction account address stored in the hexadecimal form, and to establish a thread corresponding to each type of character combination. The calling unit is used to create a statistical variable corresponding to each thread, and the statistical variable is used to record the transaction statistical results corresponding to the thread. Each thread is invoked to sequentially read transaction data from each row of the input set, starting from the first row. The thread then determines whether the first few digits of the receiving account address in the current row of transaction data match the specified character combination. If so, the current row of transaction data is determined to be a matching transaction, and the thread updates the statistical variables based on the current row of transaction data. After the update is complete, the thread reads the next row of transaction data from the input set and returns to the step of determining whether the first few digits of the receiving account address in the current row of transaction data match the specified character combination. If not, the thread reads the next row of transaction data from the input set and returns to the step of determining whether the first few digits of the receiving account address in the current row of transaction data match the specified character combination. The integration unit is used to integrate the transaction statistics results corresponding to each thread to obtain the final blockchain transaction statistics results.
Citation Information
Patent Citations
Method for parallelly processing transaction data
CN107423124A
Transaction packaging and transaction information query method and device and electronic equipment
CN112615894A
Block chain-based data processing method and device, equipment and readable storage medium
CN113821536A