CN111339089B - Data storage and acquisition method and device applied to blockchain - Google Patents

Data storage and acquisition method and device applied to blockchain Download PDF

Info

Publication number
CN111339089B
CN111339089B CN202010107583.3A CN202010107583A CN111339089B CN 111339089 B CN111339089 B CN 111339089B CN 202010107583 A CN202010107583 A CN 202010107583A CN 111339089 B CN111339089 B CN 111339089B
Authority
CN
China
Prior art keywords
data
block
node
nodes
blockchain network
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.)
Active
Application number
CN202010107583.3A
Other languages
Chinese (zh)
Other versions
CN111339089A (en
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.)
Union Mobile Pay Co Ltd
Original Assignee
Union Mobile Pay Co Ltd
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 Union Mobile Pay Co Ltd filed Critical Union Mobile Pay Co Ltd
Priority to CN202010107583.3A priority Critical patent/CN111339089B/en
Publication of CN111339089A publication Critical patent/CN111339089A/en
Application granted granted Critical
Publication of CN111339089B publication Critical patent/CN111339089B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • 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/23Updating
    • 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
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Business, Economics & Management (AREA)
  • Software Systems (AREA)
  • Finance (AREA)
  • Computer Security & Cryptography (AREA)
  • Accounting & Taxation (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Bioethics (AREA)
  • Health & Medical Sciences (AREA)
  • Computing Systems (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • Technology Law (AREA)
  • General Business, Economics & Management (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a data storage and acquisition method and device applied to a blockchain, wherein the method comprises the following steps: after the block data consensus is successful, if the target node is determined not to be a node for storing block data in the block data, storing block header data in the block data but not storing block volume data in the block data; the target node is any node in a blockchain network; the block data includes the block volume data and the block header data; the nodes in the blockchain network for storing the blockvolume data are part of nodes in the blockchain network.

Description

Data storage and acquisition method and device applied to blockchain
Technical Field
The present application relates to the field of blockchains, and in particular, to a data storage method and apparatus applied to blockchains.
Background
The blockchain technology is increasingly applied in various fields due to the characteristics of non-tamper-resistance, consistency and the like of the blockchain. Therefore, the storage read-write performance of the blockchain is critical to the blockchain application quality of service.
In the traditional block chain network, for the node, each newly generated block is stored in the node, and once the block chain network runs for a long time, the data volume of the block stored in the node is overlarge, so that the storage read-write performance of the whole block chain network is poor, and the bottleneck of the running performance of the whole block chain network is formed. Obviously, the problem to be solved is that the storage read-write performance of the whole blockchain network is poor due to the fact that the blockchain network runs for too long.
Disclosure of Invention
The application provides a data storage method and device applied to a blockchain, which solve the problem that the storage read-write performance of the whole blockchain network is poor due to the fact that the blockchain network operates for too long in the prior art.
In a first aspect, the present application provides a data storage method applied to a blockchain, comprising: after the block data consensus is successful, if the target node is determined not to be a node for storing block data in the block data, storing block header data in the block data but not storing block volume data in the block data; the target node is any node in a blockchain network; the block data includes the block volume data and the block header data; the nodes in the blockchain network for storing the blockvolume data are part of nodes in the blockchain network.
In the above method, after the block data consensus succeeds, the target node does not directly store the block body data and the block header data in the target node, but determines whether the target node is the block data in the block data storage area, if not, only stores the block header data in the block data, so that all data of the block data do not need to be stored.
In an alternative embodiment, the determining that the target node is not storing block data in the block data includes: the target node takes the data identification of the block data as the input of the node selection strategy, and determines a node set storing the block volume data in a block chain network according to the node selection strategy; and if the target node determines that the target node is not in the node set, determining that the target node is not storing the block data in the block data.
In the method, the target node takes the data identifier as the input of the node selection strategy, the node set is determined according to the node selection strategy, and when the target node is determined not to be in the node set, the target node is determined not to be the node for storing the block data in the block data, so that the method for determining the node for storing the block data in the block chain network is provided under the condition that data interaction with the outside is not needed.
In an alternative embodiment, the node selection policy includes a number of nodes in the blockchain network that store the blockvolume data; the number range of the number of nodes is determined by a consensus algorithm of the blockchain network; if the consensus algorithm is a practical Bayesian fault tolerant PBFT consensus algorithm, the number range isWherein M is the total number of nodes in the blockchain network, < >>Representing a rounding operation; alternatively, if the consensus algorithm is a proof of work POW consensus algorithm, the number range is +.>
In the method, under different consensus algorithms, the blockchain is used forThe block body data is stored according to the nodes above a certain node number in the network, so that the block body data stored by at least one node in the node set of the target node is effective data, under the PBFT consensus algorithm,the above is->Nodes within the range store the block volume data, ensure that the block volume data stored in at least one node is valid data, and under the POW consensus algorithm, the block volume data is stored in the at least one node>The above is-> Nodes in the range store the block volume data, and the block volume data stored in at least one node is ensured to be effective data, so that the block volume data is stored in the nodes in the range under different consensus algorithms, the correctness of data storage can be ensured, and the storage space of the data can be saved.
In an alternative embodiment, if the consensus algorithm is a PBFT consensus algorithm, the number of nodes isAlternatively, if the consensus algorithm is a POW consensus algorithm, the number of nodes is +.>
Under the mode, the data storage space is saved to the greatest extent on the basis of ensuring the correctness of data storage under different consensus algorithms.
In an alternative embodiment, the node selection policy is a consistent node selection algorithm based on the number of nodes; the target node uses the data identification of the block data as the input of the node selection strategy, and determines a node set storing the block volume data in a block chain network according to the node selection strategy, wherein the node set comprises: the target node takes the data identification as input of the consistency node selection algorithm, and takes the nodes of the node number selected in the blockchain network according to the consistency node selection algorithm as a node set of the target node; the consistency node selection algorithm is executed by each node in the blockchain network, so that node sets determined by each node in the blockchain network according to the node selection strategy are consistent.
In the above manner, the node selection policy is a consistent node selection algorithm based on the number of nodes; because the consistency node selection algorithm is executed by each node in the blockchain network, node sets determined by each node in the blockchain network according to the node selection strategy are consistent, and therefore the unification of storage information of block storage data in the blockchain network in each node can be ensured.
In a second aspect, the present application provides a data acquisition method applied to a blockchain, comprising: the target node obtains a query request; the query request is used for acquiring a block to be queried; the block data to be queried comprises block body data and block head data; if the target node determines that the block volume data is not stored in the target node, determining a node storing the block volume data in the block chain network; wherein the nodes in the blockchain network storing the blockvolume data are part of the nodes in the blockchain network; the target node is any node in a blockchain network; the target node sends an acquisition request to a node storing the block volume data in the blockchain network, thereby acquiring the block volume data returned from the node.
In the method, after the target node acquires the query request, if it is determined that the block volume data is not stored in the target node, determining a node storing the block volume data in the blockchain network, and transmitting an acquisition request to acquire the block volume data returned from the node, so that the block volume data acquisition method is provided when only part of nodes in the blockchain network store the block volume data.
In an alternative embodiment, after the target node sends the acquisition request to the node storing the block volume data in the blockchain network, the method further includes: the target node acquires pending block volume data returned by the node; the target node determines a hash value of the block head data to be localized according to the block data to be localized; and if the target node determines that the hash value of the block header to be determined is consistent with the hash value of the block header data, determining that the block data to be determined, which is returned from the node, is the block body data, and thus acquiring the returned block body data from the node.
In a third aspect, the present application provides a data storage device for use in a blockchain, comprising: the determining module is used for determining whether the target node is a node for storing block data in the block data after the block data consensus is successful; the storage module is used for storing the block head data in the block data but not the block volume data in the block data if the determination module determines that the target node is not the node for storing the block data in the block data; the target node is any node in a blockchain network; the block data includes the block volume data and the block header data; the nodes in the blockchain network for storing the blockvolume data are part of nodes in the blockchain network.
In an alternative embodiment, the determining module is specifically configured to: the data identification of the block data is used as the input of the node selection strategy, and the node set for storing the block volume data in the block chain network is determined according to the node selection strategy; and if the target node is determined not to be in the node set, determining that the target node is not a node for storing block data in the block data.
In an alternative embodiment, the node selection policy includes a number of nodes in the blockchain network that store the blockvolume data; the number range of the number of nodes is determined by a consensus algorithm of the blockchain network; if the consensus algorithm is a practical Bayesian fault tolerant PBFT consensus algorithm, the number range isWherein M is the total number of nodes in the blockchain network, < >>Representing a rounding operation; alternatively, if the consensus algorithm is a proof of work POW consensus algorithm, the number range is +.>
In an alternative embodiment, if the consensus algorithm is a PBFT consensus algorithm, the number of nodes isAlternatively, if the consensus algorithm is a POW consensus algorithm, the number of nodes is +.>
In an alternative embodiment, the node selection policy is a consistent node selection algorithm based on the number of nodes; the determining module is specifically configured to: the target node takes the data identification as input of the consistency node selection algorithm, and takes the nodes of the node number selected in the blockchain network according to the consistency node selection algorithm as a node set of the target node; the consistency node selection algorithm is executed by each node in the blockchain network, so that node sets determined by each node in the blockchain network according to the node selection strategy are consistent.
The advantages of the foregoing third aspect and the respective embodiments of the third aspect may be referred to the advantages of the foregoing first aspect and the respective embodiments of the first aspect, and are not described herein again.
In a fourth aspect, the present application provides a data storage device for use in a blockchain, comprising: the acquisition module is used for acquiring the query request; the query request is used for acquiring a block to be queried; the block data to be queried comprises block body data and block head data; the processing module is used for determining a node storing the block volume data in the block chain network if the block volume data is not stored in the target node; wherein the nodes in the blockchain network storing the blockvolume data are part of the nodes in the blockchain network; the target node is any node in a blockchain network; and sending an acquisition request to a node storing the block volume data in the block chain network, so that the acquisition module acquires the block volume data returned from the node.
In an alternative embodiment, the obtaining module is further configured to: acquiring pending block volume data returned by the node; the processing module is further configured to: determining a hash value of the block head data to be fixed according to the block data to be fixed; and if the hash value of the block header to be determined to be consistent with the hash value of the block header data, determining that the block data to be determined, which is returned from the node, is the block body data, and thus obtaining the returned block body data from the node.
The advantages of the foregoing fourth aspect and the embodiments of the fourth aspect may be referred to for the advantages of the foregoing second aspect and the embodiments of the second aspect, and will not be described herein.
In a fifth aspect, the present application provides a computer device comprising a program or instructions which, when executed, is adapted to carry out the method of the first or second aspect and the respective embodiments described above.
In a sixth aspect, the present application provides a storage medium comprising a program or instructions which, when executed, is operable to perform the method of each embodiment of the first or second aspects described above.
Drawings
FIG. 1 is a schematic block chain architecture;
FIG. 2 is a flowchart illustrating steps of a data storage method for a blockchain according to an embodiment of the present application;
FIG. 3 is a schematic diagram of an architecture to which a data storage method applied to a blockchain is applicable according to an embodiment of the present application;
FIG. 4 is a schematic diagram illustrating steps of a data storage method applied to a blockchain according to an embodiment of the present application;
fig. 5 is a schematic diagram of an application scenario of a data storage method applied to a blockchain according to an embodiment of the present application;
FIG. 6 is a schematic diagram of a data storage device applied to a blockchain according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of a data acquisition device applied to a blockchain according to an embodiment of the present application.
Detailed Description
In order to better understand the above technical solutions, the following detailed description will be made with reference to the accompanying drawings and specific embodiments of the present application, and it should be understood that specific features in the embodiments and examples of the present application are detailed descriptions of the technical solutions of the present application, and not limiting the technical solutions of the present application, and the technical features in the embodiments and examples of the present application may be combined with each other without conflict.
The terms appearing in the embodiments of the present application are explained first below.
Blockchain: as shown in fig. 1, a blockchain is a chain of blocks, each block being recorded with a Hash value of the previous block in addition to the data of the block, in such a way that the chain is formed. The block chain has two core concepts, one is a cryptography technology, the other is a decentralization concept, and the history information on the block chain cannot be tampered based on the two concepts.
And (3) node: each participant in the network is a node that participates in network construction and data exchange. In a blockchain network, a node refers to a participant with a unique identity, the node having a complete ledger copy with the ability to participate in blockchain network consensus and ledger maintenance.
Intelligent contract: an intelligent contract is a computer protocol that aims to propagate, verify, or execute contracts in an informative manner. Smart contracts allow trusted transactions to be made without third parties, which transactions are traceable and irreversible. The smart contracts are in the form of code deployed on a blockchain to perform a specific function. For example, solubility is a mainstream smart contract programming language, and smart contracts written in the solubility language are called solubility contracts. When an intelligent contract is deployed onto a blockchain, a contract address is generated through which a user may invoke the intelligent contract. A function defined in an intelligent contract, called a contract interface, calls to an intelligent contract, are calls to a certain contract interface in the contract through a contract address.
Transaction: a transaction is a request by a user for an operation of an intelligent contract interface deployed on a blockchain. The transaction is initiated by a user, the transaction is sent to a blockchain node from a client of the user, and after the blockchain node receives the transaction, the corresponding intelligent contract is called according to a contract address and an interface appointed by the transaction. In the blockchain, any operation (deploying contracts, invoking contract interfaces, etc.) is performed by way of a send transaction. The transaction is initiated by the user and sent to the blockchain node through the client. After receiving the transaction, the blockchain node packages the transaction into blocks and executes the blocks.
Each transaction in the block is executed to generate a corresponding transaction receipt. The transaction receipt stores the results of the execution of the transaction, and typically the transaction receipt contains important information such as a transaction hash, status bits identifying whether the transaction was successfully executed, and logs generated during execution.
As shown in FIG. 2, a data storage method for a blockchain is provided in an embodiment of the present application.
Step 201: after the block data consensus is successful, the target node determines whether the target node is a node storing block data in the block data.
Step 202: and if the target node is determined not to be the node for storing the block data in the block data, storing the block head data in the block data but not storing the block volume data in the block data.
In step 201 to step 202, the target node is any node in a blockchain network; the block data includes the block volume data and the block header data; the nodes in the blockchain network for storing the blockvolume data are part of nodes in the blockchain network. Thus, the storage of the target node may be: a block head and a block body of the block I; a block header of the second block; a block header of a block three; block header and block body of block four.
In an alternative embodiment of step 201, determining that the target node is not storing the block data may be as follows:
the target node takes the data identification of the block data as the input of the node selection strategy, and determines a node set storing the block volume data in a block chain network according to the node selection strategy; and if the target node determines that the target node is not in the node set, determining that the target node is not storing the block data in the block data.
It should be noted that, the data identifier of the block data may be various, so long as the block can be uniquely identified. For example, the data identification of the chunk data is a transaction hash of the first transaction in the chunk data. The node selection policy is not limited, as long as the finally selected node is a part of nodes in the blockchain network and can be obtained according to the node selection policy.
The above process includes, for example, node one, node two, node three, and node four in the blockchain network. And when the target node is the first node, after the first node successfully shares the block data, taking the transaction hash of the first transaction of the block data as the input of a node selection strategy, obtaining a node set which is the second node and the third node, and determining that the first node is not the block data in the block data when the first node is not in the node set.
In an alternative embodiment, the node selection policy is a consistent node selection algorithm based on the number of nodes; the specific process of the target node using the data identifier of the block data as the input of the node selection policy and determining the node set storing the block volume data in the blockchain network according to the node selection policy may be:
the target node takes the data identification as input of the consistency node selection algorithm, and takes the nodes of the node number selected in the blockchain network according to the consistency node selection algorithm as a node set of the target node; the consistency node selection algorithm is executed by each node in the blockchain network, so that node sets determined by each node in the blockchain network according to the node selection strategy are consistent.
The above process includes, for example, node one, node two, node three, and node four in the blockchain network. After the first, second, third and fourth common block data succeed, the transaction hash of the first transaction of the block data is used as the input of the node selection strategy, and the first, second, third and fourth obtained node sets are the second and third nodes.
The consistency node selection algorithm may be any one of the following: a node polling algorithm; a node weight polling algorithm; a node identification ordering algorithm; the random function VRF algorithm may be validated.
It should be noted that, the node selection policy may include the number of nodes storing the block volume data in the blockchain network; the number range of the number of nodes is determined by a consensus algorithm of the blockchain network, specifically:
if the consensus algorithm is a practical Bayesian fault tolerant PBFT consensus algorithm, the number range isWherein M is the total number of nodes in the blockchain network, < >>Representing a rounding operation; alternatively, if the consensus algorithm is a proof of work POW consensus algorithm, the number range is +.>
For example, when M is 10, for the PBFT consensus algorithm, then the number range is [4, 10); for the POW consensus algorithm, the number range is [6,10 ].
Under different consensus algorithms, the block volume data is stored according to nodes with more than a certain number of nodes in the block chain network, so that the block volume data stored by at least one node in the node set of the target node can be valid data. That is, the number range may be determined according to the consensus algorithm; any of the number ranges is such that at least one node in the blockchain network stores a value for which the blockvolume data is real data. Under the PBFT consensus algorithm,the above is-> Nodes within the range store the block volume data, ensure that the block volume data stored in at least one node is valid data, and under the POW consensus algorithm, the block volume data is stored in the at least one node>The above isNodes in the range store the block volume data, and the block volume data stored in at least one node is ensured to be effective data, so that the block volume data is stored in the nodes in the range under different consensus algorithms, the correctness of data storage can be ensured, and the storage space of the data can be saved.
In a more specific alternative embodiment, if the consensus algorithm is a PBFT consensus algorithm, the number of nodes isAlternatively, if the consensus algorithm is a POW consensus algorithm, the number of nodes is +.>
For example, when M is 20, for the PBFT consensus algorithm, then the number of nodes is 7; for the POW consensus algorithm, the number of nodes is 11.
Under the mode, the data storage space is saved to the greatest extent on the basis of ensuring the correctness of data storage under different consensus algorithms.
In the method of step 201 to step 202, after the block data consensus is successful, the target node does not directly store the block body data and the block header data in the target node, but determines whether the target node is the block data in the block data, if not, only stores the block header data in the block data, so that all data of the block data is not required to be stored.
After the data storage methods of steps 201 to 202 are performed, since each block data is stored in only a part of nodes in the blockchain network, when a node is requested for a block data, the node may not have all the block data and only the block body data.
To this end, the present application provides a data acquisition method applied to a blockchain, specifically:
the target node obtains the query request.
The query request is used for acquiring a block to be queried. The block data to be queried comprises block body data and block head data.
And if the target node determines that the block volume data is not stored in the target node, determining a node storing the block volume data in the block chain network. Wherein the nodes in the blockchain network storing the blockvolume data are part of the nodes in the blockchain network; the target node is any node in a blockchain network.
The target node sends an acquisition request to a node storing the block volume data in the blockchain network, thereby acquiring the block volume data returned from the node.
When the target node stores the block data, a node selection policy is used to select the node storing the block data, and the node selection policy includes the number of nodes storing the block data in the blockchain network, where the number range of the number of nodes is determined by a consensus algorithm of the blockchain network. The more nodes storing block data, the smaller the space for node collusion, and when the number of nodes is larger than a certain storage threshold, the block data stored by at least one node can be ensured to be effectively available. The number range of specific node numbers may thus be determined according to a consensus algorithm of the blockchain network such that blockvolume data stored by at least one node is effectively available. If the consensus algorithm is a practical Bayesian fault tolerant PBFT consensus algorithm, the number range isWherein M is the total number of nodes in the blockchain network, < >>Representing a rounding operation; alternatively, if the consensus algorithm is a proof of work POW consensus algorithm, the number range is +.>The target node has at least one node feeding back pending block data available effectively when querying the block data.
In the method, after the target node acquires the query request, if it is determined that the block volume data is not stored in the target node, determining a node storing the block volume data in the blockchain network, and transmitting an acquisition request to acquire the block volume data returned from the node, so that the block volume data acquisition method is provided when only part of nodes in the blockchain network store the block volume data.
In an alternative embodiment, after the target node sends the acquisition request to the node storing the block volume data in the blockchain network, the method further includes: the target node acquires pending block volume data returned by the node; the target node determines a hash value of the block head data to be localized according to the block data to be localized; and if the target node determines that the hash value of the block header to be determined is consistent with the hash value of the block header data, determining that the block data to be determined, which is returned from the node, is the block body data, and thus acquiring the returned block body data from the node.
When the target node stores the node of the block data of the storage area by adopting a node selection strategy, and the node selection strategy comprises the number of nodes storing the block volume data in the block chain network, as at least one node returns the block volume data to be determined, the target node can obtain at least one block volume data to be determined under the method, so that the hash value of the block head to be determined is consistent with the hash value of the block head data, and the returned block volume data is acquired from the node.
The following describes in detail a data storage method applied to a blockchain in conjunction with fig. 3 and 4. After the nodes receive the block data which are commonly recognized, the nodes are commonly recognized through an interface module, a transaction management module, an intelligent contract execution module and a multi-node module, and each node stores the block by an account book module. The nodes execute the transactions in the blocks to complete the updating of the state data, and the account book module stores the state data. After the account book module receives the block, the block data is split into block body data and block head data, and the storage area block head data is stored. And judging whether the current node stores block data or not by the account book module according to the node selection strategy. If so, the block data is stored. Otherwise, the block data is not stored. After the query module receives the query request, the node where the block body data is located is obtained through a consistency node selection algorithm according to the queried block number, and the query is performed to the node containing the block.
Specifically, the node selection policy includes two steps: node number selection and specific node selection. Wherein the number of nodes varies according to the consensus algorithm. For the PBFT type consensus algorithm, if the number of nodes is 3f+1 (f is a positive integer greater than or equal to 1), the key field of the block data, then each newly generated block needs at least f+1 nodes to store the block data. f represents the number of Bayesian nodes, and if the number of the nodes is 2f+1 (f is a positive integer greater than or equal to 1), the POW type consensus algorithm needs at least f+1 node storage area block data for each newly generated block. Other consensus algorithms also satisfy that the number of storage nodes is at least greater than the number of bayer pattern nodes.
As shown in fig. 4, the complete flow includes the following steps:
step 401: the target node identifies the block data.
After the success of the target node formula block data, step 402 is performed.
Step 402: the target node stores state data in the block data.
Step 403: the target node splits the block header data and the block body data in the block data and stores the block header data.
Step 404: and the target node obtains a node set of the storage block according to the consistency algorithm.
Step 405: it is determined whether the target node is in the node set.
If yes, go to step 406, otherwise go to step 407.
Step 406: block body data in the block data is stored.
Step 407: the block volume data in the block data is discarded.
The data storage method shown in fig. 1 is described in detail below in conjunction with the scenario shown in fig. 5, using a PBFT consensus algorithm, for example, by one blockchain system, where the total number of nodes is 4, and the nodes are a, B, C, D, respectively. Wherein the D node is a bayer node.
The node B initiates a transaction and the consensus is completed.
For each of the A, B, C and D nodes, the following steps are performed:
the ledger module stores block header data and status data. And the account book module determines to select at least F+1 nodes according to a consensus algorithm for data storage, wherein F=1, namely two nodes store the full data. And the account book module selects specific A nodes and C nodes to store block data according to the current block height and HASH of the block head through a VRF random selection algorithm.
And entering the next round of consensus.
When a certain node needs to inquire the data in the block body of the area, the node where the block is located is determined by a VRF verifiable algorithm preferentially according to the number of the block, if the node is the current node, the local database is inquired, and if the node is not the current node, the block data is requested to the corresponding node. After the data is acquired, the hash of the block and the hash of the local block header are verified. If the data are consistent, the data are correct, otherwise, the data are wrong, and the next node is requested to acquire the data. Until consistent data is obtained, if the data are inconsistent, a data error is returned.
As shown in FIG. 6, the present application provides a data storage device for a blockchain, comprising: a determining module 601, configured to determine whether a target node is a node storing block data in the block data after block data consensus is successful; a storage module 602, configured to store block header data in the block data but not block volume data in the block data if the determination module 601 determines that the target node is not a node storing block data in the block data; the target node is any node in a blockchain network; the block data includes the block volume data and the block header data; the nodes in the blockchain network for storing the blockvolume data are part of nodes in the blockchain network.
In an alternative embodiment, the determining module 601 is specifically configured to: the data identification of the block data is used as the input of the node selection strategy, and the node set for storing the block volume data in the block chain network is determined according to the node selection strategy; and if the target node is determined not to be in the node set, determining that the target node is not a node for storing block data in the block data.
In an alternative embodiment, the node selection policy includes a number of nodes in the blockchain network that store the blockvolume data; the number range of the number of nodes is determined by a consensus algorithm of the blockchain network; if the consensus algorithm is a practical Bayesian fault tolerant PBFT consensus algorithm, the number range isWherein M is the total number of nodes in the blockchain network, < >>Representing a rounding operation; alternatively, if the consensus algorithm is a proof of work POW consensus algorithm, the number range is +.>
In an alternative embodiment, if the consensus algorithm is a PBFT consensus algorithm, the number of nodes isAlternatively, if the consensus algorithm is a POW consensus algorithm, the number of nodes is +.>
In an alternative embodiment, the node selection policy is a consistent node selection algorithm based on the number of nodes; the determining module 601 is specifically configured to: the target node takes the data identification as input of the consistency node selection algorithm, and takes the nodes of the node number selected in the blockchain network according to the consistency node selection algorithm as a node set of the target node; the consistency node selection algorithm is executed by each node in the blockchain network, so that node sets determined by each node in the blockchain network according to the node selection strategy are consistent.
As shown in FIG. 7, the present application provides a data storage device for a blockchain, comprising: an obtaining module 701, configured to obtain a query request; the query request is used for acquiring a block to be queried; the block data to be queried comprises block body data and block head data; a processing module 702, configured to determine a node in the blockchain network that stores the blockvolume data if it is determined that the blockvolume data is not stored in the target node; wherein the nodes in the blockchain network storing the blockvolume data are part of the nodes in the blockchain network; the target node is any node in a blockchain network; an acquisition request is sent to a node in the blockchain network that stores the blockvolume data, so that the acquisition module 701 acquires the blockvolume data returned from the node.
In an alternative embodiment, the obtaining module 701 is further configured to: acquiring pending block volume data returned by the node; the processing module 702 is further configured to: determining a hash value of the block head data to be fixed according to the block data to be fixed; and if the hash value of the block header to be determined to be consistent with the hash value of the block header data, determining that the block data to be determined, which is returned from the node, is the block body data, and thus obtaining the returned block body data from the node.
The embodiment of the application provides a computer device, which comprises a program or an instruction, and when the program or the instruction is executed, the program or the instruction is used for executing the data storage method and any optional method applied to a blockchain.
The embodiment of the application provides a storage medium comprising a program or an instruction, which when executed, is used for executing the data storage method and any optional method applied to a blockchain.
Finally, it should be noted that: it will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to the application. It will be understood that each flow and/or block of 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, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present application without departing from the scope of the application. Thus, it is intended that the present application also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.

Claims (10)

1. A data storage method applied to a blockchain, comprising:
after the block data consensus is successful, if the target node is determined not to be a node for storing block data in the block data, storing block header data in the block data but not storing block volume data in the block data; the target node is any node in a blockchain network; the block data includes the block volume data and the block header data; the nodes in the blockchain network for storing the blockvolume data are part of nodes in the blockchain network.
2. The method of claim 1, wherein the determining that the target node is not storing block data in the block data comprises:
the target node takes the data identification of the block data as the input of the node selection strategy, and determines a node set storing the block volume data in a block chain network according to the node selection strategy;
and if the target node determines that the target node is not in the node set, determining that the target node is not a node for storing block data in the block data.
3. The method of claim 2, wherein the node selection policy includes a number of nodes in the blockchain network that store the blockvolume data; the number range of the number of nodes is determined by a consensus algorithm of the blockchain network;
if the consensus algorithm is a practical Bayesian fault tolerant PBFT consensus algorithm, the number range isWherein M is the total number of nodes in the blockchain network, < >>Representing a rounding operation;
alternatively, if the consensus algorithm is a proof of work POW consensus algorithm, the number range is
4. The method of claim 3, wherein if the consensus algorithm is a PBFT consensus algorithm, the number of nodes isAlternatively, if the consensus algorithm is a POW consensus algorithm, the number of nodes is +.>
5. The method of claim 3 or 4, wherein the node selection policy is a consistent node selection algorithm based on the number of nodes; the target node uses the data identification of the block data as the input of the node selection strategy, and determines a node set storing the block volume data in a block chain network according to the node selection strategy, wherein the node set comprises:
the target node takes the data identification as input of the consistency node selection algorithm, and takes the nodes of the node number selected in the blockchain network according to the consistency node selection algorithm as a node set of the target node; the consistency node selection algorithm is executed by each node in the blockchain network, so that node sets determined by each node in the blockchain network according to the node selection strategy are consistent.
6. A method of data acquisition for a blockchain, comprising:
the target node obtains a query request; the query request is used for acquiring a block to be queried; the block data to be queried comprises block body data and block head data;
if the target node determines that the block volume data is not stored in the target node, determining a node storing the block volume data in the block chain network; wherein the nodes in the blockchain network storing the blockvolume data are part of the nodes in the blockchain network; the target node is any node in a blockchain network;
the target node sends an acquisition request to a node storing the block volume data in the blockchain network, thereby acquiring the block volume data returned from the node.
7. The method of claim 6, wherein after the target node sends the acquisition request to the node in the blockchain network that stores the blockvolume data, further comprising:
the target node acquires pending block volume data returned by the node;
the target node determines a hash value of the block head data to be localized according to the block data to be localized;
and if the target node determines that the hash value of the block header to be determined is consistent with the hash value of the block header data, determining that the block data to be determined, which is returned from the node, is the block body data, and thus acquiring the returned block body data from the node.
8. A data storage device for use in a blockchain, comprising:
the determining module is used for determining whether the target node is a node for storing block data in the block data after the block data consensus is successful;
the storage module is used for storing the block head data in the block data but not the block volume data in the block data if the determination module determines that the target node is not the node for storing the block data in the block data; the target node is any node in a blockchain network; the block data includes the block volume data and the block header data; the nodes in the blockchain network for storing the blockvolume data are part of nodes in the blockchain network.
9. A data acquisition device for a blockchain, comprising:
the acquisition module is used for acquiring the query request; the query request is used for acquiring a block to be queried; the block data to be queried comprises block body data and block head data;
the processing module is used for determining a node storing the block volume data in the block chain network if the block volume data is not stored in the target node; wherein the nodes in the blockchain network storing the blockvolume data are part of the nodes in the blockchain network; the target node is any node in a blockchain network; and sending an acquisition request to a node storing the block volume data in the block chain network, so that the acquisition module acquires the block volume data returned from the node.
10. A computer device comprising a program or instructions which, when executed, performs the method of any of claims 1 to 5 or 6 to 7.
CN202010107583.3A 2020-02-21 2020-02-21 Data storage and acquisition method and device applied to blockchain Active CN111339089B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010107583.3A CN111339089B (en) 2020-02-21 2020-02-21 Data storage and acquisition method and device applied to blockchain

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010107583.3A CN111339089B (en) 2020-02-21 2020-02-21 Data storage and acquisition method and device applied to blockchain

Publications (2)

Publication Number Publication Date
CN111339089A CN111339089A (en) 2020-06-26
CN111339089B true CN111339089B (en) 2023-09-22

Family

ID=71184147

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010107583.3A Active CN111339089B (en) 2020-02-21 2020-02-21 Data storage and acquisition method and device applied to blockchain

Country Status (1)

Country Link
CN (1) CN111339089B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112988903B (en) * 2021-04-22 2021-08-03 腾讯科技(深圳)有限公司 Data processing method, device and equipment based on block chain network and storage medium

Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018112805A1 (en) * 2016-12-21 2018-06-28 深圳前海达闼云端智能科技有限公司 Blockchain storage method and device, and node device
CN108537063A (en) * 2018-02-26 2018-09-14 阿里巴巴集团控股有限公司 A kind of method, apparatus and equipment of data storage
CN108769230A (en) * 2018-06-06 2018-11-06 腾讯科技(深圳)有限公司 Transaction data storage method, device, server and storage medium
CN109324757A (en) * 2018-08-22 2019-02-12 深圳前海微众银行股份有限公司 Block chain data capacity reduction method, device and storage medium
CN109508982A (en) * 2018-11-21 2019-03-22 北京蓝石环球区块链科技有限公司 REPB common recognition based on the more subchains of block chain main chain adduction row
CN109522362A (en) * 2018-10-17 2019-03-26 北京瑞卓喜投科技发展有限公司 Incomplete markets synchronous method, system and equipment based on block chain data
CN109636388A (en) * 2018-12-07 2019-04-16 深圳市智税链科技有限公司 Data processing method, device, medium and electronic equipment in block chain network
CN109842606A (en) * 2018-02-24 2019-06-04 中国科学院计算技术研究所 Block chain common recognition algorithm and system based on consistency hash algorithm
WO2019179540A2 (en) * 2019-07-11 2019-09-26 Alibaba Group Holding Limited Shared blockchain data storage
CN110472116A (en) * 2018-04-28 2019-11-19 腾讯科技(深圳)有限公司 Alliance's block chain business network and its federation node, product data storage method
WO2019228550A2 (en) * 2019-08-20 2019-12-05 Alibaba Group Holding Limited Blockchain data storage based on shared nodes and error correction code
CN110602116A (en) * 2019-09-19 2019-12-20 腾讯科技(深圳)有限公司 Block chain based data verification method, device and computer readable storage medium
CN110633323A (en) * 2019-09-16 2019-12-31 腾讯科技(深圳)有限公司 Business data storage method, device, storage medium and computer equipment
CN110730225A (en) * 2019-09-30 2020-01-24 北京中电拓方科技股份有限公司 Data processing method of Internet of things based on block chain, Internet of things and storage medium
WO2020035088A2 (en) * 2019-11-06 2020-02-20 Alipay (Hangzhou) Information Technology Co., Ltd. Prioritizing shared blockchain data storage

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190188086A1 (en) * 2017-12-14 2019-06-20 International Business Machines Corporation Redundancy reduction in blockchains

Patent Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018112805A1 (en) * 2016-12-21 2018-06-28 深圳前海达闼云端智能科技有限公司 Blockchain storage method and device, and node device
CN109842606A (en) * 2018-02-24 2019-06-04 中国科学院计算技术研究所 Block chain common recognition algorithm and system based on consistency hash algorithm
CN108537063A (en) * 2018-02-26 2018-09-14 阿里巴巴集团控股有限公司 A kind of method, apparatus and equipment of data storage
CN110472116A (en) * 2018-04-28 2019-11-19 腾讯科技(深圳)有限公司 Alliance's block chain business network and its federation node, product data storage method
CN108769230A (en) * 2018-06-06 2018-11-06 腾讯科技(深圳)有限公司 Transaction data storage method, device, server and storage medium
CN109324757A (en) * 2018-08-22 2019-02-12 深圳前海微众银行股份有限公司 Block chain data capacity reduction method, device and storage medium
CN109522362A (en) * 2018-10-17 2019-03-26 北京瑞卓喜投科技发展有限公司 Incomplete markets synchronous method, system and equipment based on block chain data
CN109508982A (en) * 2018-11-21 2019-03-22 北京蓝石环球区块链科技有限公司 REPB common recognition based on the more subchains of block chain main chain adduction row
CN109636388A (en) * 2018-12-07 2019-04-16 深圳市智税链科技有限公司 Data processing method, device, medium and electronic equipment in block chain network
WO2019179540A2 (en) * 2019-07-11 2019-09-26 Alibaba Group Holding Limited Shared blockchain data storage
WO2019228550A2 (en) * 2019-08-20 2019-12-05 Alibaba Group Holding Limited Blockchain data storage based on shared nodes and error correction code
CN110633323A (en) * 2019-09-16 2019-12-31 腾讯科技(深圳)有限公司 Business data storage method, device, storage medium and computer equipment
CN110602116A (en) * 2019-09-19 2019-12-20 腾讯科技(深圳)有限公司 Block chain based data verification method, device and computer readable storage medium
CN110730225A (en) * 2019-09-30 2020-01-24 北京中电拓方科技股份有限公司 Data processing method of Internet of things based on block chain, Internet of things and storage medium
WO2020035088A2 (en) * 2019-11-06 2020-02-20 Alipay (Hangzhou) Information Technology Co., Ltd. Prioritizing shared blockchain data storage

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
一种基于区块链的分布式公钥管理方案研究;刘敬浩;平鉴川;付晓梅;;信息网络安全(第08期);全文 *

Also Published As

Publication number Publication date
CN111339089A (en) 2020-06-26

Similar Documents

Publication Publication Date Title
CN112003703B (en) Method and device for transmitting authenticatable message across chains
EP3678346B1 (en) Blockchain smart contract verification method and apparatus, and storage medium
WO2020258848A1 (en) Method and apparatus for cross-chain transmission of resources
US11347726B2 (en) Cross-chain transaction method and apparatus
CN110866825B (en) Public link-based block chain information storage method and system
EP3816910B1 (en) Blockchain-based transaction processing method and apparatus, and electronic device
TWI734088B (en) Block chain-based transaction processing method and device, and electronic equipment
CN106453415B (en) Block chain-based equipment authentication method, authentication server and user equipment
TWI737977B (en) Block chain-based transaction processing method and device, and electronic equipment
WO2020258847A1 (en) Method and apparatus for cross-chain transmission of authenticable message based on processing module
US10742415B2 (en) Method and apparatus for inter-blockchain transmission of authenticable message
CN112153085A (en) Data processing method, node and block chain system
US11250395B2 (en) Blockchain-based transaction processing methods and apparatuses and electronic devices
US20230275771A1 (en) Pre-execution of block chain transaction in parallel during block consensus
CN111144883A (en) Processing performance analysis method and device for block chain network
CN110599166A (en) Method and device for acquiring transaction dependency relationship in block chain
WO2020258849A1 (en) Method and apparatus for sending authenticable message in cross-chain manner
CN114726517A (en) Method, system and consensus node for generating random number seeds on block chain
CN112596801B (en) Transaction processing method, device, equipment, storage medium and database
CN116308344A (en) Transaction data authentication consensus method and system based on blockchain
CN111339089B (en) Data storage and acquisition method and device applied to blockchain
WO2024041505A1 (en) Data acquisition method and apparatus, and device
CN110928923A (en) Data storage method and system based on block chain
CN111383008B (en) Block chain transfer method and device based on account model
CN113157451A (en) Method and apparatus for performing blocks in a blockchain system

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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: Room 501, 5 / F, block B, No. 28, Xinjiekou Wai Street, Xicheng District, Beijing 100032

Applicant after: Joint digital technology (Beijing) Co.,Ltd.

Address before: Room 501, 5 / F, block B, No. 28, Xinjiekou Wai Street, Xicheng District, Beijing 100032

Applicant before: Linkage advantage (Beijing) Digital Technology Co.,Ltd.

TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20220119

Address after: 100082 7th floor, block a, Jingshi science and technology building, 12 Xueyuan South Road, Haidian District, Beijing

Applicant after: UNION MOBILE PAY Co.,Ltd.

Address before: Room 501, 5 / F, block B, No. 28, Xinjiekou Wai Street, Xicheng District, Beijing 100032

Applicant before: Joint digital technology (Beijing) Co.,Ltd.

GR01 Patent grant
GR01 Patent grant