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

Block synchronization method, device and storage medium Download PDF

Info

Publication number
CN110888892B
CN110888892B CN201911124322.6A CN201911124322A CN110888892B CN 110888892 B CN110888892 B CN 110888892B CN 201911124322 A CN201911124322 A CN 201911124322A CN 110888892 B CN110888892 B CN 110888892B
Authority
CN
China
Prior art keywords
node
block
target
heat
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.)
Active
Application number
CN201911124322.6A
Other languages
Chinese (zh)
Other versions
CN110888892A (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 obtains the heat of each node in a first target node set, wherein the first node is any one node in a plurality of nodes, and the first target node set comprises at least one node in the plurality of nodes; the first node determines a second node from the first target node set according to the heat; the first node sends 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 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.

Description

Block synchronization method, device and storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a block synchronization method, apparatus, and storage medium.
Background
In the prior art, a method of block synchronization is that a node randomly requests a high-level block from a node or nodes in a block chain to achieve block synchronization. However, this approach may select a node with higher heat to request a block, which results in lower efficiency of block synchronization, while other nodes with lower heat in the blockchain are not reasonably utilized, which results in lower network traffic utilization.
Disclosure of Invention
The embodiment of the invention provides a block synchronization method, a device and a storage medium, which realize block synchronization by selecting nodes with lower heat, thereby being beneficial to improving the efficiency and flexibility of block synchronization and improving the utilization rate of network traffic.
In a first aspect, an embodiment of the present invention provides a block synchronization method applied to a blockchain network, where the blockchain network includes a plurality of nodes, the method includes:
a first node obtains the heat of each node in a first target node set, wherein the first node is any one node in a plurality of nodes, and the first target node set comprises at least one node in the plurality of nodes;
The first node determines a second node from the first target node set according to the heat;
the first node sends 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 send the target block to the first node.
In a second aspect, an embodiment of the present invention provides another block synchronization method applied to a blockchain network, where the blockchain network includes a plurality of nodes, the method includes:
a second node receives a synchronous block request sent by a first node, wherein the synchronous block request carries a block identifier, the first node is any one of the plurality of nodes, the second node is determined from a first target node set according to the heat degree, 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;
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 applied to a blockchain network, where the blockchain network includes a plurality of nodes, the apparatus includes:
the first acquisition module is used for acquiring the heat degree of each node in a first target node set by a first node, wherein the first node is any one node in the plurality of nodes, and the first target node set comprises at least one node in the plurality of nodes;
the determining module is used for determining a second node from the first target node set according to the heat degree by the first node;
the first sending module is configured to send a synchronization block request to the second node by using the first node, where the synchronization block request carries a block identifier, and the synchronization block request is configured to instruct the second node to obtain a target block corresponding to the block identifier in a blockchain, and send the target block to the first node.
In a fourth aspect, an embodiment of the present invention provides another block synchronization apparatus applied to a blockchain network, where the blockchain network includes a plurality of nodes, the apparatus includes:
the receiving module is used for receiving a synchronous block request sent by a first node, wherein the synchronous block request carries a block identifier, the first node is any one of the plurality of nodes, the second node is determined from a first target node set according to the heat, and the first target node set comprises at least one of the plurality of nodes;
The second obtaining module is used for responding to the synchronous block request by the second node to obtain a target block corresponding to the block identifier in the block chain;
and the second sending module is used for sending the target block to the first node by the second 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 of each node in a first target node set, wherein the first node is any one of the plurality of nodes, and the first target node set comprises at least one of the plurality of nodes;
determining a second node from the first target node set according to the heat;
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 second node, and the node includes: a processor and a memory, the processor to perform:
Receiving a synchronous block request sent by a first node, wherein the synchronous block request carries a block identifier, the first node is any one node of the plurality of nodes, the second node is determined from a first target node set according to the heat degree, and the first target node set comprises at least one node of the plurality of nodes;
responding to the synchronous block request to obtain 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, an embodiment of the present invention further provides a computer readable storage medium, where program instructions are stored, the program instructions being configured to implement the method according to the first or second aspect.
According to the embodiment of the invention, the heat degree of each node in the first target node set is obtained through the first node, the second node is determined from the first target node set according to the heat degree, so that a synchronous block request is sent to the second node, the synchronous block request carries a block identifier, 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 traffic is improved.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1a is a schematic diagram of a blockchain network according to an embodiment of the present invention;
FIG. 1b is a block chain architecture diagram according to an embodiment of the present invention;
FIG. 1c is a schematic diagram illustrating a process of generating a new block according to an embodiment of the present invention;
fig. 2 is a flowchart of 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 device according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of another block synchronization apparatus according to an embodiment of the present invention;
FIG. 6 is a schematic 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 of the embodiments of the present invention will be clearly described below with reference to the drawings in the embodiments of the present invention, and it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Some embodiments of the present invention are described in detail below with reference to the accompanying drawings. The following embodiments and features of the embodiments may be combined with each other without conflict.
The block synchronization method provided by the embodiment of the invention is applied to a block chain network, wherein the block chain network comprises a plurality of nodes, and communication connection can be established among all the nodes.
The blockchain network provided by embodiments of the present invention is schematically illustrated in the following with reference to fig. 1 a-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 communication connection between the nodes 111 can be established.
In one embodiment, the blockchain network 11 refers to a network for sharing data between nodes, and a plurality of nodes 111 may be included in the blockchain network. Each node 111 may receive input information during normal operation and maintain shared data (i.e., blockchains) within the blockchain network based on the received input information. In order To ensure information intercommunication in the blockchain network, information connection can exist between every two nodes, point-To-point (P2P) communication can be realized between any two nodes, and particularly P2P communication can be performed 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 merely 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 node identifier corresponding to the node identifier, and each node in the blockchain network 11 may store the node identifiers of other nodes in the blockchain network, so that the generated block may be broadcast to other nodes in the blockchain network according to the node identifiers of other nodes. Each node can maintain a node identification list shown in the following table, and the node names and the node identifications are correspondingly stored in the node identification list. The node identifier may be an internet protocol (Internet Protocol, IP) address, and any other information that can be used to identify the node, and the IP address is only illustrated in table 1.
TABLE 1
Node name Node identification
Node 1 117.114.151.174
Node 2 117.116.189.145
Node N 119.123.789.258
Wherein each node in the blockchain network stores one and the same blockchain. The blockchain is composed of a plurality of blocks, referring to fig. 1b, fig. 1b is a schematic diagram of a blockchain structure according to an embodiment of the present invention. The block chain consists 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 time stamp 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 father 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 father 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 are associated with the block data stored in the father block, and the safety of the input information in the block is ensured.
In generating each block in the blockchain, 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 receiving input information, a node where the blockchain is located checks the input information, stores the input information into a memory pool after the check is completed, and updates a hash tree used for recording the input information; then, updating the update time stamp to the time of receiving the input information, trying different random numbers, and calculating the characteristic value for a plurality of 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 eigenvalue algorithm used to calculate eigenvalues; version (version number) is version information of the related block protocol in the block chain; the prev_hash is the block header characteristic value of the parent block of the current block; the merkle_root is a characteristic value of input information; ntime is the update time of the update timestamp; the nbits is the current difficulty, is a fixed value in a period of time, and is determined again after exceeding a fixed period of time; x is a random number; TARGET is a eigenvalue threshold that can be determined from nbits.
Thus, when the random number meeting the formula is calculated, the information can be correspondingly stored to generate the block head and the block main body, and the current block is obtained. And then, the node where the blockchain is located sends the newly generated blocks to other nodes in the blockchain network where the newly generated blocks are located according to the node identifications of other nodes in the blockchain network, the other nodes verify the newly generated blocks, and the newly generated blocks are added into the blockchain stored in the newly generated blocks after the verification is completed.
Wherein, the nodes of the blockchain network 11 can run intelligent contracts, the intelligent contracts are code implementation for executing when certain conditions are met, developers can define contract logic through programming languages, issue the contract logic to the blockchain (intelligent contract registration), call keys or other event triggers for executing according to the logic of contract clauses to complete the contract logic, and simultaneously provide functions of upgrading and logging off the intelligent contracts.
The block synchronization method provided by the embodiment of the invention is schematically illustrated in the following with reference to fig. 2 to fig. 3.
Referring to fig. 2 in detail, fig. 2 is a flowchart of 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 performed by a first node in a blockchain network, and the first node may be any one of a plurality of nodes in the blockchain network. Specifically, the method of the embodiment of the invention comprises the following steps.
S201: the method comprises the steps that a first node obtains the heat of each node in a first target node set, wherein the first node is any one node in a plurality of nodes, and the first target node set comprises at least one node in the plurality of nodes.
In the embodiment of the invention, the first node may acquire the heat of each node in a first target node set, where the first node is any one node in the plurality of nodes, and the first target node set includes at least one node in the plurality of nodes.
In one embodiment, each node in the first target node set is a node that maintains the heat level of the first node, that is, the first node may receive the heat level sent by each node maintained by the first node, so that the first node may perform operations such as updating the heat level of each maintained node.
In one example, assuming that the first node maintains the heat of 3 nodes, node a, node b, and node c, it is determined that the first target node set is composed of node a, node b, and node c, so that the first node may obtain the respective heat transmitted by node a, node b, and node c.
In some embodiments, the heat degree of each node may be determined according to any one or more of the number of times each node is accessed within a preset duration, the amount of block data provided externally, 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 embodiments of the present invention are not specifically limited herein, and in one example, the heat degree of the node a is 5.
In one embodiment, the heat degree of each node may determine, according to the preset number of times, the corresponding relationship between the block data amount and the heat degree, the number of times each node is accessed in a preset duration and the heat degree corresponding to the block data amount provided externally.
In one example, assuming that the number of times that the node a is accessed within 30s is 5 and the amount of block data that is sent out to the outside is 1024 bits, the heat with the node a within 30s can be determined to be 6 according to the preset correspondence between the number of times, the amount of block data and the heat.
In one 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 the third node is accessed in a preset duration, an externally provided block data amount, and signature confirmation information of a node, and the third node is any node in the first target node set; the first node may update the heat of the third node according to the heartbeat packet. In some embodiments, the third node is a node that maintains a hotness for the first node. In some embodiments, the signature confirmation information of the node may be used to confirm the block data amount externally provided by the third node in the preset duration.
In one example, assuming that the third node is node b and that 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 is beneficial to the first node to select the second node for sending the synchronous block request according to the heat degree by acquiring the heat degree of each maintained node through the first node.
S202: and the first node determines a second node from the first target node set according to the heat.
In the embodiment of the present invention, the first node may determine, according to the heat, a second node from the first target node set.
In one embodiment, when the first node determines the second node from the first target node set according to the heat, the second node with the lowest current heat may be determined from the first target node set according to the heat.
In one example, assuming that the first node currently acquires the heat degree of the node a as 4, acquires the heat degree of the node b as 5, and acquires the heat degree of the node c as 3, the first node may determine that the node c with the lowest current heat degree is the second node.
Therefore, the embodiment of the invention is beneficial to improving the efficiency of acquiring the block when the synchronous block request is sent to the second node with the lowest current heat to acquire the block by determining the second node with the lowest current heat.
S203: the first node sends 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 send the target block to the first node.
In the 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 blockchain corresponding 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, etc., and embodiments of the present invention are not specifically limited. In one example, the block height carried in the sync block request is 100.
In one 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 acquire a target block in the blockchain corresponding 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 invention, the first node obtains the heat of each node in the first target node set, determines the second node from the first target node set according to the heat, and sends a synchronous block request to the second node, so that the second node can obtain a target block corresponding to the block identifier in the block chain according to the block identifier carried in the synchronous block request, and sends the target block to the first node. The synchronous blocks are obtained by selecting the nodes with lower heat, so that the efficiency and flexibility of block synchronization can be improved, and the utilization rate of network traffic can be improved.
Referring to fig. 3 in particular, fig. 3 is a flowchart of 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 performed by a second node in a blockchain network, and the second node may be any one of a plurality of nodes in the blockchain network.
S301: the method comprises the steps that a second node receives a synchronous block request sent by a first node, wherein the synchronous block request carries a block identifier, the first node is any one of a plurality of nodes, the second node is determined from a first target node set according to the heat degree, and the first target node set comprises at least one of the plurality of nodes.
In the embodiment of the present invention, the second node may receive a synchronization block request sent by the first node, where the synchronization block request carries a block identifier, the first node is any one node among the plurality of nodes, the second node is determined by the first node from a first target node set according to the heat, and the first target node set includes at least one node among the plurality of nodes. Specific embodiments are as described above and will not be described in detail herein.
S302: the second node responds to the synchronous block request to acquire a target block corresponding to the block identifier in a block chain.
In the embodiment of the present invention, the second node may obtain, in response to the synchronization block request, a target block in the blockchain corresponding to the block identifier.
In one embodiment, the second node may acquire the heat of the second node before the second node acquires the target block corresponding to the block identifier in the blockchain in response to the synchronous block request, and if the heat of the second node indicates that the heat of the second node does not reach the preset heat threshold, the second node may execute the step of acquiring the target block corresponding to the block identifier in the blockchain in response to the synchronous block request.
In an embodiment, if the heat of the second node indicates that the heat of the second node reaches the preset heat threshold, the second node may determine a fourth node with the lowest current heat 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 level of the second node indicates that the heat level of the second node reaches the preset heat level threshold, it may be determined that the second node cannot afford to request the sync block sent by the first node. In some embodiments, the nodes in the second set of target nodes are nodes for which the second node maintains a level of hotness.
In one example, assuming that the second node maintains a second target node set with heat including a node d and a node e, if the heat of the second node obtained when the second node obtains a synchronous block request sent by the first node is greater than a preset heat threshold, the second node may determine that a fourth node with the lowest current heat is the node e 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 synchronous block request to the node e according to the identification information of the node e.
Therefore, when the second node receives the request of the synchronous block, 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 request of the synchronous block to the fourth node with the low heat degree.
In one embodiment, when the second node's heat indicates that the second node's heat reaches the preset heat threshold, if the second node detects that each node in the second target node set has a heat higher than the first node's heat, 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 is currently unable to process, and ask the first node to send a synchronization block request to other nodes maintained by the first node.
In one embodiment, when the second node's heat indicates that the second node's heat reaches the preset heat 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 is currently unable to process, and ask the first node to send a synchronization block request to other nodes maintained by the first node.
S303: the second node sends the target block to the first node.
In the embodiment of the present invention, the second node may send the target block to the first node.
In one 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 in a preset duration, an amount of block data provided externally, and the 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 second node can receive the synchronous block request sent by the first node, and respond to the synchronous block request to obtain the target block corresponding to the block identifier carried in the synchronous block request in the block chain, 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 device according to an embodiment of the invention. Specifically, the apparatus is disposed in a blockchain network, where the blockchain network includes a plurality of nodes, and the apparatus includes: a first acquisition module 401, a determination module 402 and a first transmission 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 node in the plurality of nodes, and the first target node set includes at least one node in the plurality of 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;
a first sending module 403, configured to send a synchronization block request to the second node by using the first 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 blockchain corresponding 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 the third node is accessed in a preset time period, the block data amount provided externally and signature confirmation information of the node, and the third node is any node in the first target node set;
And the first node updates the heat of the third node according to the heartbeat packet.
Further, the determining module 402 is configured to, when the first node determines, according to the heat, a second node from the first target node set, specifically:
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 second node is determined from the first target node set according to the heat of each node in the first target node set, so that a synchronous block request is sent to the second node, the second node can acquire a target block corresponding to the block identifier in a block chain according to the block identifier carried in the synchronous block request, and the target block is sent to the first node. The synchronous blocks are obtained by selecting the nodes with lower heat, so that the efficiency and flexibility of block synchronization can be improved, and the utilization rate of network traffic can be improved.
Referring to fig. 5, fig. 5 is a schematic structural diagram of another block synchronization device according to an embodiment of the invention. Specifically, the apparatus is disposed in a blockchain network, where 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 a synchronization block request sent by a first node, where the synchronization block request carries a block identifier, the first node is any one node 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 node of the plurality of nodes;
a second obtaining module 502, configured to obtain, by the second node, a target block corresponding to the block identifier in a blockchain in response to the synchronous block request;
a second sending module 503, configured to send the target block to the first node by using the second node.
Further, the second obtaining module 502 is configured to, before the second node obtains, in response to the synchronization block request, a target block corresponding to the block identifier in the blockchain, further be configured to:
the second node obtains the heat 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 the preset heat degree threshold, the second node executes the step of responding to 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, 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 synchronous block request to the fourth node according to the identification information of the fourth node.
Further, the second sending module 503 is configured to, after the second node sends the target block to the first node, further be configured to:
the second node receives signature confirmation information sent by the first node after receiving the target block;
the second node transmits a heartbeat packet to the first node, wherein the heartbeat packet comprises the number of times the second node is accessed within a preset duration, the block data amount provided externally 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.
According to the embodiment of the invention, the target block corresponding to the block identifier carried in the synchronous block request in the block chain is obtained by receiving the synchronous block request sent by the first node and responding to the synchronous block request, so that the target block is sent 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. 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 includes: memory 601, and processor 602.
In an embodiment, the node further comprises a data interface 603, the data interface 603 being for transferring 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 (nonvolatile memory); the memory 601 may also include a combination of the above types of memories. The processor 602 may be a central processing unit (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 (programmable logic device, PLD), or a combination thereof. The PLD may be a complex programmable logic device (complex programmable logic device, CPLD), a field-programmable gate array (field-programmable gate array, FPGA), or any combination thereof.
The memory 601 is used for storing a program, and the processor 602 may call the program stored in the memory 601 for performing the following steps:
Acquiring the heat of each node in a first target node set, wherein the first node is any one of the plurality of nodes, and the first target node set comprises at least one of the plurality of nodes;
determining a second node from the first target node set according to the heat;
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 in a preset time period, the block data amount provided externally and signature confirmation information of the node, and the third node is any node in the first target node set;
and updating the heat of the third node according to the heartbeat packet.
Further, when the processor 602 determines, according to the heat, a second node from the first set of target nodes, the method is specifically configured to:
And determining a second node with the lowest current heat from the first target node set according to the heat.
According to the embodiment of the invention, the second node is determined from the first target node set according to the heat of each node in the first target node set, so that a synchronous block request is sent to the second node, the second node can acquire a target block corresponding to the block identifier in a block chain according to the block identifier carried in the synchronous block request, and the target block is sent to the first node. The synchronous blocks are obtained by selecting the nodes with lower heat, so that the efficiency and flexibility of block synchronization can be improved, and the utilization rate of network traffic can be improved.
Referring to fig. 7, fig. 7 is a schematic structural diagram of another node provided in an embodiment of the present invention, where the node is the same as the second node, and specifically includes: memory 701, processor 702.
In an embodiment, the node further comprises a data interface 703, the data interface 703 being for transferring data information between the node and other devices.
The memory 701 may include volatile memory; memory 701 may also include non-volatile memory (nonvolatile memory); memory 701 may also include a combination of the above types of memory. The processor 702 may be a central processing unit (central processing unit, CPU). The processor 702 may further comprise a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (programmable logic device, PLD), or a combination thereof. The PLD may be a complex programmable logic device (complex programmable logic device, CPLD), a field-programmable gate array (field-programmable gate array, FPGA), or any combination thereof.
The memory 701 is used for storing a program, and the processor 702 may call the program stored in the memory 701, for performing the following steps:
receiving a synchronous block request sent by a first node, wherein the synchronous block request carries a block identifier, the first node is any one node of the plurality of nodes, the second node is determined from a first target node set according to the heat degree, and the first target node set comprises at least one node of the plurality of nodes;
responding to the synchronous block request to obtain 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 obtains the target block corresponding to the block identifier in the blockchain in response to the synchronous block request, the processor is further configured to:
acquiring the heat 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 the preset heat degree threshold, executing the 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, 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 the second node is accessed within a preset time period, the block data amount provided externally 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.
According to the embodiment of the invention, the target block corresponding to the block identifier carried in the synchronous block request in the block chain is obtained by receiving the synchronous block request sent by the first node and responding to the synchronous block request, so that the target block is sent 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.
The embodiment of the present invention further provides a computer readable storage medium, where a computer program is stored, where the computer program when executed by a processor implements the method described in the embodiment corresponding to fig. 2 or fig. 3 of the present invention, and may also implement the apparatus corresponding to the embodiment corresponding to fig. 4 or fig. 5 of the present invention, 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) or the like, which are provided on the device. Further, the computer readable storage medium may also include both internal storage units and external storage devices of the device. The computer-readable storage medium is used to store 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.
Those skilled in the art will appreciate that implementing all or part of the above-described methods in accordance with the embodiments may be accomplished by way of a computer program stored on a computer readable storage medium, which when executed may comprise the steps 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 (Random Access Memory, RAM), or the like.
The above disclosure is only a few examples of the present invention, and it is not intended to limit the scope of the present invention, but it is understood by those skilled in the art that all or a part of the above embodiments may be implemented and equivalents thereof may be modified according to the scope of the present invention.

Claims (9)

1. A block synchronization method for use in a blockchain network, the blockchain network including a plurality of nodes, the method comprising:
a first node obtains the heat of each node in a first target node set, wherein the first node is any one node in a plurality of nodes, and the first target node set comprises at least one node in the plurality of nodes;
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 the third node is accessed in a preset time period, the block data amount provided externally and signature confirmation information of the node, and the third node is any node in the first target node set;
the first node updates the heat of the third node according to the heartbeat packet;
the first node determines a second node from the first target node set according to the heat;
the first node sends 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 send the target block to the first node.
2. The method of claim 1, wherein the first node determining a second node from the first set of target nodes based on the heat 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.
3. A block synchronization method for use in a blockchain network, the blockchain network including a plurality of nodes, the method comprising:
a second node receives a synchronous block request sent by a first node, wherein the synchronous block request carries a block identifier, the first node is any one of the plurality of nodes, the second node is determined from a first target node set according to the heat degree, 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;
the second node sends the target block to the first node;
the second node receives signature confirmation information sent by the first node after receiving the target block;
the second node transmits a heartbeat packet to the first node, wherein the heartbeat packet comprises the number of times the second node is accessed within a preset duration, the block data amount provided externally 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.
4. The method of claim 3, wherein the second node is further configured to, prior to obtaining a target block in a blockchain corresponding to the block identification in response to the synchronized block request:
the second node obtains the heat 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 the preset heat degree threshold, the second node executes the step of responding to the synchronous block request to acquire a target block corresponding to the block identifier in the block chain.
5. The method according to claim 4, wherein the method further comprises:
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 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 synchronous block request to the fourth node according to the identification information of the fourth node.
6. A block synchronization apparatus for use in a blockchain network, the blockchain network including a plurality of nodes therein, the apparatus comprising:
The first acquisition module is used for acquiring the heat degree of each node in a first target node set by a first node, wherein the first node is any one node in the plurality of nodes, and the first target node set comprises at least one node in the plurality of nodes;
the first acquisition module 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 in a preset time period, the block data amount provided externally and signature confirmation information of the node, and the third node is any node in the first target node set; updating the heat of the third node according to the heartbeat packet;
the determining module is used for determining a second node from the first target node set according to the heat degree by the first node;
the first sending module is configured to send a synchronization block request to the second node by using the first node, where the synchronization block request carries a block identifier, and the synchronization block request is configured to instruct the second node to obtain a target block corresponding to the block identifier in a blockchain, and send the target block to the first node.
7. A block synchronization apparatus for use in a blockchain network, the blockchain network including a plurality of nodes therein, the apparatus comprising:
the receiving module is used for receiving a synchronous block request sent by a first node, wherein the synchronous block request carries a block identifier, the first node is any one of the plurality of nodes, the second node is determined from a first target node set according to the heat, and the first target node set comprises at least one of the plurality of nodes;
the second obtaining module is used for responding to the synchronous block request by the second node to obtain a target block corresponding to the block identifier in the block chain;
the second sending module is used for sending the target block to the first node by the second node; 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 the second node is accessed within a preset time period, the block data amount provided externally 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 node of a blockchain network, characterized in that the node comprises a processor, a memory and a data interface for transferring data information between the node and other devices, the memory for storing program code, the processor for invoking the program code for performing the method according to any of claims 1-5.
9. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein program instructions, which when executed, are adapted to carry out the method according to any of claims 1-5.
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 CN110888892A (en) 2020-03-17
CN110888892B true 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)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113765675B (en) * 2021-06-21 2022-05-27 腾讯科技(深圳)有限公司 Transaction data processing method, device, equipment and medium
CN114048270B (en) * 2022-01-14 2022-05-13 北京大学深圳研究生院 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》.2010,第53-58页. *
基于电商平台的区块链状态同步问题研究;毛宁 等;《现代计算机(专业版)》;第2019年卷(第06期);第7-11页 *

Also Published As

Publication number Publication date
CN110888892A (en) 2020-03-17

Similar Documents

Publication Publication Date Title
CN107332876B (en) Method and device for synchronizing block chain state
CN107276765B (en) Processing method and device for consensus in block chain
CN110995513B (en) Data sending and receiving method in Internet of things system, internet of things equipment and platform
CN110888892B (en) Block synchronization method, device and storage medium
US10469620B2 (en) Method for transferring a new software version to at least one electricity meter via a communication network
CN110597918A (en) Account management method and device and computer readable storage medium
CN105871963B (en) Method and device for processing resource operation request
CN112202877A (en) Gateway linkage method, gateway, cloud server and user terminal
CN110417876B (en) Session method, node server in distributed system and master control equipment
US20170295452A1 (en) Method and Registration Node for Managing Application Resource in Machine to Machine (M2M)
KR102026841B1 (en) Data processing methods, apparatus, and devices
US10637748B2 (en) Method and apparatus for establishing interface between VNFMS, and system
CN106790354B (en) Communication method and device for preventing data congestion
CN111124316A (en) Method and device for sharing storage space and computer readable storage medium
EP3319346A1 (en) Method and apparatus for implementing member resource processing
EP3174322A1 (en) Method for deleting notification resource, and common service entity
CN110572857A (en) Network connection processing method and device
CN111464395B (en) Method and device for creating blockchain and readable storage medium
CN113660353B (en) Method, device, equipment and medium for managing Provisioner address based on Bluetooth Mesh
CN107563942B (en) Logistics data batch processing method, logistics processing system and processing device
US11134412B2 (en) Wireless communication device, wireless communication method and non-transitory computer readable medium
CN110839034B (en) Communication connection control method and related equipment
CN114189384B (en) Service processing method, device, equipment and storage medium
WO2017058110A1 (en) Method and system for collaborative security key generation for ad-hoc internet of things (iot) nodes
CN110932980B (en) Communication method, terminal, and computer-readable storage medium

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