CN112561700A - Storage method and verification method of transaction data in block chain and block chain system - Google Patents

Storage method and verification method of transaction data in block chain and block chain system Download PDF

Info

Publication number
CN112561700A
CN112561700A CN202011465866.1A CN202011465866A CN112561700A CN 112561700 A CN112561700 A CN 112561700A CN 202011465866 A CN202011465866 A CN 202011465866A CN 112561700 A CN112561700 A CN 112561700A
Authority
CN
China
Prior art keywords
transaction
transactions
tree
merkle
node
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011465866.1A
Other languages
Chinese (zh)
Inventor
王进
魏博洋
张经宇
王磊
李文军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Changsha University of Science and Technology
Original Assignee
Changsha University of Science and Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Changsha University of Science and Technology filed Critical Changsha University of Science and Technology
Priority to CN202011465866.1A priority Critical patent/CN112561700A/en
Publication of CN112561700A publication Critical patent/CN112561700A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2246Trees, e.g. B+trees
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2255Hash tables
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2291User-Defined Types; Storage management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures

Abstract

The invention discloses a storage method, a verification method and a block chain system of transaction data in a block chain, wherein the storage method comprises the steps of firstly obtaining an importance parameter in the block chain; then, selecting a plurality of transactions from all transactions of the block chain according to the importance parameter of each transaction, so that the verified probability is greater than the verified probability of the rest of transactions when the plurality of transactions are verified at the node; and constructing a second Merkle sub-tree according to the rest transactions, constructing a first Merkle sub-tree according to a plurality of transactions, and constructing a total Merkle tree, so that the distance from any leaf node in the first Merkle sub-tree to the root node of the total Merkle tree is less than the distance from any leaf node in the second Merkle sub-tree to the root node of the total Merkle tree. Compared with the prior art, when any light node verifies the transaction data in the first Merkle sub-tree through the storage method, at least the hash computation amount can be reduced, the size of the data sent by the main node is reduced, the transmission speed is increased, the transmission load is reduced, and the efficiency is improved.

Description

Storage method and verification method of transaction data in block chain and block chain system
Technical Field
The present invention relates to the field of blockchain technologies, and in particular, to a method for storing and verifying transaction data in a blockchain, and a blockchain system.
Background
When a new block is created in the block chain, the nodes participating in consensus need to verify the identity of the transaction information in the nodes of the miner, so that the condition of data tampering is prevented. Node verification starts comparison from a Merkle root, when the Merkle roots are different, the hash values are compared to the next level, and the hash values indicate that data are different and need to be further extended and compared downwards. Repeating the process of comparing the hash values, finding out all data packets with different hash values, comparing each data in the packets, and finding out the data with difference. A large amount of data exists in a newly generated block, and a large amount of hash values and data need to be compared when a node is verified. The data storage method of the Merkle tree is complex, a large amount of operations are required, and the verification efficiency is reduced.
However, the current Merkle tree storage method of the block chain also has the following defects:
(1) in the Merkle tree, transaction data are randomly arranged, classification processing cannot be performed according to the importance degree of the transaction data, and the transaction data are stored on leaf nodes at the bottommost layer of the Merkle tree regardless of the amount of money, so that the current Merkle tree storage method needs to perform hash operation for the same times when any transaction is verified. In the block chain, the higher the amount of money, the higher the possibility that the transaction is verified, which makes the verification of the large amount of money transaction be performed with the same number of hash operations as the small amount of money transaction which is not verified frequently.
(2) When a light node (light node: a node which does not have a complete blockchain account book, can not synchronize transaction information in a block during synchronization, only synchronizes block head information, and can be stored on a mobile device because a hard disk occupies less space) verifies a specific transaction, the hash value of the group of data is obtained through known transactions and the located groups by using a hash algorithm. And sending all hash values required by verification according to the structure of the Merkle tree by using the full nodes (the full nodes: the nodes with the complete blockchain account book, which need to occupy a memory to synchronize all blockchain data, can independently verify all transactions on the blockchain and update data in real time, and are mainly responsible for broadcasting and verifying the transactions of the blockchain), and repeating the hash operation by using the light nodes until the root hash value is obtained. In the process, the whole node needs to transmit a large number of hash values to the light node, so that the problems of long data transmission time, large network load and the like are caused, and meanwhile, the verification efficiency is limited due to the fact that the number of hash operations required to be performed by the light node is large. Therefore, how to reduce the hash operation of the light node and the number of hash values transmitted by the whole node is also a problem to be solved urgently at present.
Disclosure of Invention
The present invention is directed to solving at least one of the problems of the prior art. Therefore, the invention provides a storage method, a verification method and a blockchain system of transaction data in a blockchain. The calculation amount can be reduced, and the storage and verification efficiency is improved.
In a first aspect of the present invention, a method for storing transaction data in a blockchain is provided, including the following steps:
acquiring an importance parameter in a block chain, wherein the importance parameter comprises a transaction amount corresponding to each transaction and/or a node number corresponding to each transaction;
selecting a plurality of transactions from all transactions of the blockchain according to the importance parameter of each transaction, so that the verified probability of the plurality of transactions is greater than the verified probability of the rest transactions except the plurality of transactions of all transactions when the plurality of transactions are verified at the node;
and constructing a first Merkle sub-tree according to the transactions, constructing a second Merkle sub-tree according to the residual transactions, and constructing a total Merkle tree according to the first Merkle sub-tree and the second Merkle sub-tree, so that the distance from any leaf node in the first Merkle sub-tree to the root node of the total Merkle tree is less than the distance from any leaf node in the second Merkle sub-tree to the root node of the total Merkle tree.
According to the embodiment of the invention, at least the following technical effects are achieved:
in the first Merkle sub-tree constructed by the method, the verification probability of the transaction data of the leaf node is greater than that of the transaction data of the leaf node in the second Merkle sub-tree, which means that in practical application, the verification or access to the leaf node in the first Merkle sub-tree is more frequent, and compared with the existing Merkle tree (the Merkle tree in the existing scheme randomly stores the transaction data on the leaf node at the bottommost layer of the Merkle tree), by the method, at least one layer of hash operation amount can be reduced when any node verifies the transaction data in the first Merkle sub-tree.
According to some embodiments of the invention, the importance parameter includes a transaction amount corresponding to each transaction and a number of nodes participating in each transaction; selecting a plurality of transactions from all transactions according to the importance parameter of each transaction, comprising the following steps:
let Yi=p*Xi+q*SiThe total number of all transactions is N, wherein X isiA transaction amount representing an ith transaction, said SiRepresenting the number of nodes participating in the ith transaction, wherein p and q respectively represent weight values, and the p and q of each transaction are the same, and p + q is 1;
through 2n<N<2n+1Solving the n;
for all YiSorting is carried out, and the Y is selected from sorting resultsiLarger 2n-1Pen transactions.
According to some embodiments of the invention, the importance parameter comprises a transaction amount corresponding to each transaction; selecting a plurality of transactions from all transactions according to the importance parameter of each transaction, comprising the following steps:
counting the total number of transactions in the block chain, and recording the total number as N; counting the transaction amount of each transaction, and recording the maximum transaction amount as M;
selecting all transactions in the block chain, the transaction amount of which is less than xM, and all transactions in which the transaction amount is greater than or equal to xM; the probability that all transactions with transaction amounts greater than or equal to xM are verified is greater than the probability that all transactions with transaction amounts less than xM are verified;
through 2n<N<2n+1Obtaining the value of n;
the number of all transactions with the transaction amount less than xM is set to be 2n-1To 2nWithin a range interval of (a).
In a second aspect of the present invention, a verification method for transaction data in a blockchain is provided, where the verification method for transaction data in a blockchain according to the first aspect of the present invention is applied, and the verification method includes the following steps:
the light node calculates the hash value of the transaction to be verified according to the storage position of the transaction to be verified in the total Merkle tree;
all nodes send all hash values necessary for a verification process to the light nodes according to the structure of the total Merkle tree;
and the light nodes carry out Hash operation to obtain root Hash values, and the transaction state of the transaction to be verified is determined according to the root Hash values obtained through calculation and the root Hash values of the total Merkle trees sent by the full nodes.
According to the embodiment of the invention, at least the following technical effects are achieved:
compared with the prior block chain technology, when the transaction data of the first Merkle sub-tree is verified by all nodes, the number of the hash values sent to the light nodes is reduced, the size of the sent data is reduced, the data transmission speed is improved, the network transmission load is reduced, and the efficiency is improved.
In a third aspect of the present invention, a blockchain system is provided, where the blockchain system performs the method for storing transaction data in a blockchain according to the first aspect of the present invention or the method for verifying transaction data in a blockchain according to the second aspect of the present invention.
Additional aspects and advantages of the invention will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the invention.
Drawings
The above and/or additional aspects and advantages of the present invention will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings of which:
FIG. 1 is a schematic diagram of a memory structure of a Merkle tree in the prior art;
fig. 2 is a flowchart illustrating a method for storing transaction data in a blockchain according to a first embodiment of the present invention;
FIG. 3 is a flowchart illustrating an embodiment of step S102 in FIG. 2;
fig. 4 is a flowchart illustrating a method for storing transaction data in a blockchain according to a second embodiment of the present invention;
FIG. 5 is a schematic diagram of a storage structure of an overall Merkle tree according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of another overall Merkle tree storage structure according to an embodiment of the present invention;
fig. 7 is a flowchart illustrating a method for verifying transaction data in a blockchain according to a third embodiment of the present invention.
Detailed Description
Reference will now be made in detail to embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the accompanying drawings are illustrative only for the purpose of explaining the present invention, and are not to be construed as limiting the present invention.
A first embodiment;
because in the existing memory method of the Merkle tree of the block chain, the transaction data are arranged randomly, classification processing can not be carried out according to the importance degree of the transaction data under the current environment, and the transaction data are randomly stored on the leaf node at the bottommost layer of the Merkle tree no matter how much the amount of a single transaction or how many transaction nodes participate in the single transaction. And (3) solving the hash value of every two groups of transaction data in the Merkle tree, continuously solving the hash value of the two subtree structures by using the same hash algorithm, repeatedly solving the hash value two by two to obtain a root hash value, and finally obtaining the Merkle tree storage structure.
Referring to fig. 2, an embodiment of the present invention provides a method for storing transaction data in a blockchain, including the following steps:
s101, obtaining importance parameters in a block chain, wherein the importance parameters comprise transaction amount corresponding to each transaction and node quantity corresponding to participation in each transaction.
In this step, the importance parameter may be adjusted according to the application environment of the blockchain, for example, in this embodiment, in the blockchain application environment where the transaction amount and the number of nodes participating in the transaction are valued, both the transaction amount and the number of nodes corresponding to each transaction are considered. Of course, if the current blockchain application environment attaches importance to the transaction amount, the importance parameter may only be the transaction amount corresponding to each transaction; if the current blockchain application environment attaches importance to the number of nodes participating in the transaction, the importance parameter may only be the number of nodes corresponding to each transaction.
S102, selecting a plurality of transactions from all transactions in the block chain according to the importance parameter of each transaction, so that the verified probability of the transactions is greater than the verified probability of the remaining transactions except the transactions when the transactions are verified at the node.
For example, there are 100 transactions in the blockchain, and 40 transactions are selected from all transactions in the blockchain according to the importance parameter of each transaction, and the probability that the 40 transactions are verified is greater than the probability that 60 transactions are left to be verified.
The importance parameter selected by the embodiment is the transaction amount corresponding to each transaction and the node number corresponding to each transaction. Therefore, an embodiment of selecting a plurality of transactions from all the transactions in the blockchain according to the importance parameter of each transaction is provided, and referring to fig. 3, the method includes the following steps:
s1021, order Yi=p*Xi+q*SiLet the total number of all transactions in the blockchain be N.
Wherein XiIndicating the transaction amount of the ith transaction, SiThe node number participating in the ith transaction is represented, p and q respectively represent weight values, p and q corresponding to each transaction are the same, and p + q is equal to 1. The two weights of p and q can be adjusted according to actual conditions. The value of N may be statistically derived.
S1022, passage 2n<N<2n+1N is obtained.
S1023, for all YiSorting is carried out, and Y is selected from sorting resultsiLarger 2n-1Pen transactions.
This step enables to ensure that the number of levels of the first Merkle sub-tree constructed by selecting a number of transactions is at least one level less than the number of levels of the second Merkle sub-tree constructed by all the remaining transactions.
S103, constructing a first Merkle sub-tree and a second Merkle sub-tree according to the transactions selected in the step S102 and the rest transactions, and constructing a total Merkle tree according to the first Merkle sub-tree and the second Merkle sub-tree, so that the distance from any leaf node in the first Merkle sub-tree to the root node of the total Merkle tree is less than the distance from any leaf node in the second Merkle sub-tree to the root node of the total Merkle tree.
Referring to fig. 5 and 6, the first Merkle sub-tree is the Merkle sub-tree on the left side in fig. 5 or 6; the second Merkle sub-tree is the right Merkle sub-tree in fig. 5 or fig. 6, and the left Merkle sub-tree in fig. 5 or fig. 6 has at least one layer less than the right Merkle sub-tree. The Merkle tree performs hash operation on every two transaction data groups, and repeats the hash operation on every two hash values until a root hash value is obtained. And carrying out hash operation on the root node of the second Merkle sub-tree and the root node of the first Merkle sub-tree to obtain a new root hash value, wherein the new root hash value is the root hash value of the total Merkle tree. Since the construction of Merkle trees is well known in the art, it will not be described in detail here.
In the method, an importance parameter in a block chain is first obtained. And then selecting a plurality of transactions from all transactions in the blockchain according to the importance parameter of each transaction in the current blockchain, so that the verified probability of the plurality of transactions is greater than the verified probability of the rest transactions except the plurality of transactions when the plurality of transactions are verified at the node. And finally, constructing a first Merkle sub-tree by the plurality of transactions, constructing a second Merkle sub-tree by the rest transactions, combining the first Merkle sub-tree and the second Merkle sub-tree into a total Merkle tree, wherein the distance from any leaf node in the first Merkle sub-tree constructed by the plurality of transactions to the root node of the total Merkle tree is smaller than the distance from any leaf node in the second Merkle sub-tree to the root node of the total Merkle tree (namely the number of layers of the first Merkle sub-tree is at least one layer less than that of the second Merkle sub-tree). In the first Merkle sub-tree constructed by the method, the verification probability of the transaction data of the leaf node is greater than that of the transaction data of the leaf node in the second Merkle sub-tree, which means that in practical application, the verification or access to the leaf node in the first Merkle sub-tree is more frequent, compared with the existing Merkle tree (the existing Merkle tree randomly stores the transaction data on the leaf node at the bottommost layer of the Merkle tree), through the method, any node verifies the transaction data in the first Merkle sub-tree, and compared with the prior art, the method can reduce at least one layer of hash operation amount.
A second embodiment;
fig. 4 provides a specific implementation step of a method for storing transaction data in a blockchain, based on the first embodiment, taking the importance parameter as the transaction amount as an example:
s201, counting the total number of the transactions in the block chain, recording the total number as N, counting the transaction amount of each transaction, and recording the maximum transaction amount as M.
S202, all transactions with transaction amount smaller than xM and all transactions with transaction amount larger than or equal to xM in the block chain are selected.
Where x represents the selected percentage (i.e., weight). Here, all transactions whose transaction amounts are greater than or equal to xM correspond to the transactions selected in step S102 of the first embodiment; all transactions having a transaction amount less than xM correspond to the remaining transactions of the first embodiment. This step divides all transaction data into two parts according to the parameter xM, since the transaction data is more likely to be verified for larger transaction amounts.
S203, pass 2n<N<2n+1And obtaining the value of n.
S204, making the number of all transactions with transaction amount less than xM at 2n-1To 2nWithin a range interval of (a).
It is noted that includes 2n-1And 2nThese two endpoints. The purpose of this step is to ensure that the number of levels of the first Merkle sub-tree (corresponding to the left Merkle sub-tree in fig. 5 or fig. 6) constructed by picking up all transactions having a transaction amount greater than or equal to xM is at least one level less than the number of levels of the second Merkle sub-tree (corresponding to the right Merkle sub-tree in fig. 5 or fig. 6) constructed by all transactions having a transaction amount less than xM. For example, in step S202, x is set to 70%, and it is determined whether the number of all transactions having transaction amounts less than 70% M is 2n-1To 2nWithin a range interval of (a). There may be three cases:
in the first case, the number of all transactions with transaction amount less than 70% M is 2n-1To 2nWithin the range of (3), directly entering the next step;
in the second case, the number of all transactions having a transaction amount of less than 70% M is less than 2n-1Then, the value of x needs to be increased, for example, to 80%, and then it is determined whether the number of all transactions with transaction amount less than 80% M is 2n-1To 2nWithin the range of (1), if still less than 2n-1And continuing to increase according to the same principle until the condition is met.
In a third case, the number of all transactions having a transaction amount of less than 70% M is greater than 2nThen, the value of x is decreased, for example, to 60%, and then it is determined whether the number of all transactions with transaction amount less than 60% M is 2n-1To 2nIf it is still greater than 2nAnd continuing to reduce according to the same principle until the condition is met.
S205, performing hash operation on all transactions with the transaction amount meeting the requirement smaller than xM to construct a second Merkle sub-tree, and performing hash operation on all transactions with the transaction amount meeting the requirement larger than or equal to xM to construct a first Merkle sub-tree.
S206, constructing an overall Merkle tree according to the first Merkle subtree and the second Merkle subtree.
And carrying out hash operation on the root node of the first Merkle sub-tree and the root node of the second Merkle sub-tree to obtain the root node of the total Merkle tree. Reference may be made to fig. 5 and 6.
The embodiment has the following beneficial effects:
sorting the transaction amounts of all transactions by taking the transaction amounts as importance parameters, determining the maximum transaction amount, and selecting a part of transaction data (namely all transaction data with the transaction amount larger than or equal to xM) according to the maximum transaction amount to construct a first Merkle sub-tree; another portion of the transaction data (i.e., all transaction data for which the transaction amount is less than xM) constructs a second Merkle sub-tree. The method ensures that the transaction amount of any transaction in the first Merkle sub-tree is larger than the transaction amount of any transaction in the second Merkle sub-tree, the probability of verifying the data recorded by any leaf node in the first Merkle sub-tree is larger than the probability of verifying the data recorded by any leaf node in the second Merkle sub-tree, so that the number of layers of the finally constructed first Merkle sub-tree is at least one layer less than that of the second Merkle sub-tree (which means that the distance between any leaf node in the first Merkle sub-tree and the total root node is closer than the distance between any leaf node in the second Merkle sub-tree and the total root node), and when any node verifies the transaction data in the first Merkle sub-tree, the hash operation amount of at least one layer can be reduced compared with the existing Merkle tree structure.
A third embodiment;
referring to fig. 7, a verification method for transaction data in a blockchain is provided, where the storage method for transaction data in a blockchain of the first embodiment or the second embodiment is applied, and the verification method includes the following steps:
s301, calculating a hash value of the transaction to be verified by the light node according to the storage position of the transaction to be verified in the total Merkle tree;
s302, all nodes send all hash values required by the verification process to the light nodes according to the structure of the total Merkle tree;
and S303, carrying out hash operation on the light nodes to obtain root hash values, and determining the transaction state of the transaction to be verified according to the root hash values obtained by calculation and the root hash values of the total Merkle tree sent by all the nodes.
In step S303, determining the transaction state of the transaction to be verified, that is: and comparing whether the calculated root hash value is the same as the root hash value of the total Merkle tree sent by the whole node or not, and determining whether the transaction to be verified is wrong or not, wherein if the root hash value is the same as the root hash value of the total Merkle tree sent by the whole node, the verified transaction is correct, and if the root hash value is not the same as the root hash value of the total Merkle tree, the transaction is wrong. Since light nodes and full nodes are well known in the art, they will not be described in detail here.
The embodiment has the following beneficial effects:
according to the first embodiment or the second embodiment, in this embodiment, when the light node verifies, the probability of verifying the first Merkle sub-tree (corresponding to the left Merkle sub-tree in fig. 5 or fig. 6) is higher, and compared with the existing block chain technology, when the full node verifies the transaction data of the first Merkle sub-tree, the number of hash values sent to the light node is reduced, the size of the sent data is reduced, the data transmission speed is improved, the network transmission load is reduced, and the efficiency is improved.
A fourth embodiment;
for easy understanding, as shown in fig. 6, assuming that the light node needs to verify the transaction data labeled Tx5, the light node first calculates the Hash value of the existing transaction through a Hash algorithm, i.e. the Hash value is Hash5The hash value of the node. Sending Hash by the whole node6、h4、h8、Root2And the light nodes repeatedly carry out hash operation according to the structure to obtain the hash value of the Root node Merkle Root, and the hash value is compared with the Root hash value sent by all the nodes. In the process, all nodes send five hash values to the light node, and in the existing Merkle tree structure, the hash values sent by all nodes are fixed when each transaction data is verified, as shown in fig. 1, when a certain transaction data is verified by the light node, all nodes also need to send five hash values.
And when the light node needs to verify the transaction data of Tx1 in FIG. 6, the light node calculates the existing transaction by the hash algorithmHash value of the easy data, namely Hash1The hash value of the node. Sending Hash by the whole node2、h2、Root1In the process, all nodes send four hash values to the light node, so that the hash values transmitted by all nodes and the times of hash operation of the light node are reduced to a certain extent. In the block chain, the amount of transaction data generated by each block far exceeds the amount of transaction data in the embodiment, so the optimization effect generated by the above embodiment is also more obvious.
A fifth embodiment;
a blockchain system is provided, where the blockchain system applies the storage method of the transaction data in the blockchain described in the above embodiment and/or the verification method of the transaction data in the blockchain described in the above embodiment. The advantages thereof will not be described in detail herein.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an illustrative embodiment," "an example," "a specific example," or "some examples" or the like mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
While embodiments of the invention have been shown and described, it will be understood by those of ordinary skill in the art that: various changes, modifications, substitutions and alterations can be made to the embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.

Claims (5)

1. A method for storing transaction data in a blockchain is characterized by comprising the following steps:
acquiring an importance parameter in a block chain, wherein the importance parameter comprises a transaction amount corresponding to each transaction and/or a node number corresponding to each transaction;
selecting a plurality of transactions from all transactions of the blockchain according to the importance parameter of each transaction, so that the verified probability of the plurality of transactions is greater than the verified probability of the rest transactions except the plurality of transactions of all transactions when the plurality of transactions are verified at the node;
and constructing a first Merkle sub-tree according to the transactions, constructing a second Merkle sub-tree according to the residual transactions, and constructing a total Merkle tree according to the first Merkle sub-tree and the second Merkle sub-tree, so that the distance from any leaf node in the first Merkle sub-tree to the root node of the total Merkle tree is less than the distance from any leaf node in the second Merkle sub-tree to the root node of the total Merkle tree.
2. The method for storing transaction data in a blockchain according to claim 1, wherein the importance parameter includes a transaction amount corresponding to each transaction and a node number participating in each transaction; selecting a plurality of transactions from all transactions according to the importance parameter of each transaction, comprising the following steps:
let Yi=p*Xi+q*SiThe total number of all transactions is N, wherein X isiA transaction amount representing an ith transaction, said SiRepresenting the number of nodes participating in the ith transaction, wherein p and q respectively represent weight values, and the p and q of each transaction are the same, and p + q is 1;
through 2n<N<2n+1Solving the n;
for all YiSorting is carried out, and the Y is selected from sorting resultsiLarger 2n-1Pen transactions.
3. The method of claim 1, wherein the importance parameter comprises a transaction amount corresponding to each transaction; selecting a plurality of transactions from all transactions according to the importance parameter of each transaction, comprising the following steps:
counting the total number of transactions in the block chain, and recording the total number as N; counting the transaction amount of each transaction, and recording the maximum transaction amount as M;
selecting all transactions in the block chain, the transaction amount of which is less than xM, and all transactions in which the transaction amount is greater than or equal to xM; the probability that all transactions with transaction amounts greater than or equal to xM are verified is greater than the probability that all transactions with transaction amounts less than xM are verified;
through 2n<N<2n+1Obtaining the value of n;
the number of all transactions with the transaction amount less than xM is set to be 2n-1To 2nWithin a range interval of (a).
4. A verification method of transaction data in a blockchain, which is characterized in that the storage method of transaction data in a blockchain according to any one of claims 1 to 3 is applied, and the verification method comprises the following steps:
the light node calculates the hash value of the transaction to be verified according to the storage position of the transaction to be verified in the total Merkle tree;
all nodes send all hash values necessary for a verification process to the light nodes according to the structure of the total Merkle tree;
and the light nodes carry out Hash operation to obtain root Hash values, and the transaction state of the transaction to be verified is determined according to the root Hash values obtained through calculation and the root Hash values of the total Merkle trees sent by the full nodes.
5. A blockchain system, wherein the blockchain system performs the method of storing transaction data in a blockchain according to any one of claims 1 to 3 or the method of verifying transaction data in a blockchain according to claim 4.
CN202011465866.1A 2020-12-14 2020-12-14 Storage method and verification method of transaction data in block chain and block chain system Pending CN112561700A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011465866.1A CN112561700A (en) 2020-12-14 2020-12-14 Storage method and verification method of transaction data in block chain and block chain system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011465866.1A CN112561700A (en) 2020-12-14 2020-12-14 Storage method and verification method of transaction data in block chain and block chain system

Publications (1)

Publication Number Publication Date
CN112561700A true CN112561700A (en) 2021-03-26

Family

ID=75064368

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011465866.1A Pending CN112561700A (en) 2020-12-14 2020-12-14 Storage method and verification method of transaction data in block chain and block chain system

Country Status (1)

Country Link
CN (1) CN112561700A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112967065A (en) * 2021-05-18 2021-06-15 腾讯科技(深圳)有限公司 Transaction verification method, device, equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109903049A (en) * 2019-03-01 2019-06-18 长沙理工大学 A kind of block chain transaction data storage method, device, equipment and storage medium
CN110580653A (en) * 2019-08-14 2019-12-17 长沙理工大学 Block chain consensus mechanism based on transaction
CN110784319A (en) * 2019-10-31 2020-02-11 广州华多网络科技有限公司 Key tree reconstruction method, group key updating method, computer equipment and communication system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109903049A (en) * 2019-03-01 2019-06-18 长沙理工大学 A kind of block chain transaction data storage method, device, equipment and storage medium
CN110580653A (en) * 2019-08-14 2019-12-17 长沙理工大学 Block chain consensus mechanism based on transaction
CN110784319A (en) * 2019-10-31 2020-02-11 广州华多网络科技有限公司 Key tree reconstruction method, group key updating method, computer equipment and communication system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
乔康等: "基于区块链的5G物联网数据共享方案", 网络与信息安全学报, vol. 6, no. 4, 31 August 2020 (2020-08-31), pages 45 - 55 *
邰雪;孙宏斌;郭庆来;: "能源互联网中基于区块链的电力交易和阻塞管理方法", 电网技术, vol. 40, no. 12, 31 December 2016 (2016-12-31), pages 15 - 23 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112967065A (en) * 2021-05-18 2021-06-15 腾讯科技(深圳)有限公司 Transaction verification method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN110602148B (en) Method and device for generating state tree of block and verifying data on chain
CN110163600B (en) Block chain system and method using the same
US20220391358A1 (en) Methods and apparatus for a distributed database within a network
CN109033422B (en) Method and device for generating block chain and block chain
US7537523B2 (en) Dynamic player groups for interest management in multi-character virtual environments
CN107171810A (en) The verification method and device of block chain
US20210216245A1 (en) Method of distributed data redundancy storage using consistent hashing
CN109903049A (en) A kind of block chain transaction data storage method, device, equipment and storage medium
CN111130790B (en) Block co-recognition method based on block chain node network
CN113242601B (en) NOMA system resource allocation method based on optimized sample sampling and storage medium
CN109194646A (en) A kind of safety certification data access method based on block chain
CN110941676A (en) Configuration method, device, equipment and medium
CN111526208A (en) High-concurrency cloud platform file transmission optimization method based on micro-service
CN114938292B (en) Multi-level optimization PBFT consensus method based on node credibility
CN112561700A (en) Storage method and verification method of transaction data in block chain and block chain system
CN106022936B (en) Community structure-based influence maximization algorithm applicable to thesis cooperative network
CN109819013B (en) Block chain storage capacity optimization method based on cloud storage
CN115878729B (en) Node block storage allocation optimization method and system based on alliance chain
CN111444206A (en) Synchronous processing method, device, equipment and medium
CN115065689B (en) Alliance chain block data storage method and system based on historical evaluation
CN114978684B (en) PBFT consensus method based on improved condensation hierarchical clustering
CN116366572A (en) SPN small particle oriented centralized time slot allocation method and device
JP2020061696A (en) Blockchain management system, blockchain management method, and blockchain management program
CN112231394B (en) Block data distribution method for block chain fragmentation storage strategy
KR20230063629A (en) Federated learning method based on consensus

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination