CN111756829A - Account book data synchronization method, device, equipment and storage medium - Google Patents
Account book data synchronization method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN111756829A CN111756829A CN202010571213.5A CN202010571213A CN111756829A CN 111756829 A CN111756829 A CN 111756829A CN 202010571213 A CN202010571213 A CN 202010571213A CN 111756829 A CN111756829 A CN 111756829A
- Authority
- CN
- China
- Prior art keywords
- block
- node
- synchronized
- chain
- block chain
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 66
- 230000001360 synchronised effect Effects 0.000 claims abstract description 100
- 238000004590 computer program Methods 0.000 claims description 12
- 238000004364 calculation method Methods 0.000 claims description 4
- 238000001514 detection method Methods 0.000 claims description 3
- 238000004891 communication Methods 0.000 description 6
- 230000008569 process Effects 0.000 description 6
- 230000007246 mechanism Effects 0.000 description 5
- 230000009471 action Effects 0.000 description 3
- 238000010586 diagram Methods 0.000 description 3
- 238000009792 diffusion process Methods 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 2
- 230000000694 effects Effects 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000006855 networking Effects 0.000 description 1
- 239000000523 sample Substances 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1095—Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/13—File access structures, e.g. distributed indices
- G06F16/134—Distributed indices
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/17—Details of further file system functions
- G06F16/178—Techniques for file synchronisation in file systems
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/104—Peer-to-peer [P2P] networks
- H04L67/1044—Group management mechanisms
- H04L67/1046—Joining mechanisms
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1097—Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L2209/00—Additional information or applications relating to cryptographic mechanisms or cryptographic arrangements for secret or secure communication H04L9/00
- H04L2209/46—Secure multiparty computation, e.g. millionaire problem
- H04L2209/463—Electronic voting
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/50—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Mathematical Physics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses an account book data synchronization method, which comprises the following steps: when a target node is started, sending first synchronization request information including a block number to a trust node group through the target node so that the trust node group feeds back a block head after the block number; receiving the block header fed back by the trust node group so that the target node votes for the block header; obtaining voting statistical results of the other block headers, generating a block chain to be synchronized according to the voting statistical results, and sending block numbers in the block chain to be synchronized to a common node; the invention also discloses an account book data synchronization device, equipment and a storage medium, and solves the problem that error data can be synchronized when data synchronization is carried out in the block chain technology.
Description
Technical Field
The invention relates to the technical field of block chains, in particular to a method, a device, equipment and a storage medium for account book data synchronization.
Background
Blockchain networks, which may also be referred to as blockchain systems, consensus networks, Distributed Ledger System (DLS) networks, or blockchains, enable participating entities to store data securely and non-tamperproof. The blockchain may be described as an ledger of transactions, and multiple copies of the blockchain are stored across the blockchain network. Exemplary types of blockchains may include public blockchains, federation blockchains, and private blockchains. The public blockchain opens the use of blockchains for all entities and opens the participation of consensus processes.
The account book of the block chain is mainly used for storing block data, transaction data, account data, contract data and the like of the block chain, and each full node in the block chain independently maintains a whole set of account book data.
When a new node joins a block chain, if the new node is a full node, all the ledger data can be synchronized, and the ledger data can be stored locally. During synchronization, many nodes are selected to be synchronized by some fixed trust nodes or randomly connected with some nodes, then the longest chain of the nodes is selected to perform synchronization, after synchronization is completed, the nodes can normally receive data of block chains and maintain independent account book systems, but in the existing account book, many nodes are directly selected from some trust nodes or randomly selected nodes in account book starting synchronization to acquire the longest chain as synchronization. If the selected node is a malicious node or has a forked chain, the selected node is error data which can possibly cause synchronization.
Disclosure of Invention
The invention mainly aims to provide an account book data synchronization method, an account book data synchronization device, account book data synchronization equipment and a storage medium, and aims to solve the problem that in the existing account book, most of the account book starting synchronization directly selects a certain trust node or randomly selects a node, and obtains the longest chain as synchronization. If the selected node is a malicious node or has a forked chain, the technical problem that the synchronization to the wrong data is possibly caused is solved.
In order to achieve the above object, the present invention provides an account book data synchronization method, which includes the following steps:
when a target node is started, sending first synchronization request information including a block number to a trust node group through the target node so that the trust node group feeds back a block head after the block number;
receiving the block header fed back by the trust node group so that the target node votes for the block header;
obtaining voting statistical results of the other block headers, generating a block chain to be synchronized according to the voting statistical results, and sending block numbers in the block chain to be synchronized to a common node;
and receiving the block body corresponding to the block number in the block chain to be synchronized fed back by the common node, and storing the block body and the block head corresponding to the block number in the block chain to be synchronized in a correlation manner to complete the block synchronization operation.
In an embodiment, the step of sending, by the target node, first synchronization request information including a block number to a trusted node group when the target node is started, so that the trusted node group feeds back a block header after the block number includes:
when a target node is started, selecting a trusted node group from a trusted node pool through the target node to establish connection, wherein the trusted node group comprises 2f +1 trusted nodes, and f is the maximum tolerable number of error nodes;
and sending first synchronization request information comprising block numbers to the trust node so that the trust node group feeds back the block heads after the block numbers.
In an embodiment, the step of obtaining the voting statistical results of the other block headers, generating a block chain to be synchronized according to the voting statistical results, and sending the block numbers in the block chain to be synchronized to a common node includes:
obtaining voting statistical results of the other block heads, and arranging the blocks corresponding to the block heads with the votes more than or equal to f +1 in the voting statistical results according to the corresponding block number sequence to obtain a block chain to be synchronized;
and acquiring the block number in the block chain to be synchronized, generating a block body acquisition application corresponding to the block number in the block chain to be synchronized, and sending the block body acquisition application to a common node.
In an embodiment, the step of receiving the block body corresponding to the block number in the block chain to be synchronized fed back by the common node, and storing the block body in association with the block header corresponding to the block number in the block chain to be synchronized to complete the block synchronization operation includes:
receiving a block body corresponding to the block number in the block chain to be synchronized fed back by the common node, and performing hash calculation on the block body to obtain a block body hash value;
comparing the block hash value with a block head hash value corresponding to a block number in the block chain to be synchronized;
and when the block hash value is the same as the block head hash value corresponding to the block number in the block chain to be synchronized, storing the block and the block head corresponding to the block number in the block chain to be synchronized in a correlation manner, and finishing the block synchronization operation.
In an embodiment, after the step of comparing the block hash value with the block header hash value corresponding to the block number in the block chain to be synchronized, the method includes:
and when the block hash value is different from the block head hash value corresponding to the block number in the block chain to be synchronized, executing the step of sending the block number in the block chain to be synchronized to a common node.
In an embodiment, the receiving a block body corresponding to a block number in the block chain to be synchronized fed back by the common node, storing the block body in association with a block header corresponding to the block number in the block chain to be synchronized, and after the step of performing a block synchronization operation is completed, the method includes:
receiving second synchronization request information sent by unsynchronized nodes in a preset public chain;
and sending the block body and the block head to the unsynchronized node so as to enable the unsynchronized node to carry out data synchronization.
In an embodiment, the receiving a block body corresponding to a block number in the block chain to be synchronized fed back by the common node, storing the block body in association with a block header corresponding to the block number in the block chain to be synchronized, and after the step of performing a block synchronization operation is completed, the method includes:
acquiring a synchronous block, writing the block into a file system, establishing an index for the block, and writing the index into an index database;
and when a block query request is received, acquiring a block number in the block query request, querying the index database, acquiring a block and outputting the block.
In addition, to achieve the above object, the present invention further provides an account book data synchronization apparatus, including:
a detection module: the method comprises the steps that when a target node is started, first synchronization request information comprising block numbers is sent to a trust node group through the target node, so that the trust node group feeds back block heads after the block numbers;
a voting module: the block header is used for receiving the feedback of the trust node group so that the target node votes for the block header;
a selection module: the system comprises a node, a node and a node, wherein the node is used for acquiring voting statistical results of other block heads, generating a block chain to be synchronized according to the voting statistical results, and sending block numbers in the block chain to be synchronized to a common node;
and the synchronization module is used for receiving the block body corresponding to the block number in the block chain to be synchronized fed back by the common node, and storing the block body and the block head corresponding to the block number in the block chain to be synchronized in a correlation manner to complete the block synchronization operation.
In addition, in order to achieve the purpose, the invention also provides an account book data synchronization device;
the account book data synchronization device includes: a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein:
the computer program, when executed by the processor, implements the steps of the ledger data synchronization method described above.
In addition, to achieve the above object, the present invention also provides a computer storage medium;
the computer storage medium has stored thereon a computer program that, when executed by a processor, implements the steps of the ledger data synchronization method described above.
According to the account book data synchronization method, device, equipment and storage medium provided by the embodiment of the invention, when a target node is started, first synchronization request information comprising a block number is sent to a trust node group through the target node, so that the trust node group feeds back a block head after the block number; the target node receives the block header fed back by the trust node group so that the target node votes for the block header; the target node acquires the voting statistical results of the other block headers, generates a block chain to be synchronized according to the voting statistical results, and sends the block numbers in the block chain to be synchronized to a common node; and receiving the block body corresponding to the block number in the block chain to be synchronized fed back by the common node, and storing the block body and the block head corresponding to the block number in the block chain to be synchronized in a correlation manner to complete block synchronization operation.
Drawings
FIG. 1 is a schematic diagram of an apparatus in a hardware operating environment according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a first embodiment of a ledger data synchronization method according to the present invention;
FIG. 3 is a flowchart illustrating a method for synchronizing ledger data according to a third embodiment of the present invention;
FIG. 4 is a flowchart illustrating a fourth embodiment of the ledger data synchronization method according to the present invention;
FIG. 5 is a flowchart illustrating a seventh embodiment of the ledger data synchronization method of the present invention;
FIG. 6 is a ledger system diagram;
the implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
In the prior art, in the account book synchronization, a certain trust node is directly selected or a node is randomly selected to obtain the longest chain as synchronization. If the selected node is a malicious node or has a forked chain, the selected node is error data which can possibly cause synchronization.
The invention provides a solution, which enables the selection of trust nodes and the voting operation with the trust nodes as the leading factor to guide the data synchronization of the ledger according to the voting result, and avoids the error of data synchronization caused by the selected nodes being malicious nodes or branch chains when the data synchronization of the ledger is carried out.
As shown in fig. 1, fig. 1 is a schematic structural diagram of a terminal (called ledger data synchronization equipment, where the ledger data synchronization equipment may be formed by a single ledger data synchronization apparatus, or may be formed by combining other apparatuses with the ledger data synchronization apparatus) in a hardware operating environment according to an embodiment of the present invention.
The terminal of the embodiment of the invention can be a fixed terminal or a mobile terminal, such as an intelligent air conditioner with a networking function, an intelligent electric lamp, an intelligent power supply, an intelligent sound box, an automatic driving automobile, a Personal Computer (PC), a smart phone, a tablet computer, an electronic book reader, a portable computer and the like.
As shown in fig. 1, the terminal may include: a processor 1001, e.g., a Central Processing Unit (CPU), a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a WIreless interface (e.g., WIFI interface, WIreless FIdelity, WIFI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a storage device separate from the processor 1001.
Optionally, the terminal may further include a camera, a Radio Frequency (RF) circuit, a sensor, an audio circuit, and a WiFi module; the input unit is compared with a display screen and a touch screen; the network interface may optionally be other than WiFi, bluetooth, probe, etc. in the wireless interface. Such as light sensors, motion sensors, and other sensors. In particular, the light sensor may include an ambient light sensor and a proximity sensor; of course, the mobile terminal may also be configured with other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor, which are not described herein again.
Those skilled in the art will appreciate that the terminal structure shown in fig. 1 is not intended to be limiting and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
As shown in fig. 1, the computer software product is stored in a storage medium (storage medium: also called computer storage medium, computer medium, readable storage medium, computer readable storage medium, or direct storage medium, etc., and the storage medium may be a non-volatile readable storage medium, such as RAM, magnetic disk, optical disk), and includes several instructions for enabling a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the method according to the embodiments of the present invention, and a memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a computer program.
In the terminal shown in fig. 1, the network interface 1004 is mainly used for connecting to a backend server and performing data communication with the backend server; the user interface 1003 is mainly used for connecting a client (user side) and performing data communication with the client; and processor 1001 may be configured to call a computer program stored in memory 1005 and perform the steps in the ledger data synchronization method provided by the following embodiments of the present invention.
Referring to fig. 2, in a first embodiment of an account book data synchronization method according to the present invention, the account book data synchronization method includes:
step S10, when the target node is started, sending a first synchronization request message including a block number to the trusted node group through the target node, so that the trusted node group feeds back a block header after the block number.
Step S20, receiving the block header fed back by the trusted node group, so that the target node votes for the block header.
Step S30, obtaining the voting statistical results of the other block headers, generating a block chain to be synchronized according to the voting statistical results, and sending the block numbers in the block chain to be synchronized to a common node.
Step S40, receiving the block body corresponding to the block number in the block chain to be synchronized fed back by the common node, and storing the block body in association with the block head corresponding to the block number in the block chain to be synchronized, thereby completing the block synchronization operation.
The method of this embodiment is applied to an account book of a block chain, where the account book of the block chain is used to store block data, transaction data, account data, contract data, and the like of the block chain, and each full node in the block chain independently maintains a whole set of account book data. When the node joins the block chain, if all the nodes are full nodes, all the account book data can be synchronized, and the account book data is stored locally. During synchronization, many nodes are selected to be synchronized by some fixed trust nodes or randomly connected, then the longest chain of the nodes is selected for synchronization, and after synchronization is completed, the nodes can normally receive data of block chains and maintain independent account book systems.
Specifically, when a target node is started, first synchronization request information including a block number is sent to a trust node group through the target node, so that the trust node group feeds back a block head after the block number, the target node is a node newly added into a block chain or a node existing in the block chain but restarted due to downtime and the like, the target node is connected after being added into the block chain or restarted, a trusted node group is selected from a trust node pool, the trust node pool and the trust node group are both composed of trust nodes, the trust node is a node selected through a preset condition in the block chain, for example, a node determined through assets or historical credits, the node meeting the condition is selected as the trust node and forms the trust node pool, so that the subsequent synchronization operation can be directly selected for connection, and the trust node group is in a BFT mechanism, the parameter f is the maximum tolerable number of error nodes, the target node selects a trust node group and then sends first synchronization request information to the trust node group, the first synchronization request information comprises block numbers, the block numbers are the latest block numbers of the target node, so that the trust node feeds back block heads after the block numbers according to the block numbers, and the block heads after the block numbers are the block heads corresponding to other block numbers after the block numbers.
And the target node receives the block header fed back by the trust node group so as to enable the target node to vote for the block header. Specifically, the target node receives block heads returned by the trust nodes with the preset number according to first synchronization request information of the target node, votes for the block heads according to existing information contained in the trust nodes, the trust nodes compare the existing information with the information contained in the block heads, when a certain trust node is confirmed to contain the information contained in a certain block head, the other block numbers are determined to be error-free and a vote is recorded for the block head, and the target node votes for the block heads according to the existing information contained in each trust node in the trust node group to form a voting statistical result.
And acquiring voting statistical results of the other block heads, generating a block chain to be synchronized according to the voting statistical results, and sending block numbers in the block chain to be synchronized to a common node, wherein the common node is a node except a trust node in the chain.
And receiving the block body corresponding to the block number in the block chain to be synchronized fed back by the common node, and storing the block body and the block head corresponding to the block number in the block chain to be synchronized in a correlation manner to complete the block synchronization operation.
In the embodiment, the target node votes the plurality of block headers according to the existing information contained in each trust node in the trust node group to form a voting statistical result, and guides the data synchronization of the account book according to the voting statistical result, so that errors of data synchronization caused by the fact that the selected node is a malicious node or a node on a branch chain when the data synchronization of the account book is carried out are effectively avoided.
Further, on the basis of the first embodiment of the present invention, a second embodiment of the ledger data synchronization method of the present invention is further proposed, and this embodiment is a refinement step of step S10 in the first embodiment, and the ledger data synchronization method includes:
step a1, when a target node is started, selecting a trusted node group from a trusted node pool through the target node to establish connection, wherein the trusted node group comprises 2f +1 trusted nodes, and f is the maximum tolerable number of error nodes.
Step a2, sending a first synchronization request message including a block number to the trusted node, so that the trusted node group feeds back a block header after the block number.
When the target node is started, selecting a trusted node group from the trusted node pool through the target node to establish a connection, where the trusted node group and the trusted node pool are explained in the first embodiment and are not described herein again. The node group comprises at least 2f +1 trust nodes, wherein f is the maximum tolerable number of error nodes, the embodiment is an improvement based on BFT, in BFT, f is the maximum tolerable number of error nodes, 2f +1 is the number of new nodes which finish common identification in BFT and need to obtain identification of other nodes at least, a target node sends a synchronization request comprising a block number to the node group comprising at least 2f +1 trust nodes, the node group is different from the BFT in that multiple rounds of common identification are carried out to obtain identification of at least 2f +1 nodes, but 2f +1 trust nodes are directly selected to be connected, so that the problem of Rakage family is avoided.
In this embodiment, by connecting to 2f +1 trusted nodes at the time of node startup, an effect of simplifying the BFT through a multi-round consensus mechanism while avoiding the byzantine problem is achieved.
Further, referring to fig. 3, on the basis of the first embodiment of the present invention, a third embodiment of the ledger data synchronization method of the present invention is further proposed, and this embodiment is a refinement step of step S30 in the first embodiment, and the ledger data synchronization method includes.
Step S31, obtaining the voting statistical results of the other block headers, and arranging the blocks corresponding to the block headers whose votes are greater than or equal to f +1 in the voting statistical results according to the corresponding block number sequence to obtain the block chain to be synchronized.
Step S32, acquiring the block number in the block chain to be synchronized, generating a block acquisition application corresponding to the block number in the block chain to be synchronized, and sending the block acquisition application to a common node.
The method for generating the voting statistical result through voting is explained in the first embodiment, and according to the voting statistical result, the blocks corresponding to the block heads with the votes greater than or equal to f +1 are arranged according to the block number sequence thereof to generate a block chain to be synchronized, and a block body corresponding to the block number in the block chain to be synchronized acquires an application and sends the application to a common node.
Further, as shown in fig. 4, on the basis of the first embodiment of the present invention, a fourth embodiment of the ledger data synchronization method of the present invention is further provided, and this embodiment is a refinement step of step S40 in the first embodiment, and the ledger data synchronization method includes:
step S41, receiving the block corresponding to the block number in the block chain to be synchronized fed back by the common node, and performing hash calculation on the block to obtain a block hash value.
Step S42, comparing the block hash value with the block header hash value corresponding to the block number in the block chain to be synchronized.
Step S43, when the hash value of the block is the same as the hash value of the block header corresponding to the block number in the block chain to be synchronized, the block is stored in association with the block header corresponding to the block number in the block chain to be synchronized, thereby completing the block synchronization operation.
And the target node receives the block body corresponding to the block number in the block chain to be synchronized fed back by the common node, and performs hash calculation on the block body to obtain a block body hash value. Comparing the hash value of the block with the hash value of the block head corresponding to the block number in the block chain to be synchronized, wherein when the hash value of the block is the same as the hash value of the block head corresponding to the block number in the block chain to be synchronized, storing the block head corresponding to the block number in the block chain to be synchronized in an associated manner, and completing block synchronization operation.
In this embodiment, the target node verifies the received synchronization data, so as to ensure the accuracy of the synchronization data.
Further, on the basis of the above embodiment of the present invention, a fifth embodiment of the ledger data synchronization method of the present invention is further proposed, where the present embodiment is a refinement step of step S42 in the fourth embodiment, and the ledger data synchronization method includes:
step b1, when the hash value of the block is different from the hash value of the block head corresponding to the block number in the block chain to be synchronized, the step of sending the block number in the block chain to be synchronized to a common node is executed.
And when the block body hash value is different from the block head hash value corresponding to the block number in the block chain to be synchronized, executing the step of sending the block number in the block chain to be synchronized to a common node. And if the hash value of the block is different from the hash value of the block head, indicating that the information of the body is error information, namely the selected common node is also an error node, executing the step of sending the block number in the block chain to be synchronized to the common node, and reselecting a synchronization common node for synchronization.
In the embodiment, by checking the synchronized data, when the check result does not meet the requirement, the common node is reselected for synchronization, and the accuracy of the synchronized data is further improved.
Further, on the basis of the first embodiment of the present invention, a sixth embodiment of the ledger data synchronization method of the present invention is further proposed, where this embodiment is a step subsequent to step S40 in the first embodiment, and the ledger data synchronization method includes:
and c1, receiving the second synchronization request information sent by the unsynchronized node in the preset public chain.
And c2, sending the block body and the block head to the unsynchronized node so as to enable the unsynchronized node to perform data synchronization.
Specifically, the target node receives second synchronization request information sent by an unsynchronized node in the current public chain and then sends the block body and the block head to the unsynchronized node, so that the unsynchronized node directly uses the block body for synchronization, and synchronization steps of subsequent nodes are simplified on the premise of ensuring data accuracy.
In addition, the mode of sending the data of the target node to the unsynchronized nodes in the block chain further comprises block diffusion, and the block diffusion is to send the synchronized information of the target node to the adjacent unsynchronized nodes in a diffusion mode.
In this embodiment, the block obtained by the target node is sent to other unsynchronized nodes in the chain, so that the data accuracy is ensured, and the synchronization steps of subsequent unsynchronized nodes are simplified.
Further, referring to fig. 5, on the basis of the above embodiment of the present invention, a seventh embodiment of the ledger data synchronization method of the present invention is further provided, where this embodiment is a post-step of step S40, and the ledger synchronization method includes:
step S44, obtaining synchronous block, writing the block into file system, building index for the block, writing the index into index database;
step S45, when receiving the block query request, obtaining the block number in the block query request, querying the index database, obtaining the block, and outputting the block.
Specifically, the file system is mainly used for storing block information and transaction detailed data, when the block transaction data generated during data synchronization or in subsequent processes are stored, the block transaction data are directly stored in a file, the size of the file can be configured, when the file is full, the block data are written into a next file, an index is established for the synchronized data, the index comprises the block and position index information of the transaction in the file system, historical transaction data, account transaction data, an account book tree, a transaction tree and a metadata tree index and the like, the index is written into the database to form an index database, the index database can be implemented by adopting levelDB, in the embodiment, a consensus mechanism of the account book, a method for establishing the index for the block transaction data and the index database, The index database and the ledger file system together form an ledger system, the ledger consensus mechanism is a mechanism or method for the target node to obtain the correct blocks and data from other nodes, and the ledger system is shown in fig. 6.
In the embodiment, the speed is obviously improved when historical transaction inquiry is carried out by using the file system to store data and constructing the index, and in addition, the inquiry is faster when balance inquiry and other operations are carried out, and the inquiry can be checked through the account tree.
In addition, an embodiment of the present invention further provides an account book data synchronization apparatus, where the account book data synchronization apparatus includes:
a detection module: the method comprises the steps that when a target node is started, first synchronization request information comprising block numbers is sent to a trust node group through the target node, so that the trust node group feeds back block heads after the block numbers;
a voting module: the block header is used for receiving the feedback of the trust node group so that the target node votes for the block header;
a selection module: the system comprises a node, a node and a node, wherein the node is used for acquiring voting statistical results of other block heads, generating a block chain to be synchronized according to the voting statistical results, and sending block numbers in the block chain to be synchronized to a common node;
and the synchronization module is used for receiving the block body corresponding to the block number in the block chain to be synchronized fed back by the common node, and storing the block body and the block head corresponding to the block number in the block chain to be synchronized in a correlation manner to complete the block synchronization operation.
The steps implemented by each functional module of the ledger data synchronization apparatus may refer to each embodiment of the ledger data synchronization method of the present invention, and are not described herein again.
In addition, an embodiment of the present invention further provides an account book data synchronization device, where the account book data synchronization device includes: a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein:
the computer program, when executed by the processor, implements the steps of the ledger data synchronization method of any of the preceding embodiments.
In addition, the embodiment of the invention also provides a computer storage medium.
The computer storage medium has a computer program stored thereon, and the computer program, when executed by a processor, implements the operations in the ledger data synchronization method provided by the above-described embodiments.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity/action/object from another entity/action/object without necessarily requiring or implying any actual such relationship or order between such entities/actions/objects; the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
For the apparatus embodiment, since it is substantially similar to the method embodiment, it is described relatively simply, and reference may be made to some descriptions of the method embodiment for relevant points. The above-described apparatus embodiments are merely illustrative, in that elements described as separate components may or may not be physically separate. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of the invention. One of ordinary skill in the art can understand and implement it without inventive effort.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. 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 (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.
Claims (10)
1. The ledger data synchronization method is characterized by comprising the following steps:
when a target node is started, sending first synchronization request information including a block number to a trust node group through the target node so that the trust node group feeds back a block head after the block number;
receiving the block header fed back by the trust node group so that the target node votes for the block header;
obtaining voting statistical results of the other block headers, generating a block chain to be synchronized according to the voting statistical results, and sending block numbers in the block chain to be synchronized to a common node;
and receiving the block body corresponding to the block number in the block chain to be synchronized fed back by the common node, and storing the block body and the block head corresponding to the block number in the block chain to be synchronized in a correlation manner to complete the block synchronization operation.
2. The ledger data synchronization method of claim 1, wherein the step of sending, by a target node, first synchronization request information including a block number to a trusted node group so that the trusted node group feeds back a block header after the block number, when the target node is started, comprises:
when a target node is started, selecting a trusted node group from a trusted node pool through the target node to establish connection, wherein the trusted node group comprises 2f +1 trusted nodes, and f is the maximum tolerable number of error nodes;
and sending first synchronization request information comprising block numbers to the trust node so that the trust node group feeds back the block heads after the block numbers.
3. The ledger data synchronization method of claim 1, wherein the step of obtaining the voting statistics results of the other block headers, generating a block chain to be synchronized according to the voting statistics results, and sending block numbers in the block chain to be synchronized to a common node comprises:
obtaining voting statistical results of the other block heads, and arranging the blocks corresponding to the block heads with the votes more than or equal to f +1 in the voting statistical results according to the corresponding block number sequence to obtain a block chain to be synchronized;
and acquiring the block number in the block chain to be synchronized, generating a block body acquisition application corresponding to the block number in the block chain to be synchronized, and sending the block body acquisition application to a common node.
4. The ledger data synchronization method of claim 1, wherein the step of receiving the block body corresponding to the block number in the block chain to be synchronized fed back by the common node, storing the block body in association with the block header corresponding to the block number in the block chain to be synchronized, and completing the block synchronization operation comprises:
receiving a block body corresponding to the block number in the block chain to be synchronized fed back by the common node, and performing hash calculation on the block body to obtain a block body hash value;
comparing the block hash value with a block head hash value corresponding to a block number in the block chain to be synchronized;
and when the block hash value is the same as the block head hash value corresponding to the block number in the block chain to be synchronized, storing the block and the block head corresponding to the block number in the block chain to be synchronized in a correlation manner, and finishing the block synchronization operation.
5. The ledger data synchronization method of claim 4, wherein after the step of comparing the block body hash value with the block header hash value corresponding to a block number in the block chain to be synchronized, the method comprises:
and when the block hash value is different from the block head hash value corresponding to the block number in the block chain to be synchronized, executing the step of sending the block number in the block chain to be synchronized to a common node.
6. The ledger data synchronization method according to claim 1, wherein the receiving the block body corresponding to the block number in the block chain to be synchronized fed back by the common node, storing the block body in association with the block header corresponding to the block number in the block chain to be synchronized, and after the step of completing the block synchronization operation, the method includes:
receiving second synchronization request information sent by unsynchronized nodes in a preset public chain;
and sending the block body and the block head to the unsynchronized node so as to enable the unsynchronized node to carry out data synchronization.
7. The ledger data synchronization method according to any one of claims 1 to 6, wherein the step of receiving the block corresponding to the block number in the block chain to be synchronized fed back by the common node, storing the block in association with the block header corresponding to the block number in the block chain to be synchronized, and after the step of completing the block synchronization operation, includes:
acquiring a synchronous block, writing the block into a file system, establishing an index for the block, and writing the index into an index database;
and when a block query request is received, acquiring a block number in the block query request, querying the index database, acquiring a block and outputting the block.
8. The utility model provides an account book data synchronizer, its characterized in that, account book data synchronizer includes:
a detection module: the method comprises the steps that when a target node is started, first synchronization request information comprising block numbers is sent to a trust node group through the target node, so that the trust node group feeds back block heads after the block numbers;
a voting module: the block header is used for receiving the feedback of the trust node group so that the target node votes for the block header;
a selection module: the system comprises a node, a node and a node, wherein the node is used for acquiring voting statistical results of other block heads, generating a block chain to be synchronized according to the voting statistical results, and sending block numbers in the block chain to be synchronized to a common node;
and the synchronization module is used for receiving the block body corresponding to the block number in the block chain to be synchronized fed back by the common node, and storing the block body and the block head corresponding to the block number in the block chain to be synchronized in a correlation manner to complete the block synchronization operation.
9. The utility model provides an account book data synchronization equipment, its characterized in that, account book data synchronization equipment includes: a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein:
the computer program when executed by the processor implements the steps of the ledger data synchronization method of any of claims 1 to 7.
10. A computer storage medium, characterized in that the computer storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of the ledger data synchronization method of any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010571213.5A CN111756829A (en) | 2020-06-19 | 2020-06-19 | Account book data synchronization method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010571213.5A CN111756829A (en) | 2020-06-19 | 2020-06-19 | Account book data synchronization method, device, equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111756829A true CN111756829A (en) | 2020-10-09 |
Family
ID=72675838
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010571213.5A Pending CN111756829A (en) | 2020-06-19 | 2020-06-19 | Account book data synchronization method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111756829A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112463889A (en) * | 2020-12-08 | 2021-03-09 | 北京众享比特科技有限公司 | Block chain data storage method, device, equipment and medium |
CN112863175A (en) * | 2020-12-31 | 2021-05-28 | 平安科技(深圳)有限公司 | Automobile road monitoring data processing method, device, equipment and storage medium |
CN115314510A (en) * | 2022-07-29 | 2022-11-08 | 北京智融云河科技有限公司 | Synchronization method and device of block chain nodes, electronic equipment and storage medium |
Citations (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108122165A (en) * | 2017-12-15 | 2018-06-05 | 北京中电普华信息技术有限公司 | A kind of block chain common recognition method and system |
WO2018119930A1 (en) * | 2016-12-29 | 2018-07-05 | 深圳前海达闼云端智能科技有限公司 | Transaction verification processing method, apparatus and node device |
CN108600353A (en) * | 2018-04-12 | 2018-09-28 | 北京天德科技有限公司 | A kind of parallel block synchronization method of block chain node |
CN108848184A (en) * | 2018-06-29 | 2018-11-20 | 北京金山安全软件有限公司 | Block link point synchronization method and device based on trust mechanism |
CN108881169A (en) * | 2018-05-21 | 2018-11-23 | 西安电子科技大学 | Time distribution and synchronous method and system, data processing system based on block chain |
CN109327528A (en) * | 2018-10-31 | 2019-02-12 | 阿里巴巴集团控股有限公司 | A kind of node administration method and device based on block chain |
CN109859047A (en) * | 2019-01-31 | 2019-06-07 | 北京瑞卓喜投科技发展有限公司 | A kind of block chain update method and block chain more new system |
CN109886690A (en) * | 2019-03-06 | 2019-06-14 | 上海共链信息科技有限公司 | A kind of method that block chain synchronizes account book |
CN110059089A (en) * | 2019-03-27 | 2019-07-26 | 深圳前海达闼云端智能科技有限公司 | Data synchronization method and device, storage medium and electronic equipment |
CN110400142A (en) * | 2018-06-01 | 2019-11-01 | 腾讯科技(深圳)有限公司 | Data processing method, device and storage medium |
CN110569305A (en) * | 2019-08-27 | 2019-12-13 | 网易(杭州)网络有限公司 | Block synchronization method, device, medium and computing equipment |
US20200167367A1 (en) * | 2019-07-31 | 2020-05-28 | Alibaba Group Holding Limited | Block chain state data synchronization method, apparatus, and electronic device |
CN111241205A (en) * | 2020-04-26 | 2020-06-05 | 北京启迪区块链科技发展有限公司 | Federation block chain bottom layer based trusted data synchronization method, network structure and server |
-
2020
- 2020-06-19 CN CN202010571213.5A patent/CN111756829A/en active Pending
Patent Citations (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2018119930A1 (en) * | 2016-12-29 | 2018-07-05 | 深圳前海达闼云端智能科技有限公司 | Transaction verification processing method, apparatus and node device |
CN108122165A (en) * | 2017-12-15 | 2018-06-05 | 北京中电普华信息技术有限公司 | A kind of block chain common recognition method and system |
CN108600353A (en) * | 2018-04-12 | 2018-09-28 | 北京天德科技有限公司 | A kind of parallel block synchronization method of block chain node |
CN108881169A (en) * | 2018-05-21 | 2018-11-23 | 西安电子科技大学 | Time distribution and synchronous method and system, data processing system based on block chain |
CN110400142A (en) * | 2018-06-01 | 2019-11-01 | 腾讯科技(深圳)有限公司 | Data processing method, device and storage medium |
CN108848184A (en) * | 2018-06-29 | 2018-11-20 | 北京金山安全软件有限公司 | Block link point synchronization method and device based on trust mechanism |
CN109327528A (en) * | 2018-10-31 | 2019-02-12 | 阿里巴巴集团控股有限公司 | A kind of node administration method and device based on block chain |
CN109859047A (en) * | 2019-01-31 | 2019-06-07 | 北京瑞卓喜投科技发展有限公司 | A kind of block chain update method and block chain more new system |
CN109886690A (en) * | 2019-03-06 | 2019-06-14 | 上海共链信息科技有限公司 | A kind of method that block chain synchronizes account book |
CN110059089A (en) * | 2019-03-27 | 2019-07-26 | 深圳前海达闼云端智能科技有限公司 | Data synchronization method and device, storage medium and electronic equipment |
US20200167367A1 (en) * | 2019-07-31 | 2020-05-28 | Alibaba Group Holding Limited | Block chain state data synchronization method, apparatus, and electronic device |
CN110569305A (en) * | 2019-08-27 | 2019-12-13 | 网易(杭州)网络有限公司 | Block synchronization method, device, medium and computing equipment |
CN111241205A (en) * | 2020-04-26 | 2020-06-05 | 北京启迪区块链科技发展有限公司 | Federation block chain bottom layer based trusted data synchronization method, network structure and server |
Non-Patent Citations (3)
Title |
---|
GANG WANG等: ""ChainSplitter: Towards Blockchain-Based Industrial IoT Architecture for Supporting Hierarchical Storage"", 《2019 IEEE INTERNATIONAL CONFERENCE ON BLOCKCHAIN (BLOCKCHAIN)》 * |
石翔: ""区块链的同步及其性能优化方法"", 《HTTPS://WWW.INFOQ.CN/ARTICLE/8BVJIONLPHHV5YUK7BHY》 * |
黄方蕾: ""联盟区块链中成员动态权限管理方法的设计与实现"", 《计算机科学与技术》 * |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112463889A (en) * | 2020-12-08 | 2021-03-09 | 北京众享比特科技有限公司 | Block chain data storage method, device, equipment and medium |
CN112863175A (en) * | 2020-12-31 | 2021-05-28 | 平安科技(深圳)有限公司 | Automobile road monitoring data processing method, device, equipment and storage medium |
CN112863175B (en) * | 2020-12-31 | 2022-11-22 | 平安科技(深圳)有限公司 | Automobile road monitoring data processing method, device, equipment and storage medium |
CN115314510A (en) * | 2022-07-29 | 2022-11-08 | 北京智融云河科技有限公司 | Synchronization method and device of block chain nodes, electronic equipment and storage medium |
CN115314510B (en) * | 2022-07-29 | 2024-04-05 | 北京智融云河科技有限公司 | Block chain node synchronization method, device, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110958118B (en) | Certificate authentication management method, device, equipment and computer readable storage medium | |
CN111756829A (en) | Account book data synchronization method, device, equipment and storage medium | |
CN105162894B (en) | Device identification acquisition methods and device | |
CN111338608B (en) | Distributed application development method and device, node equipment and readable storage medium | |
CN111464356B (en) | Block consensus period switching method and device and computer equipment | |
CN112118239A (en) | Block chain consensus method and device, electronic equipment and storage medium | |
CN110825756B (en) | Data synchronization method, device, storage medium and equipment | |
CN103701653A (en) | Processing method for interface hot plugging and unplugging configuration data and network configuration server | |
CN107577822B (en) | Data synchronization method, data synchronization device and mobile terminal | |
CN108829495B (en) | Verification method, device, equipment and storage medium for multi-database modification transaction | |
CN107609197B (en) | A kind of method of data synchronization, data synchronization unit and mobile terminal | |
CN114201484A (en) | Information processing method, information processing device, electronic equipment and storage medium | |
CN103701836A (en) | Information processing method, terminal equipment and server | |
WO2018014881A1 (en) | Interactive authentication method, device and system for internet protocol television (iptv) platform | |
CN111400266B (en) | Data processing method and system, and diagnosis processing method and device for operation event | |
WO2024012567A1 (en) | System integration method and apparatus, and electronic device | |
CN112788545A (en) | Binding method, computer device and storage medium | |
CN104331649A (en) | Identity recognition system and method based on network connection | |
JP2018517200A (en) | Data processing method and apparatus | |
CN116668020A (en) | Device connection method, electronic device, and storage medium | |
CN115221139A (en) | File reading method and device and node equipment | |
CN104581371A (en) | Method, terminal, sever and system for media interaction | |
CN115982279A (en) | Data synchronization method, device and system and computer equipment | |
CN111464395B (en) | Method and device for creating blockchain and readable storage medium | |
CN117010889A (en) | Data processing method, device, equipment, medium and product |
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 | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20211118 Address after: 239 Jingshi Road, Huaiyin District, Jinan City, Shandong Province Applicant after: Li Tao Address before: 518000 room 705, building 2, Beijing Aerospace Building, Gaoxin South ninth Road, Yuehai street, Nanshan District, Shenzhen, Guangdong Province Applicant before: Shenzhen Weilian Technology Co.,Ltd. |
|
TA01 | Transfer of patent application right | ||
AD01 | Patent right deemed abandoned |
Effective date of abandoning: 20240319 |
|
AD01 | Patent right deemed abandoned |