CN112035491A - Data storage method based on block chain, electronic integral processing method and system - Google Patents

Data storage method based on block chain, electronic integral processing method and system Download PDF

Info

Publication number
CN112035491A
CN112035491A CN202011064472.5A CN202011064472A CN112035491A CN 112035491 A CN112035491 A CN 112035491A CN 202011064472 A CN202011064472 A CN 202011064472A CN 112035491 A CN112035491 A CN 112035491A
Authority
CN
China
Prior art keywords
data
tree
node
nodes
electronic
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.)
Granted
Application number
CN202011064472.5A
Other languages
Chinese (zh)
Other versions
CN112035491B (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.)
Guangzhou Yiliantong Internet Technology Co ltd
Original Assignee
National Sun Yat Sen University
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 National Sun Yat Sen University filed Critical National Sun Yat Sen University
Priority to CN202011064472.5A priority Critical patent/CN112035491B/en
Publication of CN112035491A publication Critical patent/CN112035491A/en
Application granted granted Critical
Publication of CN112035491B publication Critical patent/CN112035491B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/2282Tablespace storage structures; 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/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • 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

Abstract

The invention provides a data storage method, an electronic integral processing method and a system of a block chain, wherein the method comprises the following steps: acquiring data of a relational data table in a block chain system, and storing primary key values corresponding to the data in leaf nodes of a tree data structure; wherein, the leaf nodes are connected into an ordered single linked list through a directed single linked list; calculating the hash value of the data according to the data item value of the data corresponding to the leaf node; storing the hash values of the child nodes and the division values of two adjacent child nodes in non-leaf nodes of the tree-shaped data structure, and calculating the hash values of the non-leaf nodes; and repeating the steps until the primary key values of all the data in the data table are stored in the leaf nodes of the tree data structure, and taking the hash value of the root node of the tree data structure as the hash certification of the relational data table. The electronic integral system provided by the invention not only realizes relational data storage, but also supports history backtracking and history backspacing, and is more transparent and public.

Description

Data storage method based on block chain, electronic integral processing method and system
Technical Field
The invention relates to the technical field of block chains, in particular to a data storage method, an electronic integral processing method and an electronic integral processing system based on a block chain.
Background
With the rise of blockchain technologies, more and more merchants and government departments select blockchain intelligent contracts as platforms of decentralized electronic scoring systems, so as to show users fair, transparent, public and decentralized user scoring platforms. In the process, the intelligent contract of the electronic scoring system inevitably adds, deletes, modifies, queries and the like to the business data stored on the block chain. Meanwhile, due to the particularity of the business logic of the electronic score system, the storage of the intelligent score contract usually needs to adopt data storage based on a relational type, so as to ensure that large-scale operation on batch score users is realized in logics of issuing scores, using scores and the like.
The existing database system using a block chain platform adopts an independent decoupling mode to provide distributed decentralized relational data storage for other block chains. However, these products are not actual blockchain systems, but rather are relatively independent database systems. Although the design of this architecture can decouple the storage logic and business flow of the blockchain system, the security of the whole system will present a short-board principle. Moreover, these products are also only capable of historical hashes and do not implement an effective historical rollback functionality. The blockchain system using these products also loses the ability to perform historical fallback, branch switching, etc., and can only be used in limited ways in certain environments.
In the existing block chain system, data of an intelligent contract can only be stored in a Key-Value storage object, but an effective method is lacked to realize relational data storage.
Disclosure of Invention
The invention aims to provide a data storage method, an electronic integral processing method and a system based on a block chain, and aims to solve the technical problems that effective storage of relational data is difficult to realize, and history backtracking and history rollback are difficult to perform on an electronic integral system.
The purpose of the invention can be realized by the following technical scheme:
a method of data storage for a blockchain, comprising:
s1: acquiring data of a relational data table in a block chain system, and storing primary key values corresponding to the data in leaf nodes of a tree data structure; the leaf nodes are connected into an ordered single linked list through a directed single linked list;
s2: calculating the hash value of the leaf node according to the data item value of the data corresponding to the leaf node;
s3: storing the hash values of the child nodes and the division values of two adjacent child nodes in non-leaf nodes of the tree-shaped data structure; the partitioning values of the two adjacent child nodes are greater than the maximum value of leaf nodes in a subtree taking the left child node as a root node and less than or equal to the minimum value of leaf nodes in a subtree taking the right child node as a root node; the number of child nodes of each non-leaf node is not less than N/2 and less than N, wherein N is the maximum value of the number of child nodes of the non-leaf nodes in the tree data structure;
s4: calculating the hash value of the non-leaf node according to the hash value of the child node and the division values of two adjacent child nodes;
repeating the steps of S1-S4 until the primary key values of all data in the data table are stored in the leaf nodes of the tree data structure, and the hash value of the root node of the tree data structure is used as the hash proof of the relational data table.
Preferably, the primary key values of the leaf nodes in the ordered singly-linked list are arranged from small to large.
Preferably, the specific process of storing the primary key value corresponding to the data in the leaf node of the tree data structure is as follows:
finding a corresponding position in the ordered linked list according to the primary key value corresponding to the data, generating a new leaf node, and storing the primary key value of the new data into the new leaf node;
updating father nodes of the leaf nodes, splitting the father nodes into two new non-leaf nodes when the number of child nodes of the father nodes is equal to N, and updating the father nodes of the non-leaf nodes and hash values of the father nodes; wherein the number of child nodes of each new non-leaf node is N/2;
and checking non-leaf nodes upwards layer by layer and updating the hash value until the root node and the hash value of the tree-shaped data structure are determined.
Preferably, after deleting a data of the data table, updating the corresponding tree data structure, and the specific process is as follows:
finding out corresponding leaf nodes in the tree data structure according to the primary key values of the deleted data and deleting the leaf nodes;
updating the father node of the leaf node and the hash value of the father node, and when the number of the child nodes of the father node is less than N/2, adjusting the father node so that the number of the child nodes is not less than N/2 and less than N;
and checking non-leaf nodes upwards layer by layer and updating the hash value until the root node and the hash value of the tree-shaped data structure are determined.
Preferably, when the number of child nodes of the non-leaf node is less than N/2, the specific process of maintaining the non-leaf node so that the number of child nodes thereof is not less than N/2 and less than N is as follows:
judging whether the number of child nodes of adjacent brother nodes of the non-leaf node is larger than N/2, if so, moving one child node of the adjacent brother nodes as a child node of the non-leaf node, and updating a parent node of the non-leaf node; if not, combining the non-leaf node and the adjacent brother node, and updating the father node of the non-leaf node.
The invention also provides an electronic integral processing method based on the block chain, which applies the data storage method of the block chain to store a relational data table of an electronic integral system and comprises the following steps:
taking out a service code of the intelligent contract from an intelligent contract account of the electronic scoring system, and constructing an intelligent contract calling transaction; the service code comprises an electronic point processing function for adding, deleting, modifying and inquiring the electronic point;
executing the intelligent contract calling transaction on an intelligent contract virtual machine, calling an intelligent contract and executing a service code of the intelligent contract;
the executor analyzes a data operation statement corresponding to the service code and performs data operation on a relational data table of the electronic score system;
and when the data operation changes the data of the data table, updating the tree-shaped data structure corresponding to the data table, and regenerating the hash certification of the data table.
Preferably, the method further comprises the following steps: the relational data sheet of the electronic score system comprises a user data sheet and a score data sheet, and the user data sheet, the score data sheet and a corresponding tree-shaped data structure are stored in a magnetic disc by taking a page as a unit.
Preferably, the method further comprises history backtracking of the electronic integration, and the specific process is as follows:
finding a historical state needing backtracking, and searching and recovering a point data table and a corresponding tree-shaped data structure in the current historical state layer by layer from a root node of the historical state; and searching to obtain a required historical integral data item according to the integral data table in the historical state and the corresponding tree-shaped data structure.
Preferably, the method further comprises the step of performing historical backspacing on the erroneously modified electronic score, and the specific process is as follows:
finding a historical state needing to be backed, and recovering a point data table and a corresponding tree-shaped data structure in the current historical state layer by layer from a root node of the historical state; and checking and repairing the ordered linked list of the leaf nodes of the tree-like data structure, and reestablishing a correct ordered linked list.
The invention also provides an electronic integration system based on the block chain, which applies the electronic integration processing method and comprises the following steps:
the initialization module is used for taking out a service code of the intelligent contract from an intelligent contract account of the electronic scoring system and constructing an intelligent contract calling transaction; the service code comprises an electronic point processing function for adding, deleting, modifying and inquiring the electronic point;
the intelligent contract calling module executes the intelligent contract calling transaction on the intelligent contract virtual machine, calls the intelligent contract and executes the service code of the intelligent contract;
the data operation execution module is used for analyzing a data operation statement corresponding to the service code by the executor and carrying out data operation on a relational data table of the electronic score system;
and the tree data structure updating module is used for updating the tree data structure corresponding to the data table and regenerating the hash certification of the data table when the data operation changes the data of the data table.
The invention provides a data storage method, an electronic integral processing method and a system of a block chain, wherein the method comprises the following steps: s1: acquiring data of a relational data table in a block chain system, and storing primary key values corresponding to the data in leaf nodes of a tree data structure; the leaf nodes are connected into an ordered single linked list through a directed single linked list; s2: calculating the hash value of the leaf node according to the data item value of the data corresponding to the leaf node; s3: storing the hash values of the child nodes and the division values of two adjacent child nodes in non-leaf nodes of the tree-shaped data structure; the partitioning values of the two adjacent child nodes are greater than the maximum value of leaf nodes in a subtree taking the left child node as a root node and less than or equal to the minimum value of leaf nodes in a subtree taking the right child node as a root node; the number of child nodes of each non-leaf node is not less than N/2 and less than N, wherein N is the maximum value of the number of child nodes of the non-leaf nodes in the tree data structure; s4: calculating the hash value of the non-leaf node according to the hash value of the child node and the division values of two adjacent child nodes; repeating the steps of S1-S4 until the primary key values of all data in the data table are stored in the leaf nodes of the tree data structure, and the hash value of the root node of the tree data structure is used as the hash proof of the relational data table.
The block chain-based data storage method, the electronic integral processing method and the system provided by the invention have the following beneficial effects that: the electronic score system provided by the invention realizes the functions of history backtracking and history backspacing while realizing the requirement of block chain platform relational data storage, is more transparent and public, can simultaneously meet the supervision requirement of a user on a merchant and the requirement of the merchant on error operation recovery, realizes the effective supervision of the user on the merchant, and ensures certain error recovery capability of the electronic score system.
Drawings
FIG. 1 is a schematic method flow diagram of a block chain-based data storage method, an electronic integral processing method and system according to the present invention;
FIG. 2 is a schematic diagram of a first embodiment of a block chain-based data storage method, an electronic score processing method and system according to the present invention;
FIG. 3 is a diagram of a block chain-based data storage method, an electronic score processing method and system according to a second embodiment of the present invention;
FIG. 4 is a schematic diagram of data in a data table maintained by a tree data structure according to the block chain-based data storage method, electronic score processing method and system of the present invention;
FIG. 5 is a schematic diagram illustrating hash calculation performed on a data table by the data storage method, the electronic integral processing method, and the system based on the blockchain according to the present invention;
FIG. 6 is a schematic diagram of a block chain-based data storage method, an electronic integral processing method and a system for storing a data table and a tree data structure in a disk according to the present invention;
FIG. 7 is a schematic diagram of a block chain-based data storage method, an electronic integral processing method and a system for storing a data table in a KEY-VALUE according to the present invention;
FIG. 8 is a schematic diagram of historical backtracking of electronic integrals by the block chain-based data storage method, electronic integral processing method and system according to the present invention;
fig. 9 is a schematic diagram of historical rollback of electronic integrals by the block chain-based data storage method, the electronic integral processing method, and the system of the present invention.
Detailed Description
Interpretation of terms:
block chains: the block chain is realized by using a cryptography technology, and is a unidirectional chain data structure formed by a plurality of data blocks in a time sequence in a unidirectional connection mode. Distributed ledger technology that uses a data structure of blockchains to achieve crypto-assurance-based non-falsification and falsification is referred to as blockchain technology, sometimes also referred to simply as blockchain. As a brand-new distributed computing system, the blockchain technology innovatively uses a chained data structure of blocks and blockchains to realize the storage, update and verification of system states and data, meanwhile, the consistency of data authentication and change is achieved among distributed peer nodes through a smart consensus algorithm, and the robustness and safety of the states in the whole system are guaranteed by using the principle of cryptography. In addition, by utilizing intelligent contracts composed of automated script codes, the block chain can also realize programmable data operation and state change, and can adapt to complex and variable actual scenes.
Intelligent contract: an intelligent contract refers to some piece of executable code that runs on a blockchain system, depends on the blockchain environment, and operates on data and blockchain state on the blockchain. The results of the intelligent contract execution are recorded onto the blocks through the blockchain system, and a non-tampering and verifiable execution consensus is achieved among all the participating nodes. The intelligent contract expands the semantics of the block chain, endows the block chain with the programmable capability, and is a bridge between a block chain system and the actual application requirement.
Relational database system: a database is a computer system for data management, which organizes and stores specific user data in a certain way and provides an interface for users to query and update data. The relational database is a database system established on a relational model and a relational algebra, describes data entities stored in the system and relations among the entities by using a set algebra, and provides a data operation interface based on relational operation. The method for expressing the entity and the relation by using the relational model in the relational database system has certain abstract capability, and can realize more complex query semantics in service use compared with a non-relational database.
Merkel tree: the Mercker tree is a tree-shaped data structure, and can realize the efficient hash calculation and verification process for verifying a large-scale data structure. In the merkel tree, each leaf is a hash value for a particular data block, and the hash value of a non-leaf node is calculated from the hash values of its child nodes. In this way, as long as the data corresponding to one leaf node is changed, the hash value of the corresponding leaf node is also changed, and the calculated hash value of the parent node corresponding to the leaf node is also changed, so that the hash value of the final tree root is also changed.
B tree, B + tree: b-trees and B + trees are tree-like data structures that are typically used for indexing data in a database. The number of children of the nodes of the B-tree and the B + tree can only be in the range of N/2 to N, where N is called the rank, is a fixed attribute value of the B-tree or B + tree, and in practice may be of the order of 100 or more. Because the number of child nodes of the B tree and the B + tree has the minimum lower limit, compared with structures such as a binary tree and the like, the height of the whole index tree can be effectively controlled, so that the node reading times in the searching process are reduced, and the method is more friendly to mechanical hard disks with slower reading and writing. The data to be indexed in the B tree is stored in both the non-leaf nodes and the leaf nodes, which is not beneficial to the continuous reading and writing of the disk, and the data in the B + tree are all stored in the leaf nodes and all the data are connected by using an ordered linked list form, thereby further increasing the performance of the index.
Hash B + tree:
the Hash B + tree is a brand-new data structure based on a B + tree structure, and aiming at the characteristics of a block chain platform, a part of principles of a Mercker tree are combined on the basis of the B + tree, a Hash calculation method is defined on each node, so that the Hash calculation and verification process for verifying a large-scale data structure efficiently can be realized while data indexing is carried out.
The embodiment of the invention provides a data storage method based on a block chain, an electronic integral processing method and a system, which aim to solve the technical problems that effective storage of relational data is difficult to realize, and history backtracking and history rollback are difficult to perform on an electronic integral system.
To facilitate an understanding of the invention, the invention will now be described more fully with reference to the accompanying drawings. Preferred embodiments of the present invention are shown in the drawings. This invention may, however, be embodied in many different forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used herein, the term "and/or" includes any and all combinations of one or more of the associated listed items.
Since Nakamoto Satoshi proposed decentralizing digital currency Bitcoin (Bitcoin), blockchain technology has received attention from many developers and investors by virtue of its decentralizing, tamper-resistant, and strong trust properties. After that, vitaik Buterin et al, in etherhouse (Ethereum), proposed that a computer program with graphics-complete functionality could be executed using block-chain techniques, thereby implementing more complex business logic on the block-chain. Such programs executing on the blockchain are referred to as intelligent contracts. Due to its good programmability, decentralization and tamper resistance, the blockchain technology is receiving much attention and is considered as an important basic technology of a new technological revolution and industrial revolution. Through the preset intelligent contract logic, the block chain technology can ensure that the stored data is not tampered, realize the traceability of the data and simultaneously realize the value transfer or other business logics on the premise of not establishing a trust relationship in advance.
With the rise of blockchain technologies, more and more merchants and government departments select blockchain intelligent contracts as platforms of decentralized electronic scoring systems, so as to show users fair, transparent, public and decentralized user scoring platforms. In the process, the intelligent contract of the electronic scoring system inevitably adds, deletes, modifies, queries and the like to the business data stored on the block chain. Meanwhile, due to the particularity of the business logic of the electronic score system, the storage of the intelligent score contract usually needs to adopt data storage based on a relational type, so as to ensure that large-scale operation on batch score users is realized in logics of issuing scores, using scores and the like.
In many existing blockchain systems, such as etherhouses and hyperridge fabrics, a non-relational Key-Value storage manner is used for storing data. Although the non-relational storage has high performance, the non-relational storage cannot process more complex data relations and data structures, and batch and structured data operation based on the data relations is realized. Under the requirement of structured query, intelligent contract items like UnorderedKeySet, SetType, EthAir balloon and the like are born on the EtherFang platform. EthAir Balloons aims to provide an ORM query binding stored in etherhouses, while unorderedkey set and SetType are operational interfaces that provide a simple data model. The items provide a certain degree of structural operation functions by converting operations such as adding, deleting, modifying, inquiring and the like into a series of operations on a Key-Value storage model. However, this process consumes a large amount of conversion operations, which is a huge drawback for the Etherhouse intelligent contracts that use gas as the execution cost. At the same time, such a conversion cannot provide very complex operation logic and cannot meet complex business requirements.
On the other hand, in a federation chain scenario, some blockchain systems, such as FISCO-BCOS, attempt to introduce structured queries and relational databases directly into the blockchain system. However, no better scheme is available for performing hash calculation on the relational data tables stored in the intelligent contract, and when the contract state is hashed in block calculation, the whole data table is often required to be scanned and hash calculated, which is a small overhead for both the intelligent contract execution and the blockchain system. Meanwhile, due to the fact that a proper data structure is not available, the relational data storage does not have a history rollback function, and only history HashExample evidence can be achieved, and therefore the block chain system cannot be branched and switched. It can be said that this scheme sacrifices certain security to implement the function of query, and is more suitable for a federation chain rather than a public chain.
In addition, there are database systems such as bigchain db, OurSQL, etc. that use blockchain platforms that employ independent decoupling to provide distributed decentralized relational data storage for other blockchains. However, these products are not practical blockchain systems, but rather are relatively independent database systems. Although the design of this architecture can decouple the storage logic and business flow of the blockchain system, the security of the whole system will present a short-board principle. Moreover, these products are also only capable of historical hashes and do not implement an effective historical rollback functionality. The blockchain system using these products also loses the ability to perform historical fallback, branch switching, etc., and can only be used in limited ways in certain environments.
For the block chain intelligent contract decentralized electronic scoring system based on relational storage, which is to be realized by the invention, the capabilities of history backtracking and history rollback are indispensable. On one hand, for a participant (user) of the system, functions of effectively monitoring issuing, using, destroying and the like of points are needed, so that the points system is effectively monitored to maintain the legal rights and interests of the user in the system, and the storage history of the intelligent electronic points contract is needed to be effectively traced; on the other hand, for the maintainer (merchant, credit issuer) of the system, it needs to provide a certain historical backspace capability to ensure that the electronic credit system is attacked maliciously,
The existing blockchain system does not directly perform hash calculation on a large number of objects, but implements the hash calculation through a hash tree, namely a merkel tree. Due to the excellent characteristics of quick recalculation, historical rollback and the like, the hash data structure and the subsequent variant structure thereof are widely applied to the blockchain system. In the design of a relational database system, the index of data is usually maintained by using a tree-like data structure, such as a B tree and a B + tree as the index structure of data items. By utilizing the principles of indexes of the data tables and the Hash tree, the huge expense generated by directly scanning the data tables and carrying out Hash calculation can be well solved, and the defect that only Hash memory can be carried out but history backspacing cannot be avoided at the same time, and on the basis, a decentralized electronic integral system on a block chain intelligent contract platform with history backtracking and history backspacing capabilities is constructed.
The embodiment of the invention provides a data storage method of a block chain, an electronic integral processing method based on the block chain and an electronic integral system. In order to make the objects, technical solutions and advantages of the present invention more apparent, the following detailed description is further made with reference to the accompanying drawings.
Referring to fig. 5, the following is an embodiment of a data storage method for a block chain according to the present invention, including:
s101: acquiring data of a relational data table in a block chain system, and storing primary key values corresponding to the data in leaf nodes of a tree data structure; the leaf nodes are connected into an ordered single linked list through a directed single linked list;
s102: calculating the hash value of the leaf node according to the data item value of the data corresponding to the leaf node;
s103: storing the hash values of the child nodes and the division values of two adjacent child nodes in non-leaf nodes of the tree-shaped data structure; the partitioning values of the two adjacent child nodes are greater than the maximum value of leaf nodes in a subtree taking the left child node as a root node and less than or equal to the minimum value of leaf nodes in a subtree taking the right child node as a root node; the number of child nodes of each non-leaf node is not less than N/2 and less than N, wherein N is the maximum value of the number of child nodes of the non-leaf nodes in the tree data structure;
s104: calculating the hash value of the non-leaf node according to the hash value of the child node and the division values of two adjacent child nodes;
and repeatedly executing S103 and S104 until the primary key values of all the data in the data table are stored in the leaf nodes of the tree data structure, and taking the hash value of the root node of the tree data structure as the hash certification of the relational data table.
In the existing block chain system, data of an intelligent contract can only be stored in a Key-Value storage object, but an effective method is lacked to realize relational data storage. According to the data storage method of the block chain, provided by the embodiment of the invention, the hash B + tree is used as an index item for the main key of the relational data table, and hash certification of all data items of the data table is completed while the index is constructed and maintained.
Referring to fig. 4, the following details are provided for maintaining the relational data table through the hash B + tree:
1. metadata table maintenance. For all data tables of the intelligent contract, some basic information of the data tables needs to be maintained through one metadata table, including addresses of the tables, structures of the tables and other key information for maintaining the data tables. In the intelligent contract execution process, the relational data operation executor can use a metadata table to construct a logic for data operation of a contract, and when the upper layer subsystem transmits a data operation SQL statement, corresponding data query and operation actions are generated by using information such as columns and data types in the metadata table and are applied to stored relational data. For example, in the process of checking and canceling electronic points, the execution engine queries metadata of the point table through the deleted SQL statement, analyzes the metadata to obtain index information and column information in the point table, and finally generates a specific data execution operation plan. The metadata table stores hash certificates of the user data table and the integral data table, and information such as a column and a data type of the corresponding table.
2. And maintaining a data table index. The user data table and the point data table of the intelligent contract electronic point system are provided with corresponding main keys. The main key in the user table is the user address, namely the unique identification of the user; in the point table, the primary key is the point ID, which is a unique identifier generated when the merchant creates the points. The primary key of the data table will use the hash B + tree as an index entry and complete the hash attestation of all data entries of the data table while building and maintaining the index.
3. Hash attestation of the user data table and the integral data table. The hash attestation stored for the user data table and the integral data table is computed over a hash B + tree. The hash value of the leaf node is the hash value of the data item, the hash value of < user address, name, alias > is in the user table, and the hash value of < integral ID, user address, value > is in the integral table. Then, for the hash value of the non-leaf node, the hash is calculated by the hash values and the separation values of all the child nodes. Finally, the hash value of the root node represents the corresponding hash attestation of the indexed data table.
Referring to fig. 5, the electronic integral system data table (for example, the user table) is hash-calculated and indexed, the hash B + tree may represent the range of the index by separating the value and the sub-tree, and the hash of the whole data table is obtained by hierarchical hash calculation. The method specifically comprises the following steps:
1. the hash value of the data item corresponding to the leaf node is used. The data item corresponding to the leaf node a is <0x01, a >, so the hash value of the leaf node a is:
Ha=Hash(<0x01, Jia, Ayi>)
The hash value of the leaf node B, C is calculated in the same manner.
2. The hash value of the non-leaf node may be calculated using the child nodes and the internal partition values. The hash value of a parent node, such as leaf node A, B, C, is:
H=Hash(Ha,0x02,Hb,0x03,Hc,0x04)
3. and searching the corresponding user in the user table through the Hash B + tree. For the user needing to search, such as the user 0x03, it can be known from the separation value of the node that the user 0x03 is necessarily under the node with the hash value H, and the address range of all leaf nodes is [0x01,0x04 ]. Searching in this way, the data items of user 0x03 can be finally obtained and operated on.
Referring to fig. 6, the electronic point system point data table and the hash B + tree index are stored in the disk, and the user data table and the point data table of the electronic point system can be stored in the mechanical disk in a page management manner, and the main details are:
1. the data item < integral ID, user address, value > of the integral table and the corresponding index node are stored in the disk in page units, each page is a continuous storage data block with fixed length, and a plurality of data items of the integral table and the corresponding index nodes can be arranged inside the page.
2. The data in the disk uses the page number, the deviant and the length as a searching mode on the disk, and a corresponding index node or a data item of the score table, such as the score ID, the user address and the value, can be obtained through the disk pointer.
3. After the < integral ID, user address, value > data item or index node in the disk is loaded to the memory, the hash B + tree node cached in the memory will be looked up and used by the memory pointer (address).
Referring to fig. 1, the following is a block chain-based electronic integral processing method, in which the block chain-based data storage method is applied to store a relational data table of an electronic integral system, and the method includes:
taking out a service code of the intelligent contract from an intelligent contract account of the electronic scoring system, and constructing an intelligent contract calling transaction; the service code comprises an electronic point processing function for adding, deleting, modifying and inquiring the electronic point;
executing the intelligent contract calling transaction on an intelligent contract virtual machine, calling an intelligent contract and executing a service code of the intelligent contract;
the executor analyzes a data operation statement corresponding to the service code and performs data operation on a relational data table of the electronic score system;
and when the data operation changes the data of the data table, updating the tree-shaped data structure corresponding to the data table, and regenerating the hash certification of the data table.
Referring to fig. 1, taking a business process of a merchant verifying and selling electronic points of a user as an example, an operation process of the electronic point system is specifically described as follows:
1. the code is fetched. The business logic of the electronic score system is realized through an intelligent contract platform, and the business code is stored in an account of the intelligent contract of the electronic score system. When a merchant checks and sells the electronic points of a user, a corresponding transaction called by an intelligent contract needs to be constructed, wherein the transaction called by the intelligent contract for calling a function of checking and selling the electronic points is constructed. Before executing transaction, the blockchain platform will first extract the corresponding business logic code from the intelligent contract account number of the electronic scoring system for execution of subsequent call.
2. The code is executed. By executing intelligent contract function transaction which is constructed by a merchant and calls the electronic points for verification and cancellation, the electronic points intelligent contract can be driven and the operation of verifying and canceling the electronic points can be completed. In this step, the electronic integral to be checked and the user identification corresponding to the integral are transmitted to the checking and canceling electronic integral function of the intelligent integral contract in the form of parameters, and the execution of the calling function code is completed on the intelligent contract virtual machine.
3. And calling a relational data operation interface. In the business logic for checking and canceling the electronic points, the deleting operation of the specific electronic point data item of the underlying point data table is completed by means of contract calling. In this step, the data operation is generated into an SQL statement and a built-in relational data operation function of the virtual machine is called.
4. The data is parsed and manipulated. The SQL statement of the deletion operation on a specific electronic score data item of the score table is transmitted to the corresponding SQL parser, and is interpreted as a deletion operation on a certain data item of the score data table and finally an operation on the data item of the score data table of the electronic score system, and the electronic score is checked and cancelled.
5. The contract storage certificate is updated. After the electronic integral data item is deleted, the index item needs to be maintained again to ensure the correctness of the index of the integral table. In the structure of the hash B + tree, the number of children of the index node must be between N/2 and N, where N is the order of the hash B + tree. After the integral data item is deleted, the number of child nodes of the parent node of the indexing item may be less than N/2, the structural requirement of the hash B + tree cannot be met, and a child node needs to be moved from the sibling node of the current node to the current child node. And finally, after the structure of the Hash B + tree of the integral table index is ensured to be correct, according to a detailed calculation mode in the attached figure 5, recalculating the integral table Hash after data is modified by the Hash B + tree of the integral table, and completing the whole business process of the electronic integral of the credit user of the merchant. Due to the calculation characteristic of the Hash B + tree, the Hash proof of the integral table is recalculated only by calculating the changed integral data item and the Hash value of the node modified in the Hash B + tree maintenance process.
Referring to fig. 2, fig. 2 is an illustration of the operation of the system by a user in the electronic integral system, which mainly includes the following operations:
1. an electron integral is obtained. The user can acquire the electronic points distributed by the merchant through the electronic point system. After the merchant distributes the electronic points, the user needs to call an intelligent contract of the electronic point system to complete ownership confirmation of the electronic points, and finally address association of the user is added to the electronic points on the point data sheet.
2. Consumer electronics integration. When the user uses the electronic points, the consumption of the corresponding electronic points is marked by calling the intelligent contract of the electronic points system, and after the merchant confirms the verification, the electronic points are destroyed and the association with the address of the user is cancelled.
3. And monitoring the behavior of the merchant by backtracking the history of the system. The user can realize backtracking of the historical state of the system through the intelligent contract platform of the electronic score system and inquire the score state at any historical moment, so that complete transparency of the behavior of merchants and the user is ensured.
It is worth noting that contracts refer to code, and contract accounts are data of contracts, which can be analogized to code and databases in web services. The integration contracts in fig. 2 and 3 refer to invocation contracts.
Referring to fig. 3, fig. 3 is a diagram illustrating the operation of the electronic points system by the merchant, which mainly includes the following operations:
1. an electronic credit is issued. The merchant can create and issue electronic points, and the issued electronic points are in a state to be picked up and wait for the user to pick up.
2. And (6) checking and canceling electron integration. After the user uses the electronic credit, the electronic credit will be in a state of being checked and sold, and the merchant needs to complete the whole using process of the electronic credit of the user through the checking and selling operation.
3. Recovery of failures and errors is achieved by rolling back the system history. When the system is abnormally operated by mistake, attacked and the like, the merchant can reset the system to a specific historical state in a history returning mode.
Referring to fig. 1, the following is an embodiment of an electron integration system based on a block chain, to which the electron integration processing method is applied, including:
the initialization module is used for taking out a service code of the intelligent contract from an intelligent contract account of the electronic scoring system and constructing an intelligent contract calling transaction; the service code comprises an electronic point processing function for adding, deleting, modifying and inquiring the electronic point;
the intelligent contract calling module executes the intelligent contract calling transaction on the intelligent contract virtual machine, calls the intelligent contract and executes the service code of the intelligent contract;
the data operation execution module is used for analyzing a data operation statement corresponding to the service code by the executor and carrying out data operation on a relational data table of the electronic score system;
and the tree data structure updating module is used for updating the tree data structure corresponding to the data table and regenerating the hash certification of the data table when the data operation changes the data of the data table.
In the embodiment, a brand-new hash data structure hash B + tree is designed as an index item of a data table by combining tree hash calculation and the B + tree, so that a block chain intelligent contract electronic score system supporting relational data storage and having a historical backspacing capability is constructed.
Specifically, in order to realize the relational data storage and business requirements required by the electronic score system provided in this embodiment, the requirements of data storage, indexing, hash calculation of data, support of a history rollback function, and the like need to be solved, and the electronic score system provided in this embodiment has the following functions:
1. the business logic for realizing the score system is as follows:
the block chain intelligent contract electronic scoring system supporting the relational data storage has the following business logic requirements:
(1) the merchant can issue electronic points to all users or specific users through the intelligent contract of the electronic point system, and each issued electronic point is a minimum unit and cannot be divided.
(2) The merchant can check and sell the points when the user uses the points, and destroy the electronic points held by the user by calling the corresponding electronic point intelligent contract.
(3) The merchant can drive the block chain system to return to the historical state before the error occurs in a historical return mode, so that the data storage in the electronic scoring system returns to a specific history.
(4) The user can receive the electronic points issued by the merchant through the electronic points intelligent contract, and the electronic points in the points data table are associated with the user identities in the corresponding user data table.
(5) The user can exchange and use the electronic points held by the user to the merchant through the electronic point intelligent contract, and finally, the merchant finishes the destruction work of the electronic points corresponding to the user.
(6) The user can realize specific history backtracking through the block chain platform of the electronic scoring system, so that the history information and storage of individuals and merchants are inquired, and the monitoring function of the merchants is realized.
2. Establishing indexes of a user of the point system and a point data table:
in order to realize the maintenance and query work of the relational data, proper data index items are required to be established for all data items of the user and the integral data table. On a part of existing intelligent contract platforms supporting relational data storage, indexes of data items are realized through a relational data engine of a third party, and data structures using a B tree, a B + tree or a hash table and the like as indexes are used in the bottom layer, so that block chains and the characteristics of tamper resistance and traceability of an intelligent contract cannot be well matched.
3. The method supports the Hash calculation of a user table and a score table of a score system:
due to the characteristics of the blockchain system, the intelligent contract based on the state change must be able to generate a certain state change after each transaction is executed, and the result of the state change is saved into the block through a certain hash digest process, and finally, the state change is agreed between all the participants of the blockchain, and the digest is hashed into an untamperable historical result. Therefore, the intelligent contract electronic score system based on the relational data storage is realized, and effective Hash memory verification of a user data table and a score data table maintained in the electronic score system is required.
4. And realizing the storage of user table and score table data:
the maintenance and storage of user and point data tables are also an important requirement for realizing the intelligent contract electronic point system. The user of the intelligent contract electronic score system, the score data table and the Hash B + tree index corresponding to the data table must be effectively stored, and persistent storage is achieved.
5. The history backtracking of the user on the data of the electronic score system is supported:
historical backtracking is an important attribute of blockchain systems. Through history backtracking, a user of the system can check and view the system state data at a specific historical time, and even can track the historical change information of the specific data. In the electronic score system without centralization, a user can check past historical data of the score system in a historical backtracking mode to supervise data operation and behavior of a merchant on the score system, so that the more transparent score system is realized. In the backtracking process, the current storage state of the electronic score system cannot be changed, and a user can only read the historical storage state.
6. The history backtracking of the user on the data of the electronic score system is supported:
by rollback, the current state of the system may be reset to the system state at a particular historical time. When a bifurcation occurs in the blockchain system, a part of nodes must perform bifurcation switching, which requires the nodes to abandon state changes after the start of the bifurcated block, fall back to the historical state before the bifurcation and apply transaction and state changes of the block on the new bifurcation. Currently, both intelligent contract platforms and systems supporting relational data operation do not have the capability of historical backtracking and rollback, can only search and use the latest data, and cannot support the rollback. In the decentralized electronic integral system, historical rollback support for a user and an integral data table of the integral system needs to be realized, so that integral data and user data of the system can be rolled back to a specific safe historical state and can be restarted to be executed when the system fails or is forked.
In the embodiment, a brand-new Hash B + tree is used as an index structure of the relational data, so that the relational data with historical backtracking and historical backspacing capabilities can be stored and proved while the operation support of the intelligent contract on the relational data is realized. The system is designed to effectively solve the problems, and has the following advantages:
1. indexing the user and point data tables of this patent system through a Hash B + Tree
In the scheme of the patent, a brand-new B + tree structure variant, namely a Hash B + tree, is adopted as an index structure of a user and a point data table, and the Hash structure of the tree can perform hierarchical Hash calculation and can better meet the requirement of performing high Hash calculation on data in a block chain system. The new index is similar to a B + tree in structure, has the characteristics of high fan-out of the B + tree structure and disk IO friendliness, can effectively ensure the read-write performance of the score system on a user and a score data table, and can better meet the application scenes of a block chain system and an intelligent contract system compared with the traditional B tree and the traditional B + tree.
2. Efficient hash certification based on tree hierarchy for users and point data table of electronic point system
In the scheme, similar to the hierarchical hash calculation process of the Merkle tree, the hash value of the user data table or the integral data table of the electronic integral system can be subjected to hierarchical hash calculation through the index structure of the hash B + tree, the hash value of the current node is calculated through the child node of each node, and finally, one hash value of all data is obtained through calculation, namely one hash value of all data is obtained
Hash(Node)=Hash(Hash(Child1)+sep1+…+sepn-1+Hash(Childn))
Wherein, Child1...ChildnChild is a leaf node, sep, of the node1...sepn-1Is the separation value in the node. In the patent system, after the user data table and the integral data table are modified, only the hash value of the node which changes in the hash B + tree index needs to be recalculated, and hash calculation does not need to be performed on all data again.
3. User and point data table and index storage for implementing disk-based electronic point system
In the system, a user and a credit data table of an intelligent contract of the electronic credit system can be maintained and stored in a page type management mode. In the disk, the user data table, the integral data table and the corresponding hash B + tree node are used for storing and managing data in a page unit, and each page has a plurality of nodes or data items. When the two nodes correspond to the Hash B + tree nodes or the maintained data is in the disk, the file pointers of the page number, the deviant and the length are used for searching.
4. User and point data table and index storage for realizing Key-Value-based electronic point system
In the system, the user and the point data table of the electronic point system can be stored and maintained through the storage of Key-Value. The hash Value of the data item of each user data table and the score data table is the Key Value of the corresponding data query in the Key-Value store. Through Key-Value-based storage, the system can maintain and store users, point data tables and indexes of the electronic point system without directly operating a disk, and can deploy the electronic point system on a more decentralized distributed Key-Value storage system.
5. Realize the historical backtracking of the user and the point data sheet of the electronic point system
In the system, history backtracking of the user of the electronic score system and the score data table is realized by a mode of saving history nodes in the updating process of the Hash B + tree. During the operation and modification of the user and the integral data table, the user can re-search the user data and the integral data under the history through the hash certification of the specific historical user data table and the integral data table, namely, the function of history backtracking.
6. Realizing historical backspacing of merchants to users and point data tables of electronic point system
In the patent system, a merchant can realize historical backspacing of a user data table and a point data table of the electronic point system in a user history backtracking similar mode. When an operation error occurs or malicious attack occurs, the complete user data table and integral data table in the historical state can be restored by only reconstructing the linked list of the user data item and the integral data item maintained at the bottom of the index, and the historical rollback is completed.
The electronic integral system based on the blockchain provided by the embodiment is a blockchain intelligent contract electronic integral system which has historical backtracking capability and can effectively maintain relational data in an intelligent contract. The integral system realizes the maintenance and the hash calculation of mass data through a novel data index, can realize the historical backspace of indexed data, and is a system with portability and safety compared with the existing solution.
The intelligent block chain contract electronic scoring system based on Hash B + tree index and using relational data storage provided by the embodiment can meet self business requirements by using the relational data storage, simultaneously supports the functions of history backtracking and history backspacing of the relational data storage, can meet the supervision requirements of a user on a merchant and the requirements of the merchant on error operation recovery, and is a more fair and transparent decentralized electronic scoring system.
Referring to fig. 7, point data of the integral system is stored in a Key-Value storage, where a non-relational Key-Value storage medium may be a stand-alone non-relational database or a hash table, or may be a distributed Key-Value storage system. Similar to direct storage in a disk, after the < integral ID, user address, Value > data items and nodes in Key-Value are loaded to a memory, they will be searched in a memory pointer manner. Different from the above, the Key-Value storage may directly use an index node or a hash Value of a < integral ID, user address, Value > data item as a Key Value to index the corresponding content, so that a disk pointer is not required to be additionally stored when the data is stored.
Referring to fig. 8, in order to perform a history backtracking process on the electronic score system by a user, as shown in fig. 8, five scores of scores 1, 2, 3, 4, and 5 are stored in the score table, and they can calculate to obtain corresponding hash values 1, 2, 3, 4, and 5, and obtain a hash value a and a hash value B by the method for calculating a hash value B + a tree node hash value introduced in fig. 5, so as to finally obtain a root hash value of the whole table. At a certain time, the merchant changes the data of the score 3 into the score 3.1, at this time, the hash value of the score 3.1 is changed into the hash 3.1, the hash value of the corresponding parent node is changed into the hash a.1, and the root hash value of the final score table is changed into a new root hash value. Where solid arrows represent pointers to nodes of the latest hashed B + tree and dashed arrows represent pointers to nodes of the hashed B + tree that exist in the history state. If the user needs to inquire the historical data of the merchant before the point 3 is modified, the specific process is as follows:
1. and finding the historical state needing backtracking. The user needs to retrieve the history status of the data before changing, that is, the old root hash value of the score table before changing, through the block.
2. Starting from the historical root node, searching layer by layer downwards, and recovering the integral data table and the corresponding Hash B + tree index in the current historical state. Referring to fig. 8, the historical hash B + tree index node 1 may be obtained by a pointer of the root hash before the change, and the hash value stored in the node 1 is hash a instead of the hash a.1 after the change. The node 2 before the change can be continuously obtained according to the hash A, and the hash value and the pointer before the change of the integral 3 are stored in the node 2.
And searching to obtain a required historical integral data item through an integral data table under the historical record and a corresponding Hash B + tree index. Through the data of the node 2 obtained in the step 2, the data item of the score 3 before being changed can be obtained in the storage of the score data table, and the user can inquire the whole data item of the historical score 3, so that the inquiry of the score recorded in the history is completed.
In the process of history backtracking by a user, the actual storage data of the current scoring system cannot be changed. The user only inquires about the stored content in the historical time, such as the score 3, through the historical state, and the data stored in the actual score system is still the modified score 3.1.
Referring to fig. 9, in order to perform a historical backspacing process on the scoring system by a merchant, as shown in fig. 9, five scores of scores 1, 2, 3, 4, and 5 are stored in the scoring table, and they can calculate to obtain corresponding hash values 1, 2, 3, 4, and 5, and obtain a hash value a and a hash value B by the method for calculating a hash value of a hash B + tree node introduced in fig. 5, and finally obtain a root hash value of the whole table. Due to the merchant's wrong operation, the data for point 3 is modified to be the wrong point 3.1. Through the hash B + tree hash calculation process described in fig. 5, the hash value of the wrong score 3.1 will be changed to hash 3.1, the hash value of the corresponding parent node will be changed to hash a.1, and the root hash value of the final score table will be changed to a root hash value that is not desired by a merchant. After the error operation is completed, the score table stores the hash B + tree structure and the score 3.1 after the error change, and the merchant needs to undo the series of error structures in a history rollback manner. Where solid arrows represent pointers to nodes of the hash B + tree before the erroneous change, dashed nodes represent nodes resulting from the erroneous change, and dashed arrows represent pointers to nodes of the hash B + tree after the erroneous change. Here the merchant incorrectly modifies the data content of point 3, requiring a rollback. The specific process of rollback is as follows:
1. and finding a historical state needing rollback. In the figure, to return to the data storage before the point 3 is modified by an error, the state of the point table before the error is changed, namely the root hash value of the point table before the change, needs to be acquired from the block.
2. And restoring the integral data table in the current historical state and the corresponding Hash B + tree index layer by layer from the historical root node. As shown in the figure, starting from the root hash before change, the root of the hash B + tree before change is found, and nodes 1, 2 of the hash B + tree before change and node 3 which has not changed in error change are traversed. Finally, the data item integrals 1, 2, 3, 4 and 5 of the integral data table before the error change occurs are obtained, and the error result of the integral 3.1 is returned to the original integral 3.
3. And checking and repairing the leaf node linked list of the current Hash B + tree index, and reestablishing a correct linked list pointer. In the process of error change, the leaf node in the hash B + tree, that is, the successor pointer of the data item of the integral 2, will be changed into the data item of the integral 3.1, and in the process of rollback, the successor pointer of the data item of the integral 2 needs to be restored to the data item pointing to the integral 3. The specific method is that traversal is started from the Hash B + tree structures before and after change, changed nodes and changed data items are found by comparison, wherein the nodes 1 and 1.1 are found firstly, then the nodes 2 and 2.1 are found, and finally changed data item integrals 3 and 3.1 are found; then, the predecessor data item of point 3, i.e. point 2, is found in the leaf node of the hash B + tree that needs to be recovered, and its successor pointer is modified to point to the data node of point 3.
After the history rollback process is finished, the hash B + tree index and the corresponding credit data table before the credit 3 error change, which are composed of the solid line nodes, the arrows and the data items shown in fig. 9, are obtained, and the error change composed of the dotted line nodes, the arrows and the data items is cancelled. Different from history backtracking, after a merchant performs history backtracking, the storage of the current credit system is changed, the modification applied to the credit 3 is cancelled, and the credit 3 before modification is changed back instead of the credit 3.1 after error change.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A data storage method of a block chain is characterized by comprising the following steps:
s1: acquiring data of a relational data table in a block chain system, and storing primary key values corresponding to the data in leaf nodes of a tree data structure; the leaf nodes are connected into an ordered single linked list through a directed single linked list;
s2: calculating the hash value of the leaf node according to the data item value of the data corresponding to the leaf node;
s3: storing the hash values of the child nodes and the division values of two adjacent child nodes in non-leaf nodes of the tree-shaped data structure; the partitioning values of the two adjacent child nodes are greater than the maximum value of leaf nodes in a subtree taking the left child node as a root node and less than or equal to the minimum value of leaf nodes in a subtree taking the right child node as a root node; the number of child nodes of each non-leaf node is not less than N/2 and less than N, wherein N is the maximum value of the number of child nodes of the non-leaf nodes in the tree data structure;
s4: calculating the hash value of the non-leaf node according to the hash value of the child node and the division values of two adjacent child nodes;
repeating the steps of S1-S4 until the primary key values of all data in the data table are stored in the leaf nodes of the tree data structure, and the hash value of the root node of the tree data structure is used as the hash proof of the relational data table.
2. The method for storing data of a blockchain according to claim 1, wherein primary key values of leaf nodes in the ordered singly linked list are arranged from small to large.
3. The method according to claim 2, wherein the specific process of storing the primary key value corresponding to the data in the leaf node of the tree data structure is as follows:
finding a corresponding position in the ordered linked list according to the primary key value corresponding to the data, generating a new leaf node, and storing the primary key value of the new data into the new leaf node;
updating father nodes of the leaf nodes, splitting the father nodes into two new non-leaf nodes when the number of child nodes of the father nodes is equal to N, and updating the father nodes of the non-leaf nodes and hash values of the father nodes; wherein the number of child nodes of each new non-leaf node is N/2;
and checking non-leaf nodes upwards layer by layer and updating the hash value until the root node and the hash value of the tree-shaped data structure are determined.
4. The method for storing data in a blockchain according to claim 3, wherein after deleting a data in the data table, the corresponding tree data structure is updated by the following specific processes:
finding out corresponding leaf nodes in the tree data structure according to the primary key values of the deleted data and deleting the leaf nodes;
updating the father node of the leaf node and the hash value of the father node, and when the number of the child nodes of the father node is less than N/2, adjusting the father node so that the number of the child nodes is not less than N/2 and less than N;
and checking non-leaf nodes upwards layer by layer and updating the hash value until the root node and the hash value of the tree-shaped data structure are determined.
5. The data storage method of the blockchain according to claim 4, wherein when the number of child nodes of the non-leaf node is less than N/2, the specific process of maintaining the non-leaf node so that the number of child nodes is not less than N/2 and less than N is as follows:
judging whether the number of child nodes of adjacent brother nodes of the non-leaf node is larger than N/2, if so, moving one child node of the adjacent brother nodes as a child node of the non-leaf node, and updating a parent node of the non-leaf node; if not, combining the non-leaf node and the adjacent brother node, and updating the father node of the non-leaf node.
6. An electronic integral processing method based on a block chain, which applies the data storage method of the block chain according to any one of claims 1 to 5 to store a relational data table of an electronic integral system, and is characterized by comprising the following steps:
taking out a service code of the intelligent contract from an intelligent contract account of the electronic scoring system, and constructing an intelligent contract calling transaction; the service code comprises an electronic point processing function for adding, deleting, modifying and inquiring the electronic point;
executing the intelligent contract calling transaction on an intelligent contract virtual machine, calling an intelligent contract and executing a service code of the intelligent contract;
the executor analyzes a data operation statement corresponding to the service code and performs data operation on a relational data table of the electronic score system;
and when the data operation changes the data of the data table, updating the tree-shaped data structure corresponding to the data table, and regenerating the hash certification of the data table.
7. The block chain-based electronic integral processing method according to claim 6, further comprising: the relational data sheet of the electronic score system comprises a user data sheet and a score data sheet, and the user data sheet, the score data sheet and a corresponding tree-shaped data structure are stored in a magnetic disc by taking a page as a unit.
8. The block chain-based electronic integral processing method according to claim 7, further comprising history backtracking of electronic integral, the specific process being as follows:
finding a historical state needing backtracking, and searching and recovering a point data table and a corresponding tree-shaped data structure in the current historical state layer by layer from a root node of the historical state; and searching to obtain a required historical integral data item according to the integral data table in the historical state and the corresponding tree-shaped data structure.
9. The block chain-based electronic integral processing method according to claim 8, further comprising performing historical rollback on the incorrectly modified electronic integral, wherein the specific process is as follows:
finding a historical state needing to be backed, and recovering a point data table and a corresponding tree-shaped data structure in the current historical state layer by layer from a root node of the historical state; and checking and repairing the ordered linked list of the leaf nodes of the tree-like data structure, and reestablishing a correct ordered linked list.
10. An electronic integration system based on a block chain, which applies the electronic integration processing method according to any one of claims 6 to 9, and is characterized by comprising the following steps:
the initialization module is used for taking out a service code of the intelligent contract from an intelligent contract account of the electronic scoring system and constructing an intelligent contract calling transaction; the service code comprises an electronic point processing function for adding, deleting, modifying and inquiring the electronic point;
the intelligent contract calling module executes the intelligent contract calling transaction on the intelligent contract virtual machine, calls the intelligent contract and executes the service code of the intelligent contract;
the data operation execution module is used for analyzing a data operation statement corresponding to the service code by the executor and carrying out data operation on a relational data table of the electronic score system;
and the tree data structure updating module is used for updating the tree data structure corresponding to the data table and regenerating the hash certification of the data table when the data operation changes the data of the data table.
CN202011064472.5A 2020-09-30 2020-09-30 Data storage method based on block chain, electronic integral processing method and system Active CN112035491B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011064472.5A CN112035491B (en) 2020-09-30 2020-09-30 Data storage method based on block chain, electronic integral processing method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011064472.5A CN112035491B (en) 2020-09-30 2020-09-30 Data storage method based on block chain, electronic integral processing method and system

Publications (2)

Publication Number Publication Date
CN112035491A true CN112035491A (en) 2020-12-04
CN112035491B CN112035491B (en) 2021-12-28

Family

ID=73573670

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011064472.5A Active CN112035491B (en) 2020-09-30 2020-09-30 Data storage method based on block chain, electronic integral processing method and system

Country Status (1)

Country Link
CN (1) CN112035491B (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112699409A (en) * 2020-12-31 2021-04-23 卓尔智联(武汉)研究院有限公司 Data processing method and device and electronic equipment
CN112765155A (en) * 2020-12-14 2021-05-07 杭州趣链科技有限公司 Block chain-based key value storage method and device, terminal equipment and medium
CN112800065A (en) * 2021-02-09 2021-05-14 北京工业大学 Efficient data retrieval method based on improved block storage structure
CN113268544A (en) * 2021-05-31 2021-08-17 新华三技术有限公司 Data processing method and device
CN113328920A (en) * 2021-08-04 2021-08-31 成都飞机工业(集团)有限责任公司 Method for collecting and storing equipment data
CN114579581A (en) * 2022-05-05 2022-06-03 武汉北大高科软件股份有限公司 Data supervision method and device based on block chain
WO2022134128A1 (en) * 2020-12-22 2022-06-30 杭州趣链科技有限公司 Multi-version data storage method and apparatus, computer device, and storage medium
CN115064020A (en) * 2022-08-18 2022-09-16 安徽宝信信息科技有限公司 Intelligent teaching method, system and storage medium based on digital twin technology
CN115150173A (en) * 2022-06-30 2022-10-04 合肥学院 Decentralized data cloud security storage system and method with bidirectional storage structure

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109410043A (en) * 2018-08-20 2019-03-01 中山大学 A kind of block chain information high-efficiency storage method and device based on hierarchical tree structure
US20190129893A1 (en) * 2017-11-01 2019-05-02 Swirlds, Inc. Methods and apparatus for efficiently implementing a fast-copyable database
CN110175188A (en) * 2019-05-31 2019-08-27 杭州复杂美科技有限公司 A kind of block chain state data buffer storage and querying method, equipment and storage medium
CN110275884A (en) * 2019-05-31 2019-09-24 阿里巴巴集团控股有限公司 Date storage method and node
US20200104294A1 (en) * 2016-12-30 2020-04-02 Guardtime Sa Event Verification Receipt System and Methods
CN111488608A (en) * 2020-04-08 2020-08-04 北京瑞策科技有限公司 Data verification method and device for service data block chain

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200104294A1 (en) * 2016-12-30 2020-04-02 Guardtime Sa Event Verification Receipt System and Methods
US20190129893A1 (en) * 2017-11-01 2019-05-02 Swirlds, Inc. Methods and apparatus for efficiently implementing a fast-copyable database
CN109410043A (en) * 2018-08-20 2019-03-01 中山大学 A kind of block chain information high-efficiency storage method and device based on hierarchical tree structure
CN110175188A (en) * 2019-05-31 2019-08-27 杭州复杂美科技有限公司 A kind of block chain state data buffer storage and querying method, equipment and storage medium
CN110275884A (en) * 2019-05-31 2019-09-24 阿里巴巴集团控股有限公司 Date storage method and node
CN111488608A (en) * 2020-04-08 2020-08-04 北京瑞策科技有限公司 Data verification method and device for service data block chain

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112765155B (en) * 2020-12-14 2022-05-31 杭州趣链科技有限公司 Block chain-based key value storage method and device, terminal equipment and medium
CN112765155A (en) * 2020-12-14 2021-05-07 杭州趣链科技有限公司 Block chain-based key value storage method and device, terminal equipment and medium
WO2022134128A1 (en) * 2020-12-22 2022-06-30 杭州趣链科技有限公司 Multi-version data storage method and apparatus, computer device, and storage medium
CN112699409A (en) * 2020-12-31 2021-04-23 卓尔智联(武汉)研究院有限公司 Data processing method and device and electronic equipment
CN112800065A (en) * 2021-02-09 2021-05-14 北京工业大学 Efficient data retrieval method based on improved block storage structure
CN113268544A (en) * 2021-05-31 2021-08-17 新华三技术有限公司 Data processing method and device
CN113328920B (en) * 2021-08-04 2021-10-29 成都飞机工业(集团)有限责任公司 Method for collecting and storing equipment data
CN113328920A (en) * 2021-08-04 2021-08-31 成都飞机工业(集团)有限责任公司 Method for collecting and storing equipment data
CN114579581A (en) * 2022-05-05 2022-06-03 武汉北大高科软件股份有限公司 Data supervision method and device based on block chain
CN114579581B (en) * 2022-05-05 2022-08-30 武汉北大高科软件股份有限公司 Data supervision method and device based on block chain
CN115150173A (en) * 2022-06-30 2022-10-04 合肥学院 Decentralized data cloud security storage system and method with bidirectional storage structure
CN115150173B (en) * 2022-06-30 2023-09-29 合肥学院 Decentralized data cloud secure storage system and method with bidirectional storage structure
CN115064020A (en) * 2022-08-18 2022-09-16 安徽宝信信息科技有限公司 Intelligent teaching method, system and storage medium based on digital twin technology

Also Published As

Publication number Publication date
CN112035491B (en) 2021-12-28

Similar Documents

Publication Publication Date Title
CN112035491B (en) Data storage method based on block chain, electronic integral processing method and system
US7890466B2 (en) Techniques for increasing the usefulness of transaction logs
US7177875B2 (en) System and method for creating and using computer databases having schema integrated into data structure
US9990391B1 (en) Transactional messages in journal-based storage systems
Hartmann et al. Analyzing complex data in motion at scale with temporal graphs
US10866865B1 (en) Storage system journal entry redaction
US10108658B1 (en) Deferred assignments in journal-based storage systems
CN112579613B (en) Database cluster difference comparison and data synchronization method, system and medium
CN111488614A (en) Digital identity storage method and device based on service data block chain
CN112115098A (en) Tracing system based on HyperLedger and IPFS
CN109614411B (en) Data storage method, device and storage medium
CN112256584B (en) Internet number making method and system
US20230229645A1 (en) Schema management for journal-based storage systems
Morris Relational database design and implementation for biodiversity informatics
US10885157B2 (en) Determining a database signature
Cisco CiscoSecureACS Database Structure
Cisco CiscoSecure ACS Database Structure
Cisco CiscoSecureACS Database Structure
WO2021207831A1 (en) Method and systems for indexing databases on a contextual basis
Cisco CiscoSecureACS Database Structure
Cisco CiscoSecure ACS Database Structure
Cisco CiscoSecure ACS Database Structure
Cisco CiscoSecure ACS Database Structure
Basile et al. A blockchain-based support to safeguarding the Cultural Heritage
Pollari-Malmi et al. Concurrency control for B-trees with differential indices

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
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20220517

Address after: 510000 room 338, 219 Shihua Road, Huangpu District, Guangzhou City, Guangdong Province (office only)

Patentee after: GUANGZHOU YILIANTONG INTERNET TECHNOLOGY Co.,Ltd.

Address before: 510006 Xingang West Road, Guangzhou, Guangdong 135

Patentee before: SUN YAT-SEN University

PE01 Entry into force of the registration of the contract for pledge of patent right
PE01 Entry into force of the registration of the contract for pledge of patent right

Denomination of invention: Data storage method, electronic integration processing method and system based on blockchain

Effective date of registration: 20221206

Granted publication date: 20211228

Pledgee: Bank of China Limited by Share Ltd. Guangzhou Haizhu branch

Pledgor: GUANGZHOU YILIANTONG INTERNET TECHNOLOGY Co.,Ltd.

Registration number: Y2022440000324