Transaction data updating method, storage medium and system based on block chain world state
1. A method for updating transaction data based on a blockchain world state, the blockchain having a plurality of nodes assembled into a network, the method comprising the steps of:
A. acquiring transaction information in the block;
B. analyzing at least two related nodes related to the transaction according to the transaction information in the block;
C. searching adjacent nodes corresponding to the relevant nodes respectively;
D. acquiring the number of adjacent nodes corresponding to each phase joint and address information of each adjacent node;
E. for each relevant node, the following steps E1, E2, E3 and E4 are performed:
E1. updating the data in the relevant node according to the transaction information in the block to obtain transaction data related to the transaction process;
E2. dividing the transaction data into a plurality of data segments according to the number of adjacent nodes corresponding to the corresponding joint points;
E3. transmitting each data segment to each adjacent node corresponding to the corresponding joint point;
E4. and transmitting the address information of each adjacent node corresponding to the relevant node to other relevant nodes related to the transaction, so that the other relevant nodes can respectively acquire the data section of the transaction data from each corresponding adjacent node according to the address information to update the data after the transaction in the block is finished.
2. The transaction data updating method of claim 1, wherein the intra-block transaction information includes transaction request information, transaction object information, transaction content information, and transaction time information.
3. The transaction data updating method according to claim 1 or 2, wherein the transaction data includes a transaction object, transaction contents, and transaction time.
4. The transaction data updating method according to claim 1, wherein: in the step E3, after each data segment is transmitted to each adjacent node corresponding to the corresponding node, the data segment in each adjacent node is encrypted by using the encryption key; in said step E4, a decryption key, which is inter-keyed to said encryption key, is also transmitted to other related nodes involved in the transaction.
5. The transaction data updating method according to claim 4, wherein: in step E3, the encryption key and the decryption key of the inter-key pair are generated by using an asymmetric encryption algorithm.
6. The transaction data updating method of claim 1, wherein in the step E2, the transaction data is divided into a plurality of data segments, wherein each data segment contains the same amount of data.
7. Computer-readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, carries out a transaction data updating method according to any one of claims 1 to 6.
8. A system for updating transaction data based on blockchain world state comprising a computer readable storage medium and a processor connected to each other, said blockchain having a plurality of nodes organized into a network, wherein the computer readable storage medium is as defined in claim 7.
Background
The block chain is built into a network in a node mode, all nodes execute block transactions which are commonly identified by all nodes in sequence from the same initial state, so that the states of all nodes are driven to change continuously according to the same operation sequence (addition, deletion and modification), the states of all nodes are completely consistent after the same block transactions are executed, and the state is called a world state.
A KV database (Key-Value database) is integrated in each node of the blockchain, and is used for storing various information, such as account balance, intelligent contract byte codes, data defined by each intelligent contract, configuration parameters of the blockchain, and the like. After the block chain executes the agreed-upon intra-block transaction, each node related to the transaction transmits the transaction data to other nodes related to the transaction for data updating, so that each node related to the transaction is in a consistent world state. However, if a plurality of nodes in a block chain execute a plurality of intra-block transactions respectively in a short time, the intra-block transactions are too frequent, which may cause an excessive data transmission pressure of the block chain network and an excessive data storage pressure of the nodes, and thus, it is difficult for the plurality of nodes involved in the transactions to be in a consistent world state.
Disclosure of Invention
The technical problem to be solved by the invention is how to reduce the data transmission pressure of a block chain network and the data storage pressure of nodes under the condition of frequent transactions in a block.
In order to solve the above technical problem, the present invention provides a transaction data updating method based on a block chain world state, where the block chain has a plurality of nodes that form a network, and the method includes the following steps:
A. acquiring transaction information in the block;
B. analyzing at least two related nodes related to the transaction according to the transaction information in the block;
C. searching adjacent nodes corresponding to the relevant nodes respectively;
D. acquiring the number of adjacent nodes corresponding to each phase joint and address information of each adjacent node;
E. for each relevant node, the following steps E1, E2, E3 and E4 are performed:
E1. updating the data in the relevant node according to the transaction information in the block to obtain transaction data related to the transaction process;
E2. dividing the transaction data into a plurality of data segments according to the number of adjacent nodes corresponding to the corresponding joint points;
E3. transmitting each data segment to each adjacent node corresponding to the corresponding joint point;
E4. and transmitting the address information of each adjacent node corresponding to the relevant node to other relevant nodes related to the transaction, so that the other relevant nodes can respectively acquire the data section of the transaction data from each corresponding adjacent node according to the address information to update the data after the transaction in the block is finished.
Preferably, the intra-block transaction information includes transaction request information, transaction object information, transaction content information, and transaction time information.
Preferably, the transaction data includes a transaction object, transaction content and transaction time.
Preferably, in the step E3, after each data segment is transmitted to each neighboring node corresponding to the corresponding node, the data segment in each neighboring node is encrypted by using the encryption key; in said step E4, a decryption key, which is inter-keyed to said encryption key, is also transmitted to other related nodes involved in the transaction.
Preferably, in the step E3, the encryption key and the decryption key of the inter-key pair are generated by using an asymmetric encryption algorithm.
Preferably, in the step E2, the transaction data is divided into a plurality of data segments, so that each data segment contains the same amount of data.
The present invention also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements a transaction data updating method as described above.
The invention also provides a transaction data updating system based on the block chain world state, which comprises a computer readable storage medium and a processor which are connected with each other, wherein the block chain is provided with a plurality of nodes which are built into a network, and the computer readable storage medium is as described above.
The invention has the following beneficial effects: each related node divides the transaction data into a plurality of data segments and then respectively transmits the data segments to each corresponding adjacent node, and then transmits the address information of each corresponding adjacent node to other related nodes related to the transaction, so that other related nodes can respectively acquire the data segments of the transaction data from each corresponding adjacent node according to the address information to update the data after the transaction in the block is finished, the transaction data of the related nodes can be respectively stored in each corresponding adjacent node to reduce the data storage pressure of the nodes, only the address information of each adjacent node needs to be transmitted to other related nodes in the transaction process in the block, the transaction data of each related node does not need to be transmitted to other related nodes, and the data volume of the address information is smaller relative to the transaction data, so the data transmission pressure of a block chain network can be reduced, multiple nodes involved in a transaction are facilitated to be in a consistent world state.
Drawings
FIG. 1 is a flow chart of a method for updating transaction data based on blockchain world states.
Detailed Description
The invention is described in further detail below with reference to specific embodiments.
The embodiment provides a transaction data updating system based on blockchain world state, where a blockchain has a plurality of nodes built into a network, the system includes a computer-readable storage medium and a processor connected to each other, the computer-readable storage medium has a computer program stored thereon, and when the computer program is executed by the processor, the method for updating transaction data based on blockchain world state as shown in fig. 1 is implemented, and the method includes the following step A, B, C, D, E.
A. And acquiring transaction information in the block.
In this embodiment, when the blockchain executes the intra-block transaction that has been agreed by each node, intra-block transaction information is obtained, where the intra-block transaction information includes transaction request information, transaction object information, transaction content information, and transaction time information.
B. At least two related nodes related to the transaction are analyzed according to the intra-block transaction information.
Since the intra-block transaction information includes transaction object information, and the transaction object is a node performing mutual transaction in the block chain, at least two related nodes related to the transaction can be analyzed according to the intra-block transaction information.
C. And searching adjacent nodes corresponding to the relevant nodes respectively.
A plurality of nodes in a block chain are organized into a network so that each node has a neighboring node adjacent to it. After analyzing at least two related nodes related to the transaction, the embodiment finds out adjacent nodes respectively corresponding to the related nodes.
D. And acquiring the number of adjacent nodes corresponding to each corresponding joint point and address information of each adjacent node.
In the block chain, the number of adjacent nodes corresponding to each node involved in the transaction is not necessarily the same if the number of adjacent nodes of each node is not all the same, and therefore, after the adjacent nodes corresponding to each relevant node are found out, the number of adjacent nodes corresponding to each relevant node is obtained. And moreover, the address information of each adjacent node is also acquired, so that each adjacent node can be found out according to the address information in the following.
E. For each relevant node, the following steps E1, E2, E3 and E4 are performed.
E1. And updating the data in the related nodes according to the transaction information in the blocks to obtain the transaction data related to the transaction process.
Taking one of the related nodes as an example, after the related node related to the transaction is analyzed, updating data in the related node according to the transaction object information, the transaction content information and the transaction time information in the transaction information in the block, and obtaining the transaction data related to the transaction process after updating, wherein the transaction data comprises the transaction object, the transaction content and the transaction time.
E2. And dividing the transaction data into a plurality of data segments according to the number of adjacent nodes corresponding to the corresponding joint points.
Taking ten adjacent nodes corresponding to the relevant node as an example, the transaction data is averagely divided into ten data segments according to the number of the adjacent nodes corresponding to the relevant node, wherein each data segment contains the same data quantity.
E3. And transmitting each data segment to each adjacent node corresponding to the corresponding joint point.
After ten data segments divided by the transaction data are obtained, the data segments are transmitted to each adjacent node corresponding to the corresponding joint point, namely, each adjacent node has one data segment, so that the transaction data of the relevant node can be shared and stored in the corresponding adjacent nodes to relieve the data storage pressure of the node. Then, an encryption key (public key) and a decryption key (private key) which are mutually formed into a key pair are generated by using an asymmetric encryption algorithm, and then the data segments in each adjacent node corresponding to the corresponding node are encrypted by using the encryption key, so that privacy protection is ensured in the subsequent transaction data transmission process.
E4. And transmitting the address information of each adjacent node corresponding to the relevant node to other relevant nodes related to the transaction, so that the other relevant nodes can respectively acquire the data section of the transaction data from each corresponding adjacent node according to the address information to update the data after the transaction in the block is finished.
After the data segment in each adjacent node corresponding to the relevant node is encrypted, the address information of each adjacent node corresponding to the relevant node is transmitted to other relevant nodes related to the transaction, and a decryption key which is mutually matched with the encryption key into a key pair is transmitted to other relevant nodes related to the transaction, so that the other relevant nodes can respectively acquire the encrypted data segment of the transaction data from each corresponding adjacent node according to each address information after the transaction in the block is finished, then the encrypted data segment is decrypted by using the corresponding encryption key, and then the data updating is performed by using the decrypted data segment. Therefore, in the intra-block transaction process, only the address information of each adjacent node needs to be transmitted to other related nodes, the transaction data of each related node does not need to be transmitted to other related nodes, and the data volume of the address information is smaller than that of the transaction data, so that the data transmission pressure of the block chain network can be reduced.
In summary, the transaction data updating method of the embodiment can reduce the data storage pressure and the data transmission pressure of the blockchain network, so that a plurality of nodes related to the transaction are easily in a consistent world state.
The above description is only the embodiments of the present invention, and the scope of protection is not limited thereto. The insubstantial changes or substitutions will now be made by those skilled in the art based on the teachings of the present invention, which fall within the scope of the claims.
- 上一篇:石墨接头机器人自动装卡簧、装栓机
- 下一篇:更新方法、装置及计算机存储介质