CN110888892A - Block synchronization method, device and storage medium - Google Patents

Block synchronization method, device and storage medium Download PDF

Info

Publication number
CN110888892A
CN110888892A CN201911124322.6A CN201911124322A CN110888892A CN 110888892 A CN110888892 A CN 110888892A CN 201911124322 A CN201911124322 A CN 201911124322A CN 110888892 A CN110888892 A CN 110888892A
Authority
CN
China
Prior art keywords
node
block
target
synchronization
nodes
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
CN201911124322.6A
Other languages
Chinese (zh)
Other versions
CN110888892B (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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201911124322.6A priority Critical patent/CN110888892B/en
Publication of CN110888892A publication Critical patent/CN110888892A/en
Application granted granted Critical
Publication of CN110888892B publication Critical patent/CN110888892B/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/23Updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Abstract

The embodiment of the invention discloses a block synchronization method, a device and a storage medium, wherein the method comprises the following steps: a first node acquires the heat degree of each node in a first target node set, wherein the first node is any one of the nodes, and the first target node set comprises at least one of the nodes; the first node determines a second node from the first target node set according to the heat degree; the first node sends a synchronous block request to the second node, the synchronous block request carries a block identifier, and the synchronous block request is used for indicating the second node to acquire a target block corresponding to the block identifier in a block chain and sending the target block to the first node. By the implementation mode, the efficiency and the flexibility of block synchronization are improved, and the utilization rate of network traffic is improved.

Description

Block synchronization method, device and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a block synchronization method, an apparatus, and a storage medium.
Background
In the existing block chain technology, a method for block synchronization is that a node randomly requests a high-level block from one node or a plurality of nodes in a block chain to realize block synchronization. However, this approach may select a node with higher heat to request a block from the node, which results in low efficiency of block synchronization, and meanwhile, other nodes with lower heat in the block chain are not reasonably utilized, which results in low network traffic utilization.
Disclosure of Invention
Embodiments of the present invention provide a block synchronization method, apparatus, and storage medium, which implement block synchronization by selecting a node with low heat, and are beneficial to improving efficiency and flexibility of block synchronization and improving utilization rate of network traffic.
In a first aspect, an embodiment of the present invention provides a block synchronization method, which is applied to a block chain network, where the block chain network includes a plurality of nodes, and the method includes:
a first node acquires the heat degree of each node in a first target node set, wherein the first node is any one of the nodes, and the first target node set comprises at least one of the nodes;
the first node determines a second node from the first target node set according to the heat degree;
the first node sends a synchronous block request to the second node, the synchronous block request carries a block identifier, and the synchronous block request is used for indicating the second node to acquire a target block corresponding to the block identifier in a block chain and sending the target block to the first node.
In a second aspect, an embodiment of the present invention provides another block synchronization method, which is applied to a block chain network, where the block chain network includes a plurality of nodes, and the method includes:
a second node receives a synchronization block request sent by a first node, wherein the synchronization block request carries a block identifier, the first node is any one of the plurality of nodes, the second node is determined by the first node from a first target node set according to heat, and the first target node set comprises at least one of the plurality of nodes;
the second node responds to the synchronous block request to acquire a target block corresponding to the block identifier in a block chain;
and the second node sends the target block to the first node.
In a third aspect, an embodiment of the present invention provides a block synchronization apparatus, which is applied to a block chain network, where the block chain network includes a plurality of nodes, and the apparatus includes:
a first obtaining module, configured to obtain, by a first node, a heat degree of each node in a first target node set, where the first node is any one of the multiple nodes, and the first target node set includes at least one of the multiple nodes;
a determining module, configured to determine, by the first node, a second node from the first target node set according to the heat degree;
a first sending module, configured to send, by the first node, a synchronization block request to the second node, where the synchronization block request carries a block identifier, and the synchronization block request is used to instruct the second node to obtain a target block in a block chain, where the target block corresponds to the block identifier, and send the target block to the first node.
In a fourth aspect, an embodiment of the present invention provides another block synchronization apparatus, which is applied to a block chain network, where the block chain network includes a plurality of nodes, and the apparatus includes:
a receiving module, configured to receive, by a second node, a synchronization block request sent by a first node, where the synchronization block request carries a block identifier, the first node is any one of the multiple nodes, and the second node is determined by the first node according to heat from a first target node set, where the first target node set includes at least one of the multiple nodes;
a second obtaining module, configured to, in response to the synchronization block request, the second node obtain a target block in a block chain, where the target block corresponds to the block identifier;
a second sending module, configured to send, by the second node, the target block to the first node.
In a fifth aspect, an embodiment of the present invention provides a node, where the node corresponds to the first node, and the node includes: a processor and a memory, the processor to perform:
acquiring the heat degree of each node in a first target node set, wherein the first node is any one of the nodes, and the first target node set comprises at least one of the nodes;
determining a second node from the first target node set according to the heat degree;
and sending a synchronous block request to the second node, wherein the synchronous block request carries a block identifier, and the synchronous block request is used for indicating the second node to acquire a target block corresponding to the block identifier in a block chain and sending the target block to the first node.
In a sixth aspect, an embodiment of the present invention provides another node, where the node corresponds to the foregoing second node, and the node includes: a processor and a memory, the processor to perform:
receiving a synchronization block request sent by a first node, wherein the synchronization block request carries a block identifier, the first node is any one of the plurality of nodes, the second node is determined by the first node from a first target node set according to heat, and the first target node set comprises at least one of the plurality of nodes;
responding the synchronous block request to acquire a target block corresponding to the block identifier in a block chain;
and sending the target block to the first node.
In a seventh aspect, the present invention further provides a computer-readable storage medium, where program instructions are stored, and when executed, the program instructions are configured to implement the method according to the first aspect or the second aspect.
According to the embodiment of the invention, the heat degree of each node in a first target node set is obtained through a first node, a second node is determined from the first target node set according to the heat degree, a synchronous block request is sent to the second node, a block identifier is carried in the synchronous block request, so that the second node obtains a target block corresponding to the block identifier in a block chain, and the target block is sent to the first node. And the first node selects the second node to send the synchronous block request according to the heat of each node in the first target node set, so that the efficiency and the flexibility of block synchronization are improved, and the utilization rate of network flow is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1a is a schematic structural diagram of a blockchain network according to an embodiment of the present invention;
fig. 1b is a schematic structural diagram of a block chain according to an embodiment of the present invention;
FIG. 1c is a schematic diagram of a process for generating a new block according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating a block synchronization method according to an embodiment of the present invention;
fig. 3 is a flowchart illustrating another block synchronization method according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a block synchronization apparatus according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of another block synchronization apparatus according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a node according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of another node according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described clearly below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Some embodiments of the invention are described in detail below with reference to the accompanying drawings. The embodiments described below and the features of the embodiments can be combined with each other without conflict.
The block synchronization method provided in the embodiment of the present invention is applied to a block chain network, wherein the block chain network includes a plurality of nodes, and communication connection can be established between each of the plurality of nodes.
A block chain network provided by an embodiment of the present invention is schematically illustrated below with reference to fig. 1a to 1 c.
Referring to fig. 1a, fig. 1a is a schematic structural diagram of a blockchain network according to an embodiment of the present invention, where the blockchain network 11 includes a plurality of nodes 111, and each node 111 may establish a communication connection.
In one embodiment, the blockchain network 11 refers to a network for performing data sharing between nodes, and the blockchain network may include a plurality of nodes 111. Each node 111 may receive input information and maintain shared data (i.e., blockchains) within the blockchain network based on the received input information while operating normally. In order To ensure information intercommunication in the blockchain network, each node may have information connection, and any two nodes may implement Peer-To-Peer (P2P) communication, and specifically may perform P2P communication through a wired communication link or a wireless communication link. For example, when any node in the blockchain network receives input information, other nodes acquire the input information according to a consensus algorithm, and store the input information as data in shared data, so that the data stored on all nodes in the blockchain network are consistent.
It should be noted that the number of nodes shown in fig. 1a is only illustrative, and any number of nodes may be deployed according to actual needs, and communication may be performed between the nodes in the blockchain network 11.
Each node in the blockchain network 11 has a corresponding node identifier, and each node in the blockchain network 11 may store node identifiers of other nodes in the blockchain network, so that the generated block is broadcast to other nodes in the blockchain network according to the node identifiers of other nodes. Each node may maintain a node identifier list as shown in the following table, and store the node name and the node identifier in the node identifier list correspondingly. The node identifier may be an Internet Protocol (IP) address or any other information that can be used to identify the node, and table 1 only illustrates the IP address as an example.
TABLE 1
Node name Node identification
Node 1 117.114.151.174
Node 2 117.116.189.145
Node N 119.123.789.258
Each node in the blockchain network stores one identical blockchain. The block chain is composed of a plurality of blocks, and referring to fig. 1b, fig. 1b is a schematic structural diagram of a block chain according to an embodiment of the present invention. The block chain is composed of a plurality of blocks, the starting block comprises a block head and a block main body, the block head stores an input information characteristic value, a version number, a timestamp and a difficulty value, and the block main body stores input information; the next block of the starting block takes the starting block as a parent block, the next block also comprises a block head and a block main body, the block head stores the input information characteristic value of the current block, the block head characteristic value of the parent block, the version number, the timestamp and the difficulty value, and the like, so that the block data stored in each block in the block chain is associated with the block data stored in the parent block, and the safety of the input information in the block is ensured.
When generating each block in the block chain, referring to fig. 1c, fig. 1c is a schematic diagram of a process for generating a new block according to an embodiment of the present invention. When the node where the block chain is located receives input information, verifying the input information, storing the input information into a memory pool after the verification is completed, and updating a hash tree for recording the input information; and then, updating the updating time stamp to the time when the input information is received, trying different random numbers, and calculating the characteristic value for multiple times, so that the calculated characteristic value can meet the following formula:
SHA256(SHA256(version+prev_hash+merkle_root+ntime+nbits+x))<TARGET
wherein, SHA256 is a characteristic value algorithm used for calculating a characteristic value; version is version information of the relevant block protocol in the block chain; prev _ hash is a block head characteristic value of a parent block of the current block; merkle _ root is a characteristic value of the input information; ntime is the update time of the update timestamp; nbits is the current difficulty, is a fixed value within a period of time, and is determined again after exceeding a fixed time period; x is a random number; TARGET is a feature threshold, which can be determined from nbits.
Therefore, when the random number meeting the formula is obtained through calculation, the information can be correspondingly stored, and the block head and the block main body are generated to obtain the current block. And then, the node where the block chain is located respectively sends the newly generated blocks to other nodes in the block chain network where the newly generated blocks are located according to the node identifications of the other nodes in the block chain network, the newly generated blocks are verified by the other nodes, and the newly generated blocks are added to the block chain stored in the newly generated blocks after the verification is completed.
The nodes of the blockchain network 11 may run an intelligent contract, the intelligent contract is implemented by a code executed when a certain condition is satisfied, and a developer may define a contract logic through a programming language, issue the contract logic to the blockchain (intelligent contract registration), call a key or trigger execution of other events according to the logic of contract terms, complete the contract logic, and provide functions of upgrading and deregistering the intelligent contract.
The block synchronization method provided by the embodiment of the invention is schematically described below with reference to fig. 2 to fig. 3.
Referring to fig. 2, fig. 2 is a flowchart illustrating a block synchronization method according to an embodiment of the present invention, where the block synchronization method according to the embodiment of the present invention may be executed by a first node in a blockchain network, where the first node may be any one of a plurality of nodes in the blockchain network. Specifically, the method of the embodiment of the present invention includes the following steps.
S201: the method comprises the steps that a first node obtains the heat degree of each node in a first target node set, the first node is any one of the nodes, and the first target node set comprises at least one of the nodes.
In this embodiment of the present invention, a first node may obtain a heat degree of each node in a first target node set, where the first node is any one of the plurality of nodes, and the first target node set includes at least one of the plurality of nodes.
In an embodiment, each node in the first target node set is a node for which the first node maintains the heat degree, that is, the first node may receive the heat degree sent by each node maintained by the first node, so that the first node may perform operations such as updating the heat degree of each maintained node.
In one example, assuming that the first node maintains the heat degrees of 3 nodes, that is, node a, node b, and node c, it is determined that the node a, node b, and node c form the first target node set, and therefore the first node may acquire the respective heat degrees sent by the node a, node b, and node c.
In some embodiments, the heat of each node may be determined according to any one or more of the number of times that each node is accessed within a preset time period, an amount of block data provided to the outside, and signature confirmation information of the node. In some embodiments, the heat degree of each node may be represented by any one or more of numbers, letters, and the like, and the embodiments of the present invention are not specifically limited herein, and in one example, the heat degree of the node a is 5.
In an embodiment, the heat of each node may determine, according to a preset number of times and a corresponding relationship between the block data amount and the heat, the number of times that each node is accessed within a preset time period and the heat corresponding to the block data amount provided to the outside.
In an example, assuming that the number of times that the node a is accessed within 30s is 5, and the amount of block data sent out externally is 1024 bits, it may be determined that the heat of the node a within 30s is 6 according to a preset correspondence between the number of times, the amount of block data, and the heat.
In an embodiment, the first node may further receive a heartbeat packet sent by a third node in the first target node set, where the heartbeat packet includes the number of times that the third node is accessed within a preset time period, an externally provided block data volume, and signature confirmation information of the node, and the third node is any one node in the first target node set; the first node may update the heat of the third node according to the heartbeat packet. In certain embodiments, the third node maintains a hot node for the first node. In some embodiments, the signature verification information of the node may be used to verify an amount of block data provided by the third node to the outside within a preset time period.
In one example, assuming that the third node is node b and node b is a first node maintenance heat node, the first node may receive a heartbeat packet sent by node b, so that the first node may update the heat of node b according to the heartbeat packet.
Therefore, the embodiment of the invention can help the first node to select the second node sending the synchronization block request according to the heat degree by the first node to obtain the maintained heat degree of each node.
S202: and the first node determines a second node from the first target node set according to the heat degree.
In this embodiment of the present invention, the first node may determine the second node from the first target node set according to the heat degree.
In an embodiment, when the first node determines the second node from the first target node set according to the heat degree, the second node with the lowest current heat degree may be determined from the first target node set according to the heat degree.
In an example, assuming that the current heat acquired by the first node to the node a is 4, the current heat acquired by the first node to the node b is 5, and the current heat acquired by the first node to the node c is 3, the first node may determine that the node c with the lowest current heat is the second node.
Therefore, the embodiment of the invention is beneficial to sending the synchronous block request to the second node with the lowest current heat degree to improve the efficiency of acquiring the block by determining the second node with the lowest current heat degree.
S203: the first node sends a synchronous block request to the second node, the synchronous block request carries a block identifier, and the synchronous block request is used for indicating the second node to acquire a target block corresponding to the block identifier in a block chain and sending the target block to the first node.
In this embodiment of the present invention, the first node may send a synchronization block request to the second node, where the synchronization block request carries a block identifier, and the synchronization block request is used to instruct the second node to obtain a target block in a block chain, where the target block corresponds to the block identifier, and send the target block to the first node. In some embodiments, the block identifier may include, but is not limited to, a block height, and in some embodiments, the block identifier may include, but is not limited to, any one or more of a number, a letter, and the like, and the embodiments of the present invention are not particularly limited. In one example, the block height carried in the sync block request is 100.
In an example, the first node may send a synchronization block request to the second node, where the synchronization block request carries a block identifier 1, so that the second node may obtain a target block in a block chain, where the target block corresponds to the block identifier 1, and send the target block to the first node.
In one embodiment, the first node may perform signature verification after receiving the target block sent by the second node, and send signature verification information to the second node.
In the embodiment of the present invention, a first node obtains the heat of each node in a first target node set, and determines a second node from the first target node set according to the heat, so as to send a synchronization block request to the second node, so that the second node can obtain a target block corresponding to a block identifier in a block chain according to the block identifier carried in the synchronization block request, and send the target block to the first node. The synchronization block is obtained by selecting the node with lower heat, so that the efficiency and flexibility of block synchronization can be improved, and the utilization rate of network flow is improved.
Referring to fig. 3 specifically, fig. 3 is a flowchart illustrating another block synchronization method according to an embodiment of the present invention, where the block synchronization method according to the embodiment of the present invention may be executed by a second node in a block chain network, where the second node may be any one of a plurality of nodes in the block chain network, and specifically, the method according to the embodiment of the present invention includes the following steps.
S301: a second node receives a synchronization block request sent by a first node, wherein the synchronization block request carries a block identifier, the first node is any one of the plurality of nodes, the second node is determined by the first node from a first target node set according to heat, and the first target node set comprises at least one of the plurality of nodes.
In this embodiment of the present invention, a second node may receive a synchronization block request sent by a first node, where the synchronization block request carries a block identifier, the first node is any one of the plurality of nodes, the second node is determined by the first node from a first target node set according to heat, and the first target node set includes at least one of the plurality of nodes. The specific embodiments are as described above and will not be described herein.
S302: and the second node responds to the synchronous block request to acquire a target block corresponding to the block identifier in the block chain.
In this embodiment of the present invention, the second node may obtain, in response to the synchronization block request, a target block in the block chain corresponding to the block identifier.
In an embodiment, before the second node acquires the target block corresponding to the block identifier in the block chain in response to the synchronization block request, the second node may acquire the heat degree of the second node, and if the heat degree of the second node indicates that the heat degree of the second node does not reach a preset heat degree threshold, the second node may perform the step of acquiring the target block corresponding to the block identifier in the block chain in response to the synchronization block request.
In an embodiment, if the heat degree of the second node indicates that the heat degree of the second node reaches the preset heat degree threshold, the second node may determine a fourth node with the lowest current heat degree from a second target node set, and send identification information of the fourth node to the first node, so that the first node sends the synchronization block request to the fourth node according to the identification information of the fourth node. In some embodiments, when the heat of the second node indicates that the heat of the second node reaches the preset heat threshold, it may be determined that the second node cannot undertake the sync block request sent by the first node. In some embodiments, the node in the second set of target nodes is a node for which the second node maintains heat.
In an example, assuming that a second target node set of the second node maintaining the heat degree includes a node d and a node e, if the heat degree of the second node acquired by the second node when acquiring the synchronization block request sent by the first node is greater than a preset heat degree threshold, the second node may determine, as the node e, a fourth node with the lowest current heat degree from the node d and the node e, and send identification information of the node e to the first node, so that the first node sends the synchronization block request to the node e according to the identification information of the node e.
Therefore, when the second node receives the synchronization block request and the self heat degree is high, the fourth node with the lowest heat degree maintained by the second node can be recommended to the first node, so that the first node sends the synchronization block request to the fourth node with the low heat degree.
In an embodiment, when the heat degree of the second node indicates that the heat degree of the second node reaches the preset heat degree threshold, if the second node detects that the heat degree of each node in the second target node set is higher than the heat degree of the first node, the second node may send a notification message to the first node, where the notification message is used to notify the first node that the second node cannot currently process, and request the first node to send a synchronization block request to other nodes maintained by the first node.
In an embodiment, when the heat degree of the second node indicates that the heat degree of the second node reaches the preset heat degree threshold, if the second node detects that there is no node in the current second target node set, the second node may send a notification message to the first node, where the notification message is used to notify the first node that the second node cannot process currently, and request the first node to send a synchronization block request to other nodes maintained by the first node.
S303: and the second node sends the target block to the first node.
In this embodiment of the present invention, the second node may send the target block to the first node.
In an embodiment, after the second node sends the target block to the first node, the second node may receive signature confirmation information sent by the first node after receiving the target block, and send a heartbeat packet to the first node, where the heartbeat packet includes the number of times the second node is accessed within a preset time period, an externally provided block data amount, and signature confirmation information of the first node, so that the first node updates the heat of the second node according to the heartbeat packet.
In this embodiment of the present invention, the second node may receive the synchronization block request sent by the first node, and respond to the synchronization block request to obtain a target block in the block chain corresponding to the block identifier carried in the synchronization block request, so as to send the target block to the first node. By the implementation mode, the efficiency and the flexibility of block synchronization are improved, and the utilization rate of network traffic is improved.
Referring to fig. 4, fig. 4 is a schematic structural diagram of a block synchronization apparatus according to an embodiment of the present invention. Specifically, the apparatus is disposed in a blockchain network, the blockchain network including a plurality of nodes, and the apparatus includes: a first obtaining module 401, a determining module 402 and a first sending module 403;
a first obtaining module 401, configured to obtain, by a first node, a heat degree of each node in a first target node set, where the first node is any one of the multiple nodes, and the first target node set includes at least one of the multiple nodes;
a determining module 402, configured to determine, by the first node, a second node from the first target node set according to the heat degree;
a first sending module 403, configured to send, by the first node, a synchronization block request to the second node, where the synchronization block request carries a block identifier, and the synchronization block request is used to instruct the second node to obtain a target block in a block chain, where the target block corresponds to the block identifier, and send the target block to the first node.
Further, the first obtaining module 401 is further configured to:
the first node receives a heartbeat packet sent by a third node in the first target node set, wherein the heartbeat packet comprises the number of times that the third node is accessed within a preset time length, block data volume provided externally and signature confirmation information of the node, and the third node is any one node in the first target node set;
and the first node updates the heat of the third node according to the heartbeat packet.
Further, when the determining module 402 is configured to determine, by the first node, the second node from the first target node set according to the heat degree, specifically, the determining module is configured to:
and the first node determines a second node with the lowest current heat degree from the first target node set according to the heat degree.
According to the embodiment of the invention, the heat degree of each node in the first target node set is obtained, the second node is determined from the first target node set according to the heat degree, the synchronous block request is sent to the second node, so that the second node can obtain the target block corresponding to the block identifier in the block chain according to the block identifier carried in the synchronous block request, and the target block is sent to the first node. The synchronization block is obtained by selecting the node with lower heat, so that the efficiency and flexibility of block synchronization can be improved, and the utilization rate of network flow is improved.
Referring to fig. 5, fig. 5 is a schematic structural diagram of another block synchronization apparatus according to an embodiment of the present invention. Specifically, the apparatus is disposed in a blockchain network, the blockchain network includes a plurality of nodes, and the apparatus includes: a receiving module 501, a second obtaining module 502 and a second sending module 503;
a receiving module 501, configured to receive, by a second node, a synchronization block request sent by a first node, where the synchronization block request carries a block identifier, the first node is any one of the multiple nodes, and the second node is determined by the first node according to heat from a first target node set, where the first target node set includes at least one node in the multiple nodes;
a second obtaining module 502, configured to, in response to the synchronization block request, the second node obtain a target block in a block chain, where the target block corresponds to the block identifier;
a second sending module 503, configured to send the target block to the first node by the second node.
Further, the second obtaining module 502 is configured to, before the second node obtains the target block corresponding to the block identifier in the block chain in response to the synchronization block request, further:
the second node acquires the heat degree of the second node;
and if the heat degree of the second node indicates that the heat degree of the second node does not reach a preset heat degree threshold value, the second node executes a step of responding the synchronous block request to acquire a target block corresponding to the block identifier in the block chain.
Further, the second obtaining module 502 is further configured to:
if the heat degree of the second node indicates that the heat degree of the second node reaches the preset heat degree threshold value, the second node determines a fourth node with the lowest current heat degree from a second target node set;
the second node sends the identification information of the fourth node to the first node, so that the first node sends the synchronization block request to the fourth node according to the identification information of the fourth node.
Further, after the second node sends the target block to the first node, the second sending module 503 is further configured to:
the second node receives signature confirmation information sent by the first node after receiving the target block;
the second node sends a heartbeat packet to the first node, wherein the heartbeat packet comprises the number of times that the second node is accessed within a preset time length, block data volume provided to the outside and signature confirmation information of the first node, so that the first node updates the heat of the second node according to the heartbeat packet.
In the embodiment of the invention, the target block is sent to the first node by receiving the synchronous block request sent by the first node and responding to the synchronous block request to acquire the target block corresponding to the block identifier carried in the synchronous block request in the block chain. By the implementation mode, the efficiency and the flexibility of block synchronization are improved, and the utilization rate of network traffic is improved.
Referring to fig. 6, fig. 6 is a schematic structural diagram of a node according to an embodiment of the present invention, where the node is the same as the first node, and specifically, the node includes: memory 601, processor 602.
In one embodiment, the node further comprises a data interface 603, and the data interface 603 is configured to communicate data information between the node and other devices.
The memory 601 may include a volatile memory (volatile memory); the memory 601 may also include a non-volatile memory (non-volatile memory); the memory 601 may also comprise a combination of memories of the kind described above. The processor 602 may be a Central Processing Unit (CPU). The processor 602 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a Programmable Logic Device (PLD), or a combination thereof. The PLD may be a Complex Programmable Logic Device (CPLD), a field-programmable gate array (FPGA), or any combination thereof.
The memory 601 is used for storing programs, and the processor 602 can call the programs stored in the memory 601 for executing the following steps:
acquiring the heat degree of each node in a first target node set, wherein the first node is any one of the nodes, and the first target node set comprises at least one of the nodes;
determining a second node from the first target node set according to the heat degree;
and sending a synchronous block request to the second node, wherein the synchronous block request carries a block identifier, and the synchronous block request is used for indicating the second node to acquire a target block corresponding to the block identifier in a block chain and sending the target block to the first node.
Further, the processor 602 is further configured to:
receiving a heartbeat packet sent by a third node in the first target node set, wherein the heartbeat packet comprises the number of times the third node is accessed within a preset time length, a block data volume provided externally and signature confirmation information of the node, and the third node is any one node in the first target node set;
and updating the heat degree of the third node according to the heartbeat packet.
Further, when the processor 602 determines the second node from the first target node set according to the heat degree, the method is specifically configured to:
and determining a second node with the lowest current heat degree from the first target node set according to the heat degree.
According to the embodiment of the invention, the heat degree of each node in the first target node set is obtained, the second node is determined from the first target node set according to the heat degree, the synchronous block request is sent to the second node, so that the second node can obtain the target block corresponding to the block identifier in the block chain according to the block identifier carried in the synchronous block request, and the target block is sent to the first node. The synchronization block is obtained by selecting the node with lower heat, so that the efficiency and flexibility of block synchronization can be improved, and the utilization rate of network flow is improved.
Referring to fig. 7, fig. 7 is a schematic structural diagram of another node according to an embodiment of the present invention, where the node is the same as the second node, and specifically, the node includes: memory 701, processor 702.
In one embodiment, the node further comprises a data interface 703, and the data interface 703 is used for transferring data information between the node and other devices.
The memory 701 may include a volatile memory (volatile memory); the memory 701 may also include a non-volatile memory (non-volatile memory); the memory 701 may also comprise a combination of memories of the kind described above. The processor 702 may be a Central Processing Unit (CPU). The processor 702 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a Programmable Logic Device (PLD), or a combination thereof. The PLD may be a Complex Programmable Logic Device (CPLD), a field-programmable gate array (FPGA), or any combination thereof.
The memory 701 is used for storing programs, and the processor 702 may call the programs stored in the memory 701 to execute the following steps:
receiving a synchronization block request sent by a first node, wherein the synchronization block request carries a block identifier, the first node is any one of the plurality of nodes, the second node is determined by the first node from a first target node set according to heat, and the first target node set comprises at least one of the plurality of nodes;
responding the synchronous block request to acquire a target block corresponding to the block identifier in a block chain;
and sending the target block to the first node.
Further, before the processor 702 acquires the target block corresponding to the block identifier in the block chain in response to the synchronization block request, it is further configured to:
acquiring the heat degree of the second node;
and if the heat degree of the second node indicates that the heat degree of the second node does not reach a preset heat degree threshold value, executing a step of responding to the synchronous block request to acquire a target block corresponding to the block identifier in the block chain.
Further, the processor 702 is further configured to:
if the heat degree of the second node indicates that the heat degree of the second node reaches the preset heat degree threshold value, determining a fourth node with the lowest current heat degree from a second target node set;
and sending the identification information of the fourth node to the first node, so that the first node sends the synchronous block request to the fourth node according to the identification information of the fourth node.
Further, after the processor 702 sends the target block to the first node, it is further configured to:
receiving signature confirmation information sent by the first node after receiving the target block;
and sending a heartbeat packet to the first node, wherein the heartbeat packet comprises the number of times that the second node is accessed within a preset time length, block data volume provided to the outside and signature confirmation information of the first node, so that the first node updates the heat of the second node according to the heartbeat packet.
In the embodiment of the invention, the target block is sent to the first node by receiving the synchronous block request sent by the first node and responding to the synchronous block request to acquire the target block corresponding to the block identifier carried in the synchronous block request in the block chain. By the implementation mode, the efficiency and the flexibility of block synchronization are improved, and the utilization rate of network traffic is improved.
An embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the computer program implements the method described in the embodiment corresponding to fig. 2 or fig. 3 of the present invention, or implements the apparatus in the embodiment corresponding to the present invention described in fig. 4 or fig. 5, which is not described herein again.
The computer readable storage medium may be an internal storage unit of the device according to any of the foregoing embodiments, for example, a hard disk or a memory of the device. The computer readable storage medium may also be an external storage device of the device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), etc. provided on the device. Further, the computer-readable storage medium may also include both an internal storage unit and an external storage device of the apparatus. The computer-readable storage medium is used for storing the computer program and other programs and data required by the server. The computer readable storage medium may also be used to temporarily store data that has been output or is to be output.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
While the invention has been described with reference to a number of embodiments, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (10)

1. A block synchronization method applied to a block chain network including a plurality of nodes, the method comprising:
a first node acquires the heat degree of each node in a first target node set, wherein the first node is any one of the nodes, and the first target node set comprises at least one of the nodes;
the first node determines a second node from the first target node set according to the heat degree;
the first node sends a synchronous block request to the second node, the synchronous block request carries a block identifier, and the synchronous block request is used for indicating the second node to acquire a target block corresponding to the block identifier in a block chain and sending the target block to the first node.
2. The method of claim 1, further comprising:
the first node receives a heartbeat packet sent by a third node in the first target node set, wherein the heartbeat packet comprises the number of times that the third node is accessed within a preset time length, block data volume provided externally and signature confirmation information of the node, and the third node is any one node in the first target node set;
and the first node updates the heat of the third node according to the heartbeat packet.
3. The method of claim 1 or 2, wherein the determining, by the first node, a second node from the first set of target nodes according to the heat degree comprises:
and the first node determines a second node with the lowest current heat degree from the first target node set according to the heat degree.
4. A block synchronization method applied to a block chain network including a plurality of nodes, the method comprising:
a second node receives a synchronization block request sent by a first node, wherein the synchronization block request carries a block identifier, the first node is any one of the plurality of nodes, the second node is determined by the first node from a first target node set according to heat, and the first target node set comprises at least one of the plurality of nodes;
the second node responds to the synchronous block request to acquire a target block corresponding to the block identifier in a block chain;
and the second node sends the target block to the first node.
5. The method of claim 4, wherein before the second node acquires the target block corresponding to the block identifier in the block chain in response to the sync block request, the method further comprises:
the second node acquires the heat degree of the second node;
and if the heat degree of the second node indicates that the heat degree of the second node does not reach a preset heat degree threshold value, the second node executes a step of responding the synchronous block request to acquire a target block corresponding to the block identifier in the block chain.
6. The method of claim 5, further comprising:
if the heat degree of the second node indicates that the heat degree of the second node reaches the preset heat degree threshold value, the second node determines a fourth node with the lowest current heat degree from a second target node set;
the second node sends the identification information of the fourth node to the first node, so that the first node sends the synchronization block request to the fourth node according to the identification information of the fourth node.
7. The method of claim 4, wherein after the second node sends the target block to the first node, the method further comprises:
the second node receives signature confirmation information sent by the first node after receiving the target block;
the second node sends a heartbeat packet to the first node, wherein the heartbeat packet comprises the number of times that the second node is accessed within a preset time length, block data volume provided to the outside and signature confirmation information of the first node, so that the first node updates the heat of the second node according to the heartbeat packet.
8. A block synchronization apparatus applied to a block chain network including a plurality of nodes, the apparatus comprising:
a first obtaining module, configured to obtain, by a first node, a heat degree of each node in a first target node set, where the first node is any one of the multiple nodes, and the first target node set includes at least one of the multiple nodes;
a determining module, configured to determine, by the first node, a second node from the first target node set according to the heat degree;
a first sending module, configured to send, by the first node, a synchronization block request to the second node, where the synchronization block request carries a block identifier, and the synchronization block request is used to instruct the second node to obtain a target block in a block chain, where the target block corresponds to the block identifier, and send the target block to the first node.
9. A block synchronization apparatus applied to a block chain network including a plurality of nodes, the apparatus comprising:
a receiving module, configured to receive, by a second node, a synchronization block request sent by a first node, where the synchronization block request carries a block identifier, the first node is any one of the multiple nodes, and the second node is determined by the first node according to heat from a first target node set, where the first target node set includes at least one of the multiple nodes;
a second obtaining module, configured to, in response to the synchronization block request, the second node obtain a target block in a block chain, where the target block corresponds to the block identifier;
a second sending module, configured to send, by the second node, the target block to the first node.
10. A computer-readable storage medium, having stored thereon program instructions for implementing the method of any one of claims 1-7 when executed.
CN201911124322.6A 2019-11-15 2019-11-15 Block synchronization method, device and storage medium Active CN110888892B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911124322.6A CN110888892B (en) 2019-11-15 2019-11-15 Block synchronization method, device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911124322.6A CN110888892B (en) 2019-11-15 2019-11-15 Block synchronization method, device and storage medium

Publications (2)

Publication Number Publication Date
CN110888892A true CN110888892A (en) 2020-03-17
CN110888892B CN110888892B (en) 2023-06-16

Family

ID=69747717

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911124322.6A Active CN110888892B (en) 2019-11-15 2019-11-15 Block synchronization method, device and storage medium

Country Status (1)

Country Link
CN (1) CN110888892B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113259130A (en) * 2021-06-21 2021-08-13 腾讯科技(深圳)有限公司 Transaction data processing method, device, equipment and medium
CN114048270A (en) * 2022-01-14 2022-02-15 北京大学深圳研究生院 Method and computer-readable storage medium for block chain data synchronization

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104580447A (en) * 2014-12-29 2015-04-29 中国科学院计算机网络信息中心 Spatio-temporal data service scheduling method based on access heat
WO2018119585A1 (en) * 2016-12-26 2018-07-05 深圳前海达闼云端智能科技有限公司 Permission control method, apparatus and system for block chain, and node device
CN109960946A (en) * 2019-03-29 2019-07-02 百度在线网络技术(北京)有限公司 Method, apparatus, equipment and medium are determined based on the data temperature of block chain
KR20190089506A (en) * 2018-01-23 2019-07-31 박동화 System and method for e-contract with shared and distributed ledger coupled with outer storage devices
CN110365768A (en) * 2019-07-15 2019-10-22 腾讯科技(深圳)有限公司 Method of data synchronization, device, medium, the electronic equipment of distributed system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104580447A (en) * 2014-12-29 2015-04-29 中国科学院计算机网络信息中心 Spatio-temporal data service scheduling method based on access heat
WO2018119585A1 (en) * 2016-12-26 2018-07-05 深圳前海达闼云端智能科技有限公司 Permission control method, apparatus and system for block chain, and node device
KR20190089506A (en) * 2018-01-23 2019-07-31 박동화 System and method for e-contract with shared and distributed ledger coupled with outer storage devices
CN109960946A (en) * 2019-03-29 2019-07-02 百度在线网络技术(北京)有限公司 Method, apparatus, equipment and medium are determined based on the data temperature of block chain
CN110365768A (en) * 2019-07-15 2019-10-22 腾讯科技(深圳)有限公司 Method of data synchronization, device, medium, the electronic equipment of distributed system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
SHO NANAO ET AL: "Performance analysis of data block synchronization mechanism in coolstreaming", 《QTNA \'10: PROCEEDINGS OF THE 5TH INTERNATIONAL CONFERENCE ON QUEUEING THEORY AND NETWORK APPLICATIONS》 *
毛宁 等: "基于电商平台的区块链状态同步问题研究", 《现代计算机(专业版)》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113259130A (en) * 2021-06-21 2021-08-13 腾讯科技(深圳)有限公司 Transaction data processing method, device, equipment and medium
CN114048270A (en) * 2022-01-14 2022-02-15 北京大学深圳研究生院 Method and computer-readable storage medium for block chain data synchronization
CN114048270B (en) * 2022-01-14 2022-05-13 北京大学深圳研究生院 Method and computer-readable storage medium for block chain data synchronization

Also Published As

Publication number Publication date
CN110888892B (en) 2023-06-16

Similar Documents

Publication Publication Date Title
CN107332876B (en) Method and device for synchronizing block chain state
CN109242500B (en) Block chain transaction validity verification method and device and storage medium
CN107171810B (en) Verification method and device of block chain
CN107276765B (en) Processing method and device for consensus in block chain
CN109417691B (en) Bluetooth cluster online upgrading method and device
CN110995513B (en) Data sending and receiving method in Internet of things system, internet of things equipment and platform
CN111294390B (en) Block data rapid synchronization method, device, equipment and storage medium
US20230273912A1 (en) Data processing method and apparatus for blockchain network, computer device, and computer-readable storage medium
CN110597918A (en) Account management method and device and computer readable storage medium
CN111654399B (en) Networking method, device, equipment and storage medium based on SD-WAN
CN110597887A (en) Data management method, device and storage medium based on block chain network
CN110888892B (en) Block synchronization method, device and storage medium
CN111522874A (en) Block chain consensus method, block chain consensus device, computer equipment and storage medium
CN111177121A (en) Order data feedback method and device, computer equipment and storage medium
CN111367923A (en) Data processing method, data processing device, node equipment and storage medium
CN108389124B (en) Data processing method, data processing device, computer equipment and storage medium
US10764724B2 (en) Method and apparatus for implementing member resource processing
CN111124316A (en) Method and device for sharing storage space and computer readable storage medium
US10085175B2 (en) Load control method and apparatus for notification messages
CN103889021A (en) Low power and lossy network member updating method and DODAG root node
CN113660353B (en) Method, device, equipment and medium for managing Provisioner address based on Bluetooth Mesh
EP3174322A1 (en) Method for deleting notification resource, and common service entity
CN111314151B (en) Node management method, node management device, electronic equipment and computer readable storage medium
CN110471922B (en) Content extension method and device for accounting node and computer readable storage medium
CN113504981A (en) Task scheduling method and device, storage medium and electronic equipment

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