A method and device for processing blockchain transaction records

By recording the latest value and block height of each account attribute in the status table of the blockchain system, and recording the modification records of attribute values ​​in the historical table corresponding to each block height, the problem of inefficient querying the latest changes in the account attribute value is solved, and fast query and efficient historical data management are realized.

CN111161064BActive Publication Date: 2025-06-17WEBANK (CHINA)
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201911277152.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-12-12
Publication Date
2025-06-17
Estimated Expiration
2039-12-12

AI Technical Summary

Technical Problem

In the existing blockchain system, when querying the block number with the latest change in account attribute value, transactions need to be reproduced, which is inefficient.

Method used

By recording the latest attribute values ​​and block heights of multiple attributes of each account in the status table, and recording the modification records of attribute values ​​in the historical table corresponding to each block height, it is possible to quickly query the historical changes of account attribute values.

Benefits of technology

It improves the efficiency of querying historical changes in account attribute values, reduces the amount of recorded data in historical tables, and improves the query speed of blockchain systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111161064B_ABST
    Figure CN111161064B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of financial technology (Fintech), and discloses a method and device for processing blockchain transaction records. The method includes: obtaining a to-be-executed transaction, where the to-be-executed transaction is used to change the attribute value of a first attribute of a first account; determining a first attribute value of the first attribute after executing the to-be-executed transaction; updating the first attribute value and the current block height to a state table, where the state table records status data of multiple accounts, and the status data of an account is the latest attribute value of each attribute among multiple attributes of the account and the block height corresponding to the latest attribute value. This technical solution is used to query the block where the attribute value of each attribute of an account last changed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of financial technology (Fintech), and in particular, to a method and apparatus for processing blockchain transaction records. Background Art

[0002] With the development of computer technology, more and more technologies are applied in the financial field, and traditional finance is gradually transforming into financial technology (Finteh). However, due to the security and real-time requirements of the financial industry, higher requirements are also put forward for technologies.

[0003] A state table is stored in the blockchain system. The state table is used to save the latest status data of each account and the block height corresponding to the latest status data. For example, when the blockchain system receives a transaction that causes a change in the status data of a certain account, the changed status data of the account and the current block height will be updated to the state table. When subsequent queries are needed, it can be directly queried from the state table which block the transaction that caused the change in the status data is on.

[0004] However, in the prior art, there are multiple attributes in the status data of an account, such as age, company where located, home address, account balance, etc. Each time a certain attribute value of the account changes, the status data and block height of the account will be updated. However, among these multiple attributes, the change frequency of the attribute values corresponding to some attributes is relatively low, such as age, while the change frequency of the attribute values corresponding to some attributes is relatively high, such as account balance. But when querying, for example, if the current state table records that the account balance of a certain account has changed due to the latest transaction, if you want to query which block the age attribute of this account was last changed on, it cannot be directly queried from the state table, and transactions need to be replayed to determine the block where the age attribute of this account was last changed. Summary of the Invention

[0005] Embodiments of the present invention provide a method and apparatus for processing blockchain transaction records to query the block where the attribute value of each attribute of an account was last changed.

[0006] A method for processing blockchain transaction records provided by embodiments of the present invention includes:

[0007] Obtain a to-be-executed transaction; the to-be-executed transaction is used to change the attribute value of a first attribute of a first account;

[0008] Determine a first attribute value of the first attribute after executing the to-be-executed transaction;

[0009] Update the first attribute value and the current block height to the status table; the status table records the status data of multiple accounts, and the status data of an account is the latest attribute value of each attribute among the multiple attributes of the account and the block height corresponding to the latest attribute value.

[0010] In the above technical solution, the status table is set to include the status data of multiple accounts. The status data of each account is the latest attribute value of each attribute among the multiple attributes of the account and the block height corresponding to the latest attribute value. In this way, the block height corresponding to the last modification of the attribute value of each attribute of the account can be determined.

[0011] Optionally, after updating the first attribute value and the current block height to the status table, it further includes:

[0012] Obtain the first historical table corresponding to the current block height; the first historical table records the modification records of multiple changed accounts at the current block height. The changed account is the account to which the attribute whose attribute value has changed belongs. The modification record of the changed account includes the attribute whose attribute value has changed at the current block height, the changed attribute value, and the index block height corresponding to the changed attribute value. The index block height is the block height corresponding to the latest change before the current change of the changed attribute value;

[0013] Take the first attribute, the first attribute value, and the index block height corresponding to the first attribute value as the first modification record of the first account and add it to the first historical table.

[0014] In the above technical solution, obtain the first historical table, and take the first attribute, the first attribute value, and the index block height corresponding to the first attribute value as the first modification record of the first account and add it to the first historical table. Among them, the first historical table does not record all data, but only records the modification records of the changed accounts at the current block height. That is, only the modification records of multiple changed accounts at the current block height are recorded. Moreover, among the multiple attributes corresponding to an account, if only the attribute value of one attribute changes and the attribute values of other attributes do not change, only the modification record of the attribute whose attribute value changes is recorded, and the record of the attribute whose attribute value does not change is not recorded, thereby further reducing the amount of recorded data in the historical table.

[0015] Optionally, the method further includes:

[0016] Receive a first query instruction; the first query instruction is used to obtain the attribute value of the second attribute of the second account at the specified block height;

[0017] If it is determined that the first block height corresponding to the latest attribute value of the second attribute in the state table is greater than the specified block height, starting from the first block height, determine the block heights corresponding to the changes in the attribute values of the second attribute of the second account in descending order until the second block height that is first less than the specified block height is determined;

[0018] Determine the attribute value of the second attribute of the second account in the historical table corresponding to the second block height as the query result.

[0019] Optionally, the method further includes:

[0020] If it is determined that the first block height is not greater than the specified block height, determine the latest attribute value of the second attribute in the state table as the query result.

[0021] Optionally, the method further includes:

[0022] Receive a second query instruction; the second query instruction is used to obtain the latest N modification records of the second attribute of the second account;

[0023] Starting from the first block height corresponding to the latest attribute value of the second attribute in the state table, determine the block heights corresponding to the changes in the attribute values of the second attribute of the second account in descending order and the modification records of the second account regarding the second attribute corresponding to each block height until N modification records are determined;

[0024] Determine the N modification records as the query result.

[0025] Optionally, the determining the block height corresponding to the change in the attribute value of the second attribute of the second account includes:

[0026] Obtain the historical table corresponding to the third block height according to the third block height corresponding to the attribute value of the second attribute of the second account at the Mth change;

[0027] Determine the second modification record of the second account from the historical table corresponding to the third block height; the second modification record includes the attribute value of the second attribute after the Mth change and the block height corresponding to the latest change before the Mth change of the attribute value of the second attribute.

[0028] In the above technical solution, a historical table corresponding to each block height can be set, and each historical table contains the attributes, attribute values, and index block heights corresponding to the changed accounts. The index block height is used to indicate the block height when the attribute value of the modification record where it is located was last modified. Then, the historical table corresponding to the block height when it was last modified can be determined, and the modification record when it was last modified can be determined from the historical table corresponding to the block height when it was last modified. Through this loop process, the modification record of a certain attribute can be quickly found. Since the modification records of the changed accounts in the historical table only include the information of the attributes whose attribute values have changed, the amount of recorded data in the historical table is further reduced. Moreover, when querying, it is also targeted at the change of a certain attribute. This method can improve the query speed.

[0029] Optionally, there are multiple state tables; the business types corresponding to each state table are different;

[0030] The modification records of the changed accounts in each state table corresponding to each block height are recorded in the historical table corresponding to the block height; the historical table includes the identifiers of each state table.

[0031] In the above technical solution, the provided historical table can correspond to the block height, so the historical table corresponding to each block height is not too large, and the historical table corresponds to the modification records of the changed accounts in multiple state tables, so that the number of historical tables in the entire blockchain system is not too large, further improving the query speed.

[0032] Correspondingly, an embodiment of the present invention further provides a device for processing blockchain transaction records, including:

[0033] An acquisition unit, configured to acquire a to-be-executed transaction; the to-be-executed transaction is used to change the attribute value of the first attribute of the first account;

[0034] A processing unit, configured to determine the first attribute value of the first attribute after executing the to-be-executed transaction; update the first attribute value and the current block height to the state table; the state table records the state data of multiple accounts, and the state data of the account is the latest attribute value of each attribute in the multiple attributes of the account and the block height corresponding to the latest attribute value.

[0035] Optionally, the obtaining unit is further configured to obtain a first history table corresponding to the current block height after the processing unit updates the first attribute value and the current block height to the status table; the first history table records modification records of multiple changed accounts at the current block height, the changed account is the account to which the attribute whose attribute value has changed belongs, and the modification record of the changed account includes the attribute whose attribute value has changed at the current block height, the attribute value after the change, and the index block height corresponding to the attribute value after the change, and the index block height is the block height corresponding to the latest change before the change of the attribute value after the change;

[0036] The processing unit is further configured to add the first attribute, the first attribute value, and the index block height corresponding to the first attribute value as the first modification record of the first account to the first history table.

[0037] Optionally, the processing unit is further configured to:

[0038] Receive a first query instruction; the first query instruction is used to obtain the attribute value of a second attribute of a second account at a specified block height;

[0039] If it is determined that the first block height corresponding to the latest attribute value of the second attribute in the status table is greater than the specified block height, starting from the first block height, sequentially determine the block heights corresponding to the change of the attribute value of the second attribute of the second account from high to low until the first second block height less than the specified block height is determined;

[0040] Determine the attribute value of the second attribute of the second account in the history table corresponding to the second block height as the query result.

[0041] Optionally, the processing unit is further configured to:

[0042] If it is determined that the first block height is not greater than the specified block height, determine the latest attribute value of the second attribute in the status table as the query result.

[0043] Optionally, the processing unit is further configured to:

[0044] Receive a second query instruction; the second query instruction is used to obtain the latest N modification records of a second attribute of a second account;

[0045] Starting from the first block height corresponding to the latest attribute value of the second attribute in the status table, sequentially determine the block heights corresponding to the change of the attribute value of the second attribute of the second account and the modification records of the second account regarding the second attribute corresponding to each block height from high to low until N modification records are determined;

[0046] Determine the N modification records as the query result.

[0047] Optionally, the processing unit is specifically configured to:

[0048] Obtain the historical table corresponding to the third block height when the attribute value of the second attribute of the second account changes for the Mth time according to the attribute value of the second attribute of the second account;

[0049] Determine the second modification record of the second account from the historical table corresponding to the third block height; the second modification record includes the attribute value of the second attribute after the Mth change and the block height corresponding to the latest change before the Mth change of the attribute value of the second attribute.

[0050] Optionally, there are multiple status tables; each status table corresponds to a different business type;

[0051] The historical table corresponding to each block height records the modification records of the changed accounts in each status table under the block height; the historical table includes the identifier of each status table.

[0052] Correspondingly, an embodiment of the present invention further provides a computing device, including:

[0053] A memory for storing program instructions;

[0054] A processor for calling the program instructions stored in the memory and executing the above-mentioned processing method of blockchain transaction records according to the obtained program.

[0055] Correspondingly, an embodiment of the present invention further provides a computer-readable non-volatile storage medium, including computer-readable instructions, when the computer reads and executes the computer-readable instructions, the computer is caused to execute the above-mentioned processing method of blockchain transaction records. Description of the Drawings

[0056] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained according to these drawings.

[0057] Figure 1 It is a schematic flowchart of a process for updating a status table provided by an embodiment of the present invention;

[0058] Figure 2 It is a schematic flowchart of a process for updating a historical table provided by an embodiment of the present invention;

[0059] Figure 3Schematic flowchart of a process for querying the attribute value of a specific block height provided by an embodiment of the present invention;

[0060] Figure 4 Schematic flowchart of a process for querying the modification record of a certain attribute provided by an embodiment of the present invention;

[0061] Figure 5 Schematic structural diagram of a processing device for blockchain transaction records provided by an embodiment of the present invention. Detailed implementation manners

[0062] In order to make the objectives, technical solutions and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without making creative efforts shall fall within the scope of protection of the present invention.

[0063] The blockchain transaction record processing method provided by the embodiments of the present invention is applicable to a blockchain system. The blockchain system is a P2P (Peer to Peer) network composed of multiple blockchain nodes, and the blockchain nodes can communicate directly with each other. The data generated by one blockchain node can be broadcast to multiple blockchain nodes at the same time, or data can be queried and obtained from any other node.

[0064] There is a state table in the blockchain system. The state table is created by a smart contract of the same business type. That is, there can be multiple state tables in the blockchain system, and each state table corresponds to a different business type.

[0065] For a state table, the state table records the state data of multiple accounts. Among them, the state data of any account is the latest attribute value of each attribute among the multiple attributes of the account and the block height corresponding to the latest attribute value. The index Key of the state table is SHA256(table name + "_" + primary key) to ensure global uniqueness. Each attribute corresponds to a block height, which is used to record the block height when the attribute value corresponding to the attribute was last modified.

[0066] For example, the name of the status table is "t_Balance". The status table includes accounts Alice, Bob, and Henry. The attributes of each account are Balance (account balance) and Age (age). The status table can be as shown in Table 1. Taking Alice as an example, the index key of the status table is SHA256("t_Balance_Alice"). The latest value of the Balance corresponding to Alice is 100, and the block height at the time of the last modification is 2. The latest value of the Age corresponding to Alice is 37, and the block height at the time of the last modification is 2.

[0067] Table 1

[0068]

[0069] Through the status table provided by the embodiments of the present invention, the block height corresponding to the time of the last modification of the latest attribute value of each attribute of the account can be determined.

[0070] Figure 1 Exemplarily, the flow of a method for processing blockchain transaction records provided by the embodiments of the present invention is shown. This flow can be executed by a processing device for blockchain transaction records.

[0071] As Figure 1 shown, the flow specifically includes:

[0072] Step 101, obtain a transaction to be executed;

[0073] Step 102, determine the first attribute value of the first attribute after executing the transaction to be executed;

[0074] Step 103, update the first attribute value and the current block height to the status table.

[0075] In an embodiment of the present invention, a to-be-executed transaction is used to change the attribute value of a first attribute of a first account. After executing the to-be-executed transaction, the attribute value of the first attribute becomes the first attribute value. Taking Table 1 as an example, when the current block height is 25 and a to-be-executed transaction of "Alice's Balance increases by 400 and Alice's Age increases by 1" is obtained, then Alice is the first account, and both Balance and Age are the first attributes. After executing this transaction, Alice's Balance will become 500, so 500 is the first attribute value. Similarly, Alice's Age will become 38, and 38 is also the first attribute value. When updating 500, 38, and the current block height to the state table respectively, the Balance_Blocknum corresponding to the Alice primary key in the original Table 1 becomes 25, and the Balance corresponding to the Alice primary key becomes 500; the Age–Blocknum corresponding to the Alice primary key becomes 25, and the Age corresponding to the Alice primary key becomes 38. The updated Table 1 can be shown as Table 2.

[0076] Table 2

[0077]

[0078] In an embodiment of the present invention, to enable querying the historical attribute values of each attribute of each account, for example, querying the attribute value of a certain attribute of a certain account at a specific block height, a historical table can also be set up to record the modification records of the attributes of the account.

[0079] In one implementation, it can be determined whether to generate the historical table corresponding to a certain state table when creating the state table. Specifically, when executing the creation of the state table, the creation instruction passed in includes whether to generate the historical table. Among them, for those who do not pay attention to historical data, the historical table can not be generated to reduce storage overhead. In the blockchain database, a creation record of the state table can be recorded to indicate whether the historical table corresponding to the state table has been created. This creation record can also be stored in the form of a table. As shown in Table 3, it can include the table name of the state table and whether to generate the historical table.

[0080] Table 3

[0081] Table name of the status table Whether to generate a historical modification record table t_Balance True t_Member True t_Order False

[0082] In another implementation, when creating a certain state table, it is determined whether to write the modification records corresponding to the state table into the history table. That is to say, the history table here is pre-created, and the modification records corresponding to multiple state tables will be written into this history table. Specifically, when executing the creation of the state table, the creation instruction passed in includes whether to write the modification records into the history table. Among them, for those who do not care about historical data, the modification records can not be written into the history table to reduce storage overhead. In the blockchain database, a creation record of the state table can be recorded to indicate whether to write the modification records of the state table into the history table. This creation record can also be stored in the form of a table. As shown in Table 4, it can include the table name of the state table and whether to write the modification records into the history table.

[0083] Table 4

[0084] Table name of the status table Whether to write the modification record into the historical table t_Balance True t_Member True t_Order False

[0085] In the embodiments of the present invention, it can be set that each block height corresponds to a history table, and the table name of the history table can be identified according to the block height, such as "t_history_block height". The full amount of data is not recorded in the history table corresponding to each block height, but only the modification records of the changed accounts corresponding to the block height are recorded. As shown below, the structures of each history table are the same, so as to establish a chained data relationship of multiple history tables.

[0086] Block height 1 → t_history_1

[0087] Block height 2 → t_history_2

[0088] Block height 3 → t_history_3

[0089] In the embodiments of the present invention, since there can be multiple state tables and the business types corresponding to each state table are different, when writing the modification records of the changed accounts of each state table into the same history table, it can be distinguished according to the identifier of the state table. The history table includes the identifier of each state table, such as the table name of each state table. The history table corresponding to each block height records the modification records of the changed accounts in each state table under the block height.

[0090] The history table records the modification records of multiple changed accounts corresponding to the block height. Among them, the changed account is understood as the account to which the attribute whose attribute value has changed under the block height belongs. The modification record of the changed account includes the attribute whose attribute value has changed under the block height, the changed attribute value, and the index block height corresponding to the changed attribute value. The index block height is the block height corresponding to the latest change before the changed attribute value in this change.

[0091] The fields that can be included in the history table are the primary key of the status table, attributes, attribute values, and the index block height of the attribute values. When multiple status tables correspond to one history table, the fields of the history table also include the identifier of the corresponding status table, such as the table name of the status table. Correspondingly, the index key of the history table is SHA256(table name of the status table + "_" + primary key of the status table + "_" + attribute).

[0092] For example, the table name of the history table is "t_history_10", which is the history table corresponding to block height 10. This history table can be as shown in Table 5. This history table includes accounts Bob and Henry. Taking Bob as an example, the index key of the history table is SHA256("t_Balance_Bob_Balance"). The value of Bob's Balance in the status table t_Balance at block height 10 is 200, and the last change occurred at block height 8.

[0093] Table 5

[0094]

[0095] Based on the above description, after the first attribute value and the current block height are updated to the status table in an embodiment of the present invention, the corresponding modification record can also be updated to the corresponding history table. In a specific implementation, it can be as shown in Figure 2 the flowchart shown.

[0096] Step 201, obtain the first history table corresponding to the current block height;

[0097] Step 202, add the first attribute, the first attribute value, and the index block height corresponding to the first attribute value as the first modification record of the first account to the first history table.

[0098] Here, the first history table is the history table corresponding to the current block height. The first history table records the modification records of multiple changed accounts at the current block height. A changed account is the account to which the attribute whose attribute value has changed belongs. The modification record of the changed account includes the attribute whose attribute value has changed at the current block height of the changed account, the attribute value after the change, and the index block height corresponding to the attribute value after the change. The index block height is the block height corresponding to the attribute value after the change at the time of the last change.

[0099] Continuing with the above example of a transaction that "increases Alice's Balance by 400 and increases Alice's Age by 1", after the above transaction is executed, not only will the Balance–Blocknum corresponding to Alice's primary key in the status table, the Balance corresponding to Alice's primary key, the Age–Blocknum corresponding to Alice's primary key, and the Age corresponding to Alice's primary key be updated, but also two modification records will be added to the history table at block height 25, namely, "the value of Alice's Balance in the status table t_Balance at block height 25 is 500, and the last modification was at block height 2", and "the value of Alice's Age in the status table t_Balance at block height 25 is 38, and the last modification was at block height 2". The two new modification records added to the history table t_history_25 can be shown in Table 6.

[0100] Table 6

[0101]

[0102] In the embodiments of the present invention, if the status data of a new account is added, it is equivalent to adding a piece of data to the status table. For example, when the current block height is 70, adding the status data of Adam to the status table t_Balance will update the status table t_Balance in Table 2 as shown in Table 7. At the same time, two new modification records will be added to the history table t_history_70. The two new modification records added can be shown in Table 8. Among them, prevblocknum being -1 indicates that the status data of the account corresponding to this modification record is newly added.

[0103] Table 7

[0104]

[0105] Table 8

[0106]

[0107] In the above embodiments, the first historical table is obtained, and the first attribute, the first attribute value, and the index block height corresponding to the first attribute value are used as the first modification record of the first account and added to the first historical table. Among them, the first historical table does not record all data, but only records the modification records of the changed accounts under the current block height. That is, only the modification records of multiple changed accounts under the current block height are recorded. Moreover, if only one of the multiple attributes corresponding to an account has a changed attribute value and the attribute values of other attributes do not change, only the modification record of the attribute with the changed attribute value is recorded, and the record of the attribute with the unchanged attribute value is not recorded, thereby further reducing the amount of data recorded in the historical table.

[0108] In one implementation manner, it is possible to support querying the attribute value of a certain attribute of an account at a specified block height.

[0109] Such as Figure 3 illustrates an exemplary query method for the attribute value of a specific block height provided by the embodiments of the present invention. The specific process includes:

[0110] Step 301, receive a first query instruction;

[0111] Step 302, if it is determined that the first block height corresponding to the latest attribute value of the second attribute in the status table is greater than the specified block height, starting from the first block height, sequentially determine the block heights corresponding to the changes in the attribute value of the second attribute of the second account from high to low until the second block height is determined;

[0112] Step 303, determine the attribute value of the second attribute of the second account in the historical table corresponding to the second block height as the query result.

[0113] In the embodiments of the present invention, the first query instruction is used to obtain the attribute value of the second attribute of the second account at the specified block height. After receiving the first query instruction, first determine the first block height corresponding to the latest attribute value of the second attribute from the status table. Here, the first block height is the block height corresponding to the latest attribute value of the second attribute, that is, the block height where the attribute value of the second attribute is located at the latest modification. If the first block height is greater than the specified block height, starting from the first block height, sequentially determine the block heights corresponding to each change in the attribute value of the second attribute of the second account from high to low until the first block height less than the specified block height is determined, and determine the attribute value of the second attribute of the second account in the historical table corresponding to this block height as the query result.

[0114] In addition, after determining the first block height corresponding to the latest attribute value of the second attribute from the status table, if it is determined that the first block height is not greater than the specified block height, it can be determined that the value after the latest change in the attribute value of the second attribute of the second account before the specified block height is the latest attribute value of the second attribute, and thus the latest attribute value of the second attribute can be used as the query result.

[0115] In an embodiment of the present invention, when determining the block height corresponding to each change in the attribute value of the second attribute of the second account, it may be to obtain the historical table corresponding to the third block height according to the third block height corresponding to the attribute value of the second attribute of the second account at the Mth change; then determine the second modification record of the second account from the historical table corresponding to the third block height; wherein, the second modification record includes the attribute value of the second attribute after the Mth change and the block height corresponding to the latest change before the Mth change of the attribute value of the second attribute (equivalent to the index block height of the attribute value of the second attribute after the Mth change). That is to say, when determining the block height corresponding to each change in the attribute value of the second attribute of the second account, it may be to obtain the historical table corresponding to the block height at the current change according to the block height corresponding to the attribute value of the second attribute of the second account at the current change, and then determine the modification record of the block height corresponding to the current change from the historical table corresponding to the block height at the current change, so as to determine the block height corresponding to the previous change from the modification record. In this way, the block heights corresponding to each change in the attribute value of the second attribute of the second account are determined in descending order.

[0116] To better illustrate the embodiments of the present invention, only take the account Alice as an example. For example, the first query instruction received is "query the Age of Alice at block height 520". Assume that the current block height is 10,000. Then the obtained status table t_Balance is shown in Table 9. After reading the status table t_Balance, it is determined that the block height of the latest attribute value corresponding to Age is 800, which is greater than 520. Then the historical table corresponding to block height 800 will be obtained. The table name of the historical table is t_history_800. Assume that the historical table corresponding to block height 800 is shown in Table 10. Then it can be determined that Alice's Age was updated at block height 500, and block height 500 is less than block height 520. Then it is determined that the value of Age after the update at block height 500 is the value to be queried. Then the historical table corresponding to block height 500 is obtained. The table name of the historical table is t_history_500. Assume that the historical table corresponding to block height 500 is shown in Table 11. Then it can be determined that the value of Alice's Age at block height 500 is 39, that is, the value to be queried is 39.

[0117] Table 9

[0118]

[0119] Table 10

[0120]

[0121] Table 11

[0122]

[0123] In the above example, assuming that the historical table corresponding to block height 800 is shown in Table 12, it can be determined that Alice's Age was updated at block height 530, and block height 530 is greater than block height 520. Then, obtain the historical table corresponding to block height 530. The table name of the historical table is t_history_530. Assuming that the historical table corresponding to block height 530 is shown in Table 13, it can be determined that Alice's Age was updated at block height 25, and block height 25 is not greater than block height 520. Then, determine that the value of Age after the update at block height 25 is the value to be queried. Then, obtain the historical table corresponding to block height 25. The table name of the historical table is t_history_25. Assuming that the historical table corresponding to block height 25 is shown in Table 14, it can be determined that the value of Alice's Age at block height 25 is 38, that is, the value to be queried is 38.

[0124] Table 12

[0125]

[0126] Table 13

[0127]

[0128] Table 14

[0129]

[0130] In the above example, assuming that the obtained status table t_Balance is shown in Table 15, after reading the status table t_Balance, it is determined that the block height corresponding to the latest attribute value of Age is 500, which is not greater than 520. Then, it can be determined that the value of Age corresponding to block height 500, which is 40, is the data to be queried.

[0131] Table 15

[0132]

[0133] In another implementation manner, it is also possible to support querying the recent modification records of a certain attribute of an account. For example Figure 4 exemplarily shows a method for querying multiple modification records of a certain attribute provided by an embodiment of the present invention. The specific process includes:

[0134] Step 401, receive a second query instruction;

[0135] Step 402: Starting from the first block height corresponding to the latest attribute value of the second attribute in the status table, determine, in descending order, the block heights corresponding to the changes in the attribute value of the second attribute of the second account and the modification records of the second account regarding the second attribute corresponding to each block height until N modification records are determined.

[0136] Step 403: Determine the N modification records as the query result.

[0137] In the embodiment of the present invention, the second query instruction is used to obtain the latest N modification records of the second attribute of the second account. After receiving the second query instruction, first determine the first block height corresponding to the latest attribute value of the second attribute from the status table. Here, the first block height is the block height corresponding to the latest attribute value of the second attribute, that is, the block height where the attribute value of the second attribute is located during the latest modification. Starting from the first block height, determine, in descending order, the block heights corresponding to each change in the attribute value of the second attribute of the second account. And each time the block height corresponding to the change in the attribute value of the second attribute of the second account is determined, obtain the historical table corresponding to this block height at the same time to obtain the modification record corresponding to this change from it until N modification records are determined, and determine the N modification records as the query result.

[0138] In the embodiment of the present invention, when determining the block height corresponding to each change in the attribute value of the second attribute of the second account, it may be to obtain the historical table corresponding to the third block height according to the third block height corresponding to the change in the attribute value of the second attribute of the second account at the Mth change; then determine the second modification record of the second account from the historical table corresponding to the third block height; where the second modification record includes the attribute value of the second attribute after the Mth change and the block height corresponding to the latest change before the Mth change of the attribute value of the second attribute (equivalent to the index block height of the attribute value of the second attribute after the Mth change). That is to say, when determining the block height corresponding to each change in the attribute value of the second attribute of the second account, it may be to obtain the historical table corresponding to the block height corresponding to the current change according to the block height corresponding to the change in the attribute value of the second attribute of the second account at the current change, and then determine the modification record corresponding to the block height corresponding to the current change from the historical table corresponding to the block height corresponding to the current change to determine the block height corresponding to the previous change from the modification record. In this way, the block heights corresponding to each change in the attribute value of the second attribute of the second account are determined in descending order.

[0139] For example, the received second query instruction is "query the last three modification records of Alice's Age". Assume that the obtained status table t_Balance is as shown in Table 9. After reading the status table t_Balance, it is determined that the latest attribute value corresponding to Age is 40, and the block height corresponding to the latest attribute value 40 is 800. Then, the historical table corresponding to block height 800 will be obtained. The table name of this historical table is t_history_800. Assume that the historical table corresponding to block height 800 is as shown in Table 10. Then, the modification record of Alice's Age at block height 800 can be determined. This modification record is the most recent modification record at present. Furthermore, according to the index block height 500 in this modification record, the historical table corresponding to block height 500 is obtained. The table name of this historical table is t_history_500. Assume that the historical table corresponding to block height 500 is as shown in Table 11. Then, the modification record of Alice's Age at block height 500 can be determined. This modification record is the second most recent modification record at present. Furthermore, according to the index block height 25 in this modification record, the historical table corresponding to block height 25 is obtained. The table name of this historical table is t_history_25. Assume that the historical table corresponding to block height 25 is as shown in Table 14. Then, the modification record of Alice's Age at block height 25 can be determined. This modification record is the third most recent modification record at present. Thus, the last three modification records of Alice's Age are obtained, which are respectively in the historical tables corresponding to block height 800, block height 500, and block height 25. Moreover, it can be obtained that the last three changes of Alice's Age are 38 → 39 → 40.

[0140] In the above embodiment, by setting the historical tables corresponding to each block height, and each historical table contains the attributes, attribute values, and index block heights of the changed accounts. The index block height is used to indicate the block height when the attribute value of the current modification record was last modified. Then, the historical table corresponding to the block height when it was last modified is determined, and the modification record when it was last modified is determined from the historical table corresponding to the block height when it was last modified. Through this loop process, the modification record of a certain attribute can be quickly found. Since the modification records of the changed accounts in the historical table only include the information of the attributes whose attribute values have changed, the amount of recorded data in the historical table is further reduced. Moreover, when querying, it is also targeted at the change of a certain attribute. This method can improve the query speed. The historical table provided in the embodiment of the present invention can correspond to the block height, so the historical table corresponding to each block height will not be too large, further improving the query speed.

[0141] Based on the same inventive concept, Figure 5 Exemplarily, the structure of a processing device for blockchain transaction records provided in an embodiment of the present invention is shown. This device can execute the process of the method for processing blockchain transaction records.

[0142] The device includes:

[0143] An acquisition unit 501, configured to acquire a to-be-executed transaction; the to-be-executed transaction is used to change the attribute value of a first attribute of a first account.

[0144] A processing unit 502, configured to determine a first attribute value of the first attribute after executing the to-be-executed transaction; update the first attribute value and the current block height to a status table; the status table records status data of multiple accounts, and the status data of an account is the latest attribute value of each attribute among multiple attributes of the account and the block height corresponding to the latest attribute value.

[0145] Optionally, the acquisition unit 501 is further configured to, after the processing unit 502 updates the first attribute value and the current block height to the status table, acquire a first historical table corresponding to the current block height; the first historical table records modification records of multiple changed accounts under the current block height, the changed account is the account to which the attribute whose attribute value has changed belongs, and the modification record of the changed account includes the attribute whose attribute value has changed under the current block height of the changed account, the attribute value after the change, and the index block height corresponding to the attribute value after the change, and the index block height is the block height corresponding to the latest change before the change of the attribute value after the change.

[0146] The processing unit 502 is further configured to add the first attribute, the first attribute value, and the index block height corresponding to the first attribute value as a first modification record of the first account to the first historical table.

[0147] Optionally, the processing unit 502 is further configured to:

[0148] Receive a first query instruction; the first query instruction is used to acquire the attribute value of a second attribute of a second account at a specified block height.

[0149] If it is determined that a first block height corresponding to the latest attribute value of the second attribute in the status table is greater than the specified block height, starting from the first block height, sequentially determine the block heights corresponding to the change of the attribute value of the second attribute of the second account from high to low until a second block height that is less than the specified block height is determined.

[0150] Determine the attribute value of the second attribute of the second account in the historical table corresponding to the second block height as the query result.

[0151] Optionally, the processing unit 502 is further configured to:

[0152] If it is determined that the first block height is not greater than the specified block height, determine the latest attribute value of the second attribute in the status table as the query result.

[0153] Optionally, the processing unit 502 is further configured to:

[0154] Receive a second query instruction; the second query instruction is used to obtain the latest N modification records of the second attribute of the second account;

[0155] Starting from the first block height corresponding to the latest attribute value of the second attribute in the status table, determine the block heights corresponding to the changes in the attribute values of the second attribute of the second account and the modification records of the second account regarding the second attribute corresponding to each block height in descending order until N modification records are determined;

[0156] Determine the N modification records as the query result.

[0157] Optionally, the processing unit 502 is specifically configured to:

[0158] Obtain the historical table corresponding to the third block height corresponding to the change in the attribute value of the second attribute of the second account at the Mth change;

[0159] Determine the second modification record of the second account from the historical table corresponding to the third block height; the second modification record includes the attribute value of the second attribute after the Mth change and the block height corresponding to the latest change before the Mth change of the attribute value of the second attribute.

[0160] Optionally, there are multiple status tables; different status tables correspond to different service types;

[0161] The historical table corresponding to each block height records the modification records of the changed accounts in each status table under the block height; the historical table includes the identifiers of each status table.

[0162] Based on the same inventive concept, an embodiment of the present invention further provides a computing device, including:

[0163] A memory for storing program instructions;

[0164] A processor for calling the program instructions stored in the memory and executing the above-mentioned method for processing blockchain transaction records according to the obtained program.

[0165] Based on the same inventive concept, an embodiment of the present invention further provides a computer-readable non-volatile storage medium, including computer-readable instructions, which when read and executed by a computer, cause the computer to execute the above-mentioned method for processing blockchain transaction records.

[0166] The present invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It should be understood that each flow and / or block in the flowchart illustrations and / or block diagrams, and combinations of flows and / or blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions executed by the processor of the computer or other programmable data processing apparatus create means for implementing the functions specified in the flow Figure 1 one or more flows and / or blocks Figure 1 or means for implementing the functions specified in one or more boxes or blocks.

[0167] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means that implement the functions specified in the flow Figure 1 one or more flows and / or blocks Figure 1 or means for implementing the functions specified in one or more boxes or blocks.

[0168] These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, such that the instructions executed on the computer or other programmable apparatus provide steps for implementing the functions specified in the flow Figure 1 one or more flows and / or blocks Figure 1 or means for implementing the functions specified in one or more boxes or blocks.

[0169] Although the preferred embodiments of the present invention have been described, additional changes and modifications can be made by those skilled in the art once they learn of the basic inventive concept. Therefore, the appended claims are intended to be construed to include the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0170] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention is also intended to include these modifications and variations.

Claims

1. A method for processing blockchain transaction records, characterized in that, Including: Obtain a to-be-executed transaction; the to-be-executed transaction is used to change the attribute value of a first attribute of a first account; Determine the first attribute value of the first attribute after executing the to-be-executed transaction; Update the first attribute value and the current block height to a status table; the status table records status data of multiple accounts, and the status data of an account is the latest attribute value of each attribute among multiple attributes of the account and the block height corresponding to the latest attribute value; Obtain a first historical table corresponding to the current block height; The first historical table records modification records of multiple changed accounts at the current block height, the changed account is the account to which the attribute whose attribute value has changed belongs, and the modification record of the changed account includes the attribute whose attribute value has changed at the current block height of the changed account, the changed attribute value, and the index block height corresponding to the changed attribute value, and the index block height is the block height corresponding to the latest change before the changed attribute value in this change; Add the first attribute, the first attribute value, and the index block height corresponding to the first attribute value as the first modification record of the first account to the first historical table.

2. The method according to claim 1, characterized in that, The method further includes: Receive a first query instruction; the first query instruction is used to obtain the attribute value of a second attribute of a second account at a specified block height; If it is determined that the first block height corresponding to the latest attribute value of the second attribute in the status table is greater than the specified block height, starting from the first block height, sequentially determine the block heights corresponding to the change of the attribute value of the second attribute of the second account from high to low until the first second block height less than the specified block height is determined; Determine the attribute value of the second attribute of the second account in the historical table corresponding to the second block height as the query result.

3. The method according to claim 2, characterized in that, The method further includes: If it is determined that the first block height is not greater than the specified block height, determine the latest attribute value of the second attribute in the status table as the query result.

4. The method according to claim 1, characterized in that, The method further includes: Receive a second query instruction; the second query instruction is used to obtain the latest N modification records of a second attribute of a second account; Starting from the first block height corresponding to the latest attribute value of the second attribute in the status table, sequentially determine the block heights corresponding to the change of the attribute value of the second attribute of the second account and the modification records of the second account regarding the second attribute corresponding to each block height from high to low until N modification records are determined; Determine the N modification records as the query result.

5. The method according to any one of claims 2 to 4, characterized in that, The determining the block height corresponding to the change of the attribute value of the second attribute of the second account includes: According to the third block height corresponding to the attribute value of the second attribute of the second account at the Mth change, obtain the historical table corresponding to the third block height; Determine the second modification record of the second account from the historical table corresponding to the third block height; the second modification record includes the attribute value of the second attribute after the Mth change and the block height corresponding to the latest change before the Mth change of the attribute value of the second attribute.

6. The method according to claim 1, characterized in that, There are multiple status tables; each status table corresponds to a different business type; In the historical table corresponding to each block height, modification records of the changed accounts in each status table under the block height are recorded; the historical table includes the identifiers of each status table.

7. A device for processing blockchain transaction records, characterized in that, It includes: An acquisition unit for acquiring a to-be-executed transaction; the to-be-executed transaction is used to change the attribute value of the first attribute of the first account. A processing unit for determining the first attribute value of the first attribute after executing the to-be-executed transaction; updating the first attribute value and the current block height to the status table; the status table records the status data of multiple accounts, and the status data of an account is the latest attribute value of each attribute among the multiple attributes of the account and the block height corresponding to the latest attribute value. The acquisition unit is further configured to, after the processing unit updates the first attribute value and the current block height to the status table, acquire a first historical table corresponding to the current block height; the first historical table records the modification records of multiple changed accounts under the current block height, the changed account is the account to which the attribute whose attribute value has changed belongs, and the modification record of the changed account includes the attribute whose attribute value has changed under the current block height, the attribute value after the change, and the index block height corresponding to the attribute value after the change, and the index block height is the block height corresponding to the latest change before the current change of the attribute value after the change. The processing unit is further configured to add the first attribute, the first attribute value, and the index block height corresponding to the first attribute value as the first modification record of the first account to the first historical table.

8. The device according to claim 7, characterized in that, The processing unit is further configured to: Receive a first query instruction; the first query instruction is used to acquire the attribute value of the second attribute of the second account at a specified block height. If it is determined that the first block height corresponding to the latest attribute value of the second attribute in the status table is greater than the specified block height, starting from the first block height, sequentially determine the block heights corresponding to the change of the attribute value of the second attribute of the second account from high to low until the second block height that is first less than the specified block height is determined. Determine the attribute value of the second attribute of the second account in the historical table corresponding to the second block height as the query result.

9. The device according to claim 8, characterized in that, The processing unit is further configured to: If it is determined that the first block height is not greater than the specified block height, determine the latest attribute value of the second attribute in the status table as the query result.

10. The device according to claim 7, wherein, The processing unit is further configured to: Receive a second query instruction; the second query instruction is used to acquire the latest N modification records of the second attribute of the second account. Starting from the first block height corresponding to the latest attribute value of the second attribute in the status table, sequentially determine the block heights corresponding to the change of the attribute value of the second attribute of the second account and the modification records of the second account regarding the second attribute corresponding to each block height from high to low until N modification records are determined. Determine the N modification records as the query result.

11. The device according to any one of claims 8 to 10, wherein, The processing unit specifically is configured to: Acquire the historical table corresponding to the third block height according to the third block height corresponding to the change of the attribute value of the second attribute of the second account at the Mth change. Determine the second modification record of the second account from the historical table corresponding to the height of the third block; the second modification record includes the attribute value of the second attribute after the Mth change and the block height corresponding to the latest change of the attribute value of the second attribute before the Mth change.

12. The device according to claim 7, wherein, There are multiple state tables; the business types corresponding to each state table are different; The historical table corresponding to each block height records the modification records of the changed accounts in each state table under the block height; the historical table includes the identifier of each state table.

13. A computing device, wherein, Comprising: A memory for storing program instructions; A processor for calling the program instructions stored in the memory and executing the method according to any one of claims 1 to 6 according to the obtained program.

14. A computer-readable non-volatile storage medium, wherein, Including computer-readable instructions, when a computer reads and executes the computer-readable instructions, the computer is caused to execute the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Block chain transaction record processing method and device

    CN110471923A