CN115174598A - Block synchronization method, block chain system, device and storage medium - Google Patents
Block synchronization method, block chain system, device and storage medium Download PDFInfo
- Publication number
- CN115174598A CN115174598A CN202211064387.8A CN202211064387A CN115174598A CN 115174598 A CN115174598 A CN 115174598A CN 202211064387 A CN202211064387 A CN 202211064387A CN 115174598 A CN115174598 A CN 115174598A
- Authority
- CN
- China
- Prior art keywords
- nvp
- block
- message
- cluster
- node
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 55
- 238000004590 computer program Methods 0.000 claims description 24
- 230000008569 process Effects 0.000 description 10
- 238000010586 diagram Methods 0.000 description 7
- 238000012545 processing Methods 0.000 description 7
- 238000004891 communication Methods 0.000 description 6
- 238000012790 confirmation Methods 0.000 description 5
- 230000005540 biological transmission Effects 0.000 description 4
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 230000006870 function Effects 0.000 description 3
- 230000001360 synchronised effect Effects 0.000 description 3
- 238000013500 data storage Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000005192 partition Methods 0.000 description 1
- 230000000644 propagated effect Effects 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1095—Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Mobile Radio Communication Systems (AREA)
Abstract
Description
技术领域technical field
本申请涉及区块链技术领域,特别涉及一种区块同步方法、区块链系统、设备和存储介质。The present application relates to the field of blockchain technology, and in particular, to a block synchronization method, blockchain system, equipment and storage medium.
背景技术Background technique
由于区块链具有不可篡改性,所以区块链技术飞速发展,且已经在各个领域中得到广泛应用。在一些场景中,区块链系统中包括多个共识节点(Validating Peer,VP)和多个非共识节点(None-Validating Peer,NVP)。VP需要参与区块共识过程,NVP无需参与区块共识过程,而为了保持节点中数据的一致性,NVP需要同步已得到VP的共识的区块。Due to the immutability of blockchain, blockchain technology has developed rapidly and has been widely used in various fields. In some scenarios, the blockchain system includes multiple consensus nodes (Validating Peer, VP) and multiple non-consensus nodes (None-Validating Peer, NVP). VP needs to participate in the block consensus process, NVP does not need to participate in the block consensus process, and in order to maintain the consistency of the data in the nodes, NVP needs to synchronize the blocks that have obtained the consensus of VP.
相关技术中,多个VP中的每个VP可以直接与多个NVP进行通信连接。多个VP在完成对某一区块的共识后,在区块链中添加该区块。之后任意一个VP可以将该区块直接发送给与这个VP进行通信连接的多个NVP,以实现多个NVP中的每个NVP对这个区块的同步。In the related art, each VP in the multiple VPs may directly communicate with the multiple NVPs. After multiple VPs complete the consensus on a block, the block is added to the blockchain. Afterwards, any VP can directly send the block to multiple NVPs in communication with the VP, so as to realize the synchronization of the block by each NVP in the multiple NVPs.
然而,在上述方式中,若VP需要共识的区块数量越来越多,且与VP进行通信连接的NVP的数量持续增长,则VP会非常繁忙。这会导致VP的压力比较大,从而影响区块共识效率。However, in the above method, if the number of blocks that the VP needs to agree on is increasing, and the number of NVPs communicating with the VP continues to grow, the VP will be very busy. This will lead to a large pressure on the VP, thus affecting the efficiency of block consensus.
发明内容SUMMARY OF THE INVENTION
本申请提供了一种区块同步方法、区块链系统、设备和存储介质,可以减轻区块链系统中共识节点的压力,提高区块共识效率。所述技术方案如下:The present application provides a block synchronization method, block chain system, equipment and storage medium, which can reduce the pressure of consensus nodes in the block chain system and improve the efficiency of block consensus. The technical solution is as follows:
第一方面,提供了一种区块同步方法,应用于区块链系统,所述区块链系统包括多个共识节点VP和m个非共识节点NVP集群,所述多个VP中的m个VP与所述m个NVP集群一一对应,所述m个NVP集群中每个NVP集群包括第一NVP和至少一个第二NVP,所述第一NVP为与对应的VP进行通信的NVP,所述第一NVP与所述至少一个第二NVP中的每个第二NVP之间均具有网络路径,所述m为正整数,所述方法包括:In a first aspect, a block synchronization method is provided, applied to a blockchain system, the blockchain system includes a plurality of consensus nodes VP and m non-consensus node NVP clusters, m of the plurality of VPs VPs are in one-to-one correspondence with the m NVP clusters, each NVP cluster in the m NVP clusters includes a first NVP and at least one second NVP, and the first NVP is an NVP that communicates with the corresponding VP, so There is a network path between the first NVP and each of the at least one second NVP, the m is a positive integer, and the method includes:
所述多个VP每完成对一个区块的共识并将所述区块添加至区块链后,所述m个VP中的每个VP向对应的NVP集群中的所述第一NVP发送携带有所述区块的第一消息;After the multiple VPs complete the consensus on a block and add the block to the blockchain, each of the m VPs sends a message to the first NVP in the corresponding NVP cluster. there is the first message of the block;
所述m个NVP集群中每个NVP集群中的每个NVP若接收到所述第一消息,则将所述第一消息携带的所述区块存储至区块链,并向同一NVP集群中相邻的NVP发送所述第一消息。If each NVP in each NVP cluster of the m NVP clusters receives the first message, it stores the block carried in the first message in the blockchain, and sends it to the same NVP cluster. The adjacent NVP sends the first message.
在本申请中,区块链系统包括多个VP和m个NVP集群,该多个VP中的m个VP与该m个NVP集群一一对应,且m个NVP集群中每个NVP集群包括第一NVP和至少一个第二NVP。第一NVP为与对应的VP进行通信的NVP,第一NVP与至少一个第二NVP中的每个第二NVP之间均具有网络路径,所以NVP集群中的第一NVP既可以与对应的VP进行通信,也可以与同一NVP集群中的其他NVP进行通信。该多个VP每完成对一个区块的共识并将该区块添加至区块链后,该m个VP中的每个VP向对应的NVP集群中的第一NVP发送携带有该区块的第一消息。该m个NVP集群中每个NVP集群中的每个NVP若接收到第一消息,则将第一消息携带的该区块存储至区块链,并向同一NVP集群中相邻的NVP发送第一消息,如此每个NVP集群中的每个NVP都可以同步该区块。这种情况下,m个VP中的每个VP只需要向对应的NVP集群中的第一NVP发送携带有该区块的第一消息,就可以实现对应的NVP集群中的每个NVP对该区块的同步,从而减轻了VP的压力,进而可以提高区块共识效率。In this application, the blockchain system includes multiple VPs and m NVP clusters, m VPs in the multiple VPs are in one-to-one correspondence with the m NVP clusters, and each NVP cluster in the m NVP clusters includes the One NVP and at least one second NVP. The first NVP is an NVP that communicates with the corresponding VP, and there is a network path between the first NVP and each second NVP in the at least one second NVP, so the first NVP in the NVP cluster can both communicate with the corresponding VP It can also communicate with other NVPs in the same NVP cluster. After the multiple VPs complete the consensus on a block and add the block to the blockchain, each of the m VPs sends a message carrying the block to the first NVP in the corresponding NVP cluster. First news. If each NVP in each NVP cluster in the m NVP clusters receives the first message, it stores the block carried in the first message in the blockchain, and sends the first message to the adjacent NVP in the same NVP cluster. A message so that every NVP in every NVP cluster can sync the block. In this case, each VP in the m VPs only needs to send the first message carrying the block to the first NVP in the corresponding NVP cluster, so that each NVP in the corresponding NVP cluster can perform the The synchronization of blocks reduces the pressure on VPs, which in turn can improve the efficiency of block consensus.
第二方面,提供了一种区块链系统,所述区块链系统包括多个共识节点VP和m个非共识节点NVP集群,所述多个VP中的m个VP与所述m个NVP集群一一对应,所述m个NVP集群中每个NVP集群包括第一NVP和至少一个第二NVP,所述第一NVP为与对应的VP进行通信的NVP,所述第一NVP与所述至少一个第二NVP中的每个第二NVP之间均具有网络路径,所述m为正整数;In a second aspect, a blockchain system is provided, the blockchain system includes multiple consensus node VPs and m non-consensus node NVP clusters, m VPs in the multiple VPs and the m NVPs The clusters are in one-to-one correspondence, and each NVP cluster in the m NVP clusters includes a first NVP and at least one second NVP, the first NVP is an NVP that communicates with a corresponding VP, and the first NVP is connected to the There is a network path between each of the at least one second NVP, and the m is a positive integer;
所述m个VP中的每个VP,用于在所述多个VP每完成对一个区块的共识并将所述区块添加至区块链后,向对应的NVP集群中的所述第一NVP发送携带有所述区块的第一消息;Each VP in the m VPs is used for sending each VP to the first block in the corresponding NVP cluster after the multiple VPs complete the consensus on a block and add the block to the blockchain. An NVP sends the first message carrying the block;
所述m个NVP集群中每个NVP集群中的每个NVP,用于若接收到所述第一消息,则将所述第一消息携带的所述区块存储至区块链,并向同一NVP集群中相邻的NVP发送所述第一消息。Each NVP in each NVP cluster in the m NVP clusters is configured to, if receiving the first message, store the block carried in the first message in the blockchain, and send the same to the same NVP. Neighboring NVPs in the NVP cluster send the first message.
第三方面,提供了一种计算机设备,所述计算机设备包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行时实现上述的区块同步方法。In a third aspect, there is provided a computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being executed by the processor When the above block synchronization method is implemented.
第四方面,提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现上述的区块同步方法。In a fourth aspect, a computer-readable storage medium is provided, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the foregoing block synchronization method is implemented.
第五方面,提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述的区块同步方法的步骤。In a fifth aspect, there is provided a computer program product comprising instructions that, when executed on a computer, cause the computer to perform the steps of the block synchronization method described above.
可以理解的是,上述第二方面、第三方面、第四方面、第五方面的有益效果可以参见上述第一方面中的相关描述,在此不再赘述。It can be understood that, for the beneficial effects of the second aspect, the third aspect, the fourth aspect, and the fifth aspect, reference may be made to the relevant descriptions in the first aspect, which will not be repeated here.
附图说明Description of drawings
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the technical solutions in the embodiments of the present application more clearly, the following briefly introduces the drawings that are used in the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can also be obtained from these drawings without creative effort.
图1是本申请实施例提供的一种区块链系统的结构示意图;1 is a schematic structural diagram of a blockchain system provided by an embodiment of the present application;
图2是本申请实施例提供的一种区块同步方法的流程图;2 is a flowchart of a block synchronization method provided by an embodiment of the present application;
图3是本申请实施例提供的一种区块链的示意图;3 is a schematic diagram of a blockchain provided by an embodiment of the present application;
图4是本申请实施例提供的另一种区块链的示意图;4 is a schematic diagram of another blockchain provided by an embodiment of the present application;
图5是本申请实施例提供的一种计算机设备的结构示意图。FIG. 5 is a schematic structural diagram of a computer device provided by an embodiment of the present application.
具体实施方式Detailed ways
为使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施方式作进一步地详细描述。In order to make the objectives, technical solutions and advantages of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.
应当理解的是,本申请提及的“多个”是指两个或两个以上。在本申请的描述中,除非另有说明,“/”表示或的意思,比如,A/B可以表示A或B;本文中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,比如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,为了便于清楚描述本申请的技术方案,采用了“第一”、“第二”等字样对功能和作用基本相同的相同项或相似项进行区分。本领域技术人员可以理解“第一”、“第二”等字样并不对数量和执行次序进行限定,并且“第一”、“第二”等字样也并不限定一定不同。It should be understood that the "plurality" mentioned in this application refers to two or more. In the description of this application, unless otherwise stated, "/" means or means, for example, A/B can mean A or B; "and/or" in this document is only an association relationship that describes an associated object, It means that there can be three kinds of relationships, for example, A and/or B, it can mean that A exists alone, A and B exist at the same time, and B exists alone. In addition, in order to facilitate the clear description of the technical solutions of the present application, words such as "first" and "second" are used to distinguish the same items or similar items with basically the same function and effect. Those skilled in the art can understand that words such as "first" and "second" do not limit the quantity and execution order, and the words "first" and "second" are not necessarily different.
在对本申请实施例进行详细地解释说明之前,先对本申请实施例的应用场景予以说明。Before explaining the embodiments of the present application in detail, the application scenarios of the embodiments of the present application are described first.
本申请实施例提供的区块同步方法可以应用于将区块链系统的VP中存储的区块同步至NVP集群中每个NVP的场景中。The block synchronization method provided in the embodiment of the present application can be applied to the scenario of synchronizing the blocks stored in the VP of the blockchain system to each NVP in the NVP cluster.
例如,在联盟链场景中,一种联盟链包括多个省级机构的节点以及一些省级机构下属的市级单位的节点。多个省级机构的节点(即VP)可以参与区块共识过程,而一个省级机构下属的市级单位的节点(即NVP)无需参与区块共识过程,这种情况下,本申请实施例提供的区块同步方法可以应用于此场景中。For example, in a consortium chain scenario, a consortium chain includes nodes of multiple provincial-level institutions and nodes of municipal-level units subordinate to some provincial-level institutions. Nodes (ie VPs) of multiple provincial institutions can participate in the block consensus process, while nodes (ie NVPs) of municipal units subordinate to a provincial institution do not need to participate in the block consensus process. In this case, the embodiments of this application The provided block synchronization method can be used in this scenario.
具体地,该多个省级机构的节点中任意的一个节点每接收到客户端发送的交易,生成新的区块,并向该多个省级机构中其余省级机构的节点发送该区块,以使该多个省级机构的节点对该区块进行共识处理。在该多个省级机构的节点完成对该区块的共识处理后,每个省级机构的节点可以向自己下属的多个市级单位中与自己通信的一个市级单位的节点发送该区块。之后,这个市级单位的节点接收到该区块后,将该区块存储至自身的区块链,并向相邻的市级单位的节点发送该区块。以此类推,一个省级机构下属的多个市级单位中每个市级单位的节点接收到该区块后,可以将该区块存储至自身的区块链中,并向自身相邻的市级单位的节点发送该区块。如此,一个省级机构下属的多个市级单位中每个市级单位的节点均可以将该区块同步至自身的区块链中。这种情况下,区块链系统中每个省级机构的节点只需向与自己通信的一个市级单位的节点发送该区块,即可实现下属的多个市级单位中每个市级单位的节点对该区块的同步,如此,减轻了区块链系统中多个省级机构的节点的压力,提高了区块共识效率。Specifically, each time any one of the nodes of the multiple provincial-level institutions receives a transaction sent by the client, a new block is generated, and the block is sent to the nodes of the remaining provincial-level institutions among the multiple provincial-level institutions , so that the nodes of the multiple provincial institutions can perform consensus processing on the block. After the nodes of the multiple provincial institutions complete the consensus processing of the block, the nodes of each provincial institution can send the block to the node of a municipal unit that communicates with itself among the multiple municipal units subordinate to it. piece. After that, after the node of this municipal unit receives the block, it stores the block in its own blockchain, and sends the block to the node of the adjacent municipal unit. By analogy, after the node of each municipal unit in the multiple municipal units subordinate to a provincial institution receives the block, it can store the block in its own blockchain and send it to its neighbors. The node of the municipal unit sends the block. In this way, the node of each municipal unit among the multiple municipal units subordinate to a provincial institution can synchronize the block to its own blockchain. In this case, the node of each provincial-level institution in the blockchain system only needs to send the block to the node of a municipal-level unit that communicates with itself, and then each municipal-level unit of the subordinate municipal-level units can be realized. The nodes of the unit synchronize the block, thus reducing the pressure on the nodes of multiple provincial institutions in the blockchain system and improving the efficiency of block consensus.
下面对本申请实施例涉及的区块链系统的相关内容予以说明。The following describes the relevant content of the blockchain system involved in the embodiments of the present application.
图1是本申请实施例提供的一种区块链系统的结构示意图。FIG. 1 is a schematic structural diagram of a blockchain system provided by an embodiment of the present application.
参见图1,区块链系统100是指用于进行节点与节点之间数据共享的系统,区块链系统100中包括多个VP101和m个NVP集群102,m个NVP集群102中的每个NVP集群102中包括多个NVP103,m为正整数。Referring to FIG. 1 , the blockchain system 100 refers to a system for data sharing between nodes, the blockchain system 100 includes a plurality of
多个VP101是区块链系统中需要参与区块共识过程的节点。m个NVP集群102中每个NVP集群102中的每个NVP103是无需参与区块共识过程的节点。Multiple VP101s are nodes in the blockchain system that need to participate in the block consensus process. Each
多个VP101在正常工作时可以接收到输入信息,并基于接收到的输入信息维护区块链系统100内的共享数据。多个VP101之间可以存在信息连接,且多个VP101之间可以通过该信息连接进行信息传输。比如,当区块链系统100中的任意的一个VP101接收到客户端发送的输入信息时,区块链系统100中的其他VP101便根据共识算法获取该输入信息,并将该输入信息作为共享数据中的数据进行存储。A plurality of
除此之外,多个VP101中的m个VP101与m个NVP集群102一一对应,对于m个VP101中任意的一个VP101,这个VP101可以与m个NVP集群102中对应的NVP集群102进行通信。区块链系统100中的多个VP101将该输入信息作为共享数据中的数据进行存储之后,还可以与对应的NVP集群102进行通信,即向对应的NVP集群102发送该输入信息,以使对应的NVP集群102中的多个NVP103将该输入信息作为共享数据中的数据进行存储。In addition, the m VP101s in the multiple VP101 correspond to the
其中,区块链系统100中的VP101是与对应的NVP集群102中的一个NVP103进行通信,也即区块链系统100中的VP101是只向对应的NVP集群102中的一个NVP103发送消息,从而可以减轻区块链系统100中多个VP101的压力,进而可以提高区块链系统100的多个VP101的性能。The VP101 in the blockchain system 100 communicates with one NVP103 in the
为了保证区块链系统100中每个节点中存储的共享数据的一致性,每个NVP集群102中的多个NVP103需要同步对应的VP101中存储的该输入数据。In order to ensure the consistency of the shared data stored in each node in the blockchain system 100,
每个NVP集群102中的多个NVP103包括第一NVP103和至少一个第二NVP103,第一NVP103为所在的NVP集群102中与对应的VP101进行通信的NVP103,也就是说区块链系统100中的一个VP101是向对应NVP集群102中的第一NVP103发送该输入信息。其中,每个NVP集群102中可以任意添加新的NVP103,而这不会影响到区块链系统100中VP101向对应的NVP集群102发送消息的能力,所以区块链系统100中的每个NVP集群102的扩展性较强。The
另外,第一NVP103与至少一个第二NVP103中的每个第二NVP103之间均具有网络路径。网络路径用于指示多个NVP103之间的数据传输通道,第一NVP103可以通过该网络路径向至少一个第二NVP103传输数据。两个NVP103之间的网络路径中可能存在多个NVP103,此时两个NVP103可以进行间接通信。两个NVP103之间的网络路径也可能不存在其他NVP103,也即两个NVP103可以进行直接通信,也即这两个NVP103为相邻的NVP103。In addition, there is a network path between the
多个NVP103中的第一NVP103接收到该输入信息后,可以通过网络路径对该输入信息进行信息传输,以使多个NVP103中的其余第二NVP103也会接收到该输入信息。如此,多个NVP103中的每个NVP103均会将该输入信息作为共享数据中的数据进行存储,以实现区块链系统100中的全部节点上存储的数据一致。也即,区块链系统100中的每个节点均存储一条相同的区块链。After receiving the input information, the
区块链系统100具有分布式数据存储、点对点传输、共识机制、加密算法等计算机技术。区块链系统100是一个分布式的共享账本和数据库,具有去中心化、不可篡改、全程留痕、可以追溯、集体维护、公开透明等特点。这些特点保证了区块链的共享开放、真实完整和安全可靠。The blockchain system 100 has computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. The blockchain system 100 is a distributed shared ledger and database, which has the characteristics of decentralization, non-tampering, full traces, traceability, collective maintenance, openness and transparency, etc. These features ensure the shared openness, authenticity, integrity, security and reliability of the blockchain.
区块链系统100中的多个VP101和m个NVP集群102可以执行下文图2实施例所述的区块同步方法,来实现将区块链系统100的VP101中存储的区块(即上文所说的共享数据)同步至NVP集群102中的每个NVP103。The
下面对本申请实施例提供的区块同步方法进行详细地解释说明。The block synchronization method provided by the embodiments of the present application will be explained in detail below.
图2是本申请实施例提供的一种区块同步方法的流程图。该方法可以应用于区块链系统。参见图2,该方法包括以下步骤。FIG. 2 is a flowchart of a block synchronization method provided by an embodiment of the present application. This method can be applied to blockchain systems. Referring to Figure 2, the method includes the following steps.
步骤201:多个VP每完成对一个区块的共识并将该区块添加至区块链后,该多个VP中m个VP中的每个VP向对应的NVP集群中的第一NVP发送携带有该区块的第一消息。Step 201: After multiple VPs complete consensus on a block and add the block to the blockchain, each of the m VPs in the multiple VPs sends a message to the first NVP in the corresponding NVP cluster Carry the first message of the block.
第一NVP为同一NVP集群中与对应的VP进行通信的NVP,同一NVP集群中只存在一个第一NVP,也就是说该多个VP中m个VP中的每个VP是向对应的NVP集群中的一个NVP发送携带有该区块的第一消息。The first NVP is an NVP that communicates with the corresponding VP in the same NVP cluster, and there is only one first NVP in the same NVP cluster, that is to say, each of the m VPs in the multiple VPs is directed to the corresponding NVP cluster. One of the NVPs sends the first message carrying the block.
第一消息中携带该区块,第一消息用于指示接收到第一消息的NVP对第一消息中携带的区块进行存储。可选地,第一消息可以为GOSSIP(流行病协议)消息,当然,第一消息也可以为其他类型的消息,本申请实施例对此不作限定。The block is carried in the first message, and the first message is used to instruct the NVP receiving the first message to store the block carried in the first message. Optionally, the first message may be a GOSSIP (epidemic protocol) message. Of course, the first message may also be other types of messages, which are not limited in this embodiment of the present application.
由于本申请实施例提供的区块链系统中的m个NVP集群中每个NVP集群中的每个NVP无需参与区块的共识过程,所以该m个VP中的每个VP可以向对应的NVP集群发送携带有该区块的第一消息,以使对应的NVP集群获得该区块并存储,从而保证区块链系统中每个节点存储的区块链的一致性。Since each NVP in each NVP cluster in the m NVP clusters in the blockchain system provided by the embodiment of this application does not need to participate in the consensus process of the block, each VP in the m VPs can report to the corresponding NVP The cluster sends the first message carrying the block, so that the corresponding NVP cluster obtains and stores the block, thereby ensuring the consistency of the blockchain stored by each node in the blockchain system.
这种情况下,该m个VP中每个VP对应的NVP集群中第一NVP可以接收到携带有该区块的第一消息,那么对应的NVP集群中的第一NVP可以对该区块进行存储。且m个VP中的每个VP只需向对应的NVP集群中的第一NVP发送第一消息,而不需要向对应的NVP集群中的每个NVP发送第一消息。如此,减轻了每个VP的压力。In this case, the first NVP in the NVP cluster corresponding to each VP of the m VPs can receive the first message carrying the block, and the first NVP in the corresponding NVP cluster can perform the operation on the block. storage. Moreover, each VP in the m VPs only needs to send the first message to the first NVP in the corresponding NVP cluster, and does not need to send the first message to each NVP in the corresponding NVP cluster. In this way, the pressure on each VP is relieved.
值得注意的是,该m个VP中的每个VP向对应的NVP集群中的第一NVP发送携带有该区块的第一消息之前,该m个NVP集群中任意的一个NVP集群还可以选举出一个主NVP。It is worth noting that, before each VP of the m VPs sends the first message carrying the block to the first NVP in the corresponding NVP cluster, any one of the m NVP clusters can also be elected. out a main NVP.
一个NVP集群的主NVP用于与对应的VP进行通信,也即主NVP为第一NVP,一个NVP集群中除主NVP之外的其他NVP为从NVP,一个NVP集群中的从NVP为第二NVP。也即一个NVP集群中存在一个主NVP和至少一个从NVP。The master NVP of an NVP cluster is used to communicate with the corresponding VP, that is, the master NVP is the first NVP, other NVPs except the master NVP in an NVP cluster are slave NVPs, and the slave NVP in an NVP cluster is the second NVP NVP. That is, there is one master NVP and at least one slave NVP in an NVP cluster.
进一步地,该m个NVP集群中任意的一个NVP集群选举出一个主NVP(即第一NVP)之后,这个NVP集群中的第一NVP可以向对应的VP发送第一通知消息。Further, after any one of the m NVP clusters elects a master NVP (ie, the first NVP), the first NVP in the NVP cluster may send a first notification message to the corresponding VP.
第一通知消息用于指示发送第一通知消息的NVP已当选所在NVP集群的主NVP。这种情况下,发送第一通知消息的NVP为所在NVP集群中与对应的VP进行通信的NVP,则之后对应的VP将该区块添加至区块链后可以向这个NVP集群中已当选主NVP的NVP(即第一NVP)发送第一消息,从而保证对应的VP可以只向这个NVP集群的第一NVP发送第一消息。The first notification message is used to indicate that the NVP sending the first notification message has been elected as the master NVP of the NVP cluster where it is located. In this case, the NVP sending the first notification message is the NVP in the NVP cluster that communicates with the corresponding VP, then the corresponding VP can add the block to the blockchain after adding the block to the NVP cluster. The NVP of the NVP (ie, the first NVP) sends the first message, so as to ensure that the corresponding VP can only send the first message to the first NVP of this NVP cluster.
可选地,该m个NVP集群中任意的一个NVP集群可以通过动态选举的方式选举出一个主NVP。Optionally, any one of the m NVP clusters may elect a master NVP through dynamic election.
如此,在这个NVP集群选举出的主NVP宕机时,会重新选举出一个主NVP,来保证一个NVP集群中一直存在一个第一NVP与对应的VP进行通信,从而提高了这个NVP集群的活性。In this way, when the primary NVP elected by the NVP cluster goes down, a primary NVP will be re-elected to ensure that there is always a first NVP in an NVP cluster to communicate with the corresponding VP, thereby improving the activity of the NVP cluster .
具体地,该m个NVP集群中任意的一个NVP集群通过动态选举的方式选举出一个主NVP的操作可以通过如下步骤(1)-步骤(4)实现。Specifically, the operation of electing a master NVP by any one of the m NVP clusters through dynamic election may be implemented through the following steps (1) to (4).
(1)一个NVP集群整体启动后,这个NVP集群中至少一个NVP中的每个NVP向同一NVP集群中的其他NVP广播携带自身的节点标识的第二消息。(1) After an NVP cluster is started as a whole, each NVP in at least one NVP in the NVP cluster broadcasts a second message carrying its own node identifier to other NVPs in the same NVP cluster.
一个NVP集群整体启动是指这个NVP集群中的所有NVP中的每个NVP均启动,也即每个NVP开始进入工作状态。The overall startup of an NVP cluster means that each NVP in all NVPs in the NVP cluster is started, that is, each NVP starts to enter a working state.
该至少一个NVP为这个NVP集群整体启动后这个NVP集群中想要申请成为主NVP的NVP。The at least one NVP is an NVP in the NVP cluster that wants to apply to be the master NVP after the NVP cluster is started as a whole.
某个NVP的节点标识用于唯一标识这个NVP,例如,某个NVP的节点标识可以为这个NVP的编号、IP(Internet Protocol,互联网协议)地址等。The node identifier of a certain NVP is used to uniquely identify the NVP, for example, the node identifier of a certain NVP may be the serial number of the NVP, an IP (Internet Protocol, Internet Protocol) address, and the like.
第二消息中携带节点标识,第二消息用于指示第二消息携带的节点标识所标识的NVP申请成为主NVP。可选地,第二消息可以为GOSSIP消息,当然,第二消息也可以为其他类型的消息,本申请实施例对此不作限定。The second message carries the node identifier, and the second message is used to indicate that the NVP identified by the node identifier carried in the second message applies for becoming the master NVP. Optionally, the second message may be a GOSSIP message. Of course, the second message may also be other types of messages, which are not limited in this embodiment of the present application.
由于一个NVP集群整体启动后,这个NVP集群中可能不存在第一NVP,也即这个NVP集群中没有与对应的VP进行通信的NVP,那么对应的VP在将该区块添加至区块链后,会不知道向这个NVP集群中的哪个NVP发送携带该区块的第一消息。所以在这个NVP集群整体启动后,需要先选举出一个主NVP,也即得到这个NVP集群的第一NVP。此时这个NVP集群中的每个NVP均有申请成为主NVP的权利,所以这个NVP集群中任意的一个NVP若想申请成为主NVP,则可以向这个NVP集群中广播第二消息,以申请成为这个NVP集群的主NVP。After an NVP cluster is started as a whole, the first NVP may not exist in the NVP cluster, that is, there is no NVP in the NVP cluster that communicates with the corresponding VP, then the corresponding VP adds the block to the blockchain after adding the block to the blockchain. , it will not know which NVP in this NVP cluster to send the first message carrying the block. Therefore, after the overall startup of the NVP cluster, it is necessary to elect a master NVP, that is, to obtain the first NVP of the NVP cluster. At this time, each NVP in this NVP cluster has the right to apply to become the master NVP, so if any NVP in this NVP cluster wants to apply to become the master NVP, it can broadcast a second message to this NVP cluster to apply for becoming the master NVP The primary NVP for this NVP cluster.
(2)该至少一个NVP中任意的一个NVP在广播第二消息后的第一预设时长内接收其他NVP广播的第二消息。(2) Any one NVP of the at least one NVP receives the second message broadcast by other NVPs within a first preset time period after broadcasting the second message.
第一预设时长可以预先进行设置,且第一预设时长可以设置的较大,以保证任意的一个NVP可以接收到其他NVP中的每个NVP广播的携带自身的节点标识的第二消息。例如第一预设时长可以设置为5分钟。The first preset duration can be set in advance, and the first preset duration can be set to be larger, so as to ensure that any one NVP can receive the second message broadcasted by each NVP in other NVPs and carrying its own node identifier. For example, the first preset duration may be set to 5 minutes.
这种情况下,该至少一个NVP中任意的一个NVP在广播第二消息后,可以接收其他NVP广播的第二消息,以知道这个NVP集群中还有哪些NVP想要申请成为主NVP。In this case, after broadcasting the second message, any one of the NVPs in the at least one NVP may receive the second message broadcasted by other NVPs, so as to know which NVPs in the NVP cluster want to apply for becoming the master NVP.
(3)该至少一个NVP中任意的一个NVP将自身的节点标识与在第一预设时长内接收到的其他NVP广播的第二消息携带的节点标识进行比较,以确定自身是否当选主NVP。(3) Any one of the at least one NVP compares its own node identifier with the node identifier carried in the second message broadcast by other NVPs received within the first preset time period to determine whether it is elected as the master NVP.
具体地,该至少一个NVP中任意的一个NVP可以根据预设选举条件将自身的节点标识与在第一预设时长内接收到的其他NVP广播的第二消息携带的节点标识进行比较,以确定自身是否当选主NVP。Specifically, any one NVP of the at least one NVP may compare its own node identifier with the node identifier carried in the second message broadcast by other NVPs received within the first preset duration to determine Whether it is elected as the main NVP.
预设选举条件为判断是否可以当选主NVP的条件。预设选举条件可以预先进行设置,且预设选举条件可以由技术人员根据使用需求进行设置。例如:预设选举条件可以为:由NVP集群中节点标识最小的NVP当选主NVP。又例如:预设选举条件可以为:由NVP集群中节点标识最大的NVP当选主NVP。当然,预设选举条件也可以设置为其他判断是否可以当选主NVP的条件,本申请实施例对此不作限定。The preset election condition is a condition for judging whether it is possible to be elected as the main NVP. The preset election conditions can be set in advance, and the preset election conditions can be set by technicians according to usage requirements. For example, the preset election condition may be: the NVP with the smallest node identification in the NVP cluster is elected as the master NVP. For another example, the preset election condition may be: the NVP with the largest node identification in the NVP cluster is elected as the master NVP. Certainly, the preset election condition may also be set to other conditions for determining whether the primary NVP can be elected, which is not limited in this embodiment of the present application.
例如:预设选举条件为:由NVP集群中节点标识最小的NVP当选主NVP。一个NVP的节点标识为04,这个NVP在第一预设时长内接收到三个NVP广播的第二消息,这三个NVP中的第一个NVP广播的第二消息中携带的节点标识为05,这三个NVP中的第二个NVP广播的第二消息中携带的节点标识为06,这三个NVP中的第三个NVP广播的第二消息中携带的节点标识为07。之后,这个NVP将自身的节点标识(04)与接收到的这三个NVP广播的第二消息中携带的节点标识(05、06、07)进行比较,判断自身节点标识是否符合预设选举条件。由于自身的节点标识均小于这三个NVP广播的第二消息中携带的节点标识,所以这个NVP确定自身可以当选主NVP。For example, the preset election condition is: the NVP with the smallest node ID in the NVP cluster is elected as the master NVP. The node identifier of an NVP is 04, the NVP receives the second messages broadcast by three NVPs within the first preset duration, and the node identifier carried in the second message broadcast by the first NVP among the three NVPs is 05 , the node identifier carried in the second message broadcast by the second NVP among the three NVPs is 06, and the node identifier carried in the second message broadcast by the third NVP among the three NVPs is 07. After that, the NVP compares its own node ID (04) with the node IDs (05, 06, 07) carried in the second messages broadcast by the three NVPs received, and determines whether its own node ID meets the preset election conditions . Since the node identifiers of its own are smaller than the node identifiers carried in the second messages broadcast by the three NVPs, the NVP determines that it can be elected as the master NVP.
(4)该至少一个NVP中任意的一个NVP若确定自身当选主NVP,则每隔第二预设时长向同一NVP集群中的其他NVP发送第二通知消息;若确定自身不能当选主NVP,则结束申请成为主NVP的操作。(4) If any NVP of the at least one NVP determines that it is elected as the primary NVP, it sends a second notification message to other NVPs in the same NVP cluster every second preset time period; if it is determined that it cannot be elected as the primary NVP, then End the application to become the main NVP.
第二预设时长可以预先进行设置,且第二预设时长可以设置的较小,以保证主NVP能够不断向同一NVP集群中的其他NVP发送第二通知消息,以使同一NVP集群中的其他NVP一直知道这个NVP集群的主NVP是哪个。The second preset duration can be set in advance, and the second preset duration can be set smaller to ensure that the master NVP can continuously send the second notification message to other NVPs in the same NVP cluster, so that other NVPs in the same NVP cluster can NVP always knows which main NVP of this NVP cluster is.
第二通知消息用于指示发送第二通知消息的NVP已当选所在NVP集群的主NVP,且用于指示接收第二通知消息的NVP为所在NVP集群的从NVP。The second notification message is used to indicate that the NVP sending the second notification message has been elected as the master NVP of the NVP cluster where it is located, and is used to indicate that the NVP receiving the second notification message is the slave NVP of the NVP cluster where it is located.
这种情况下,该至少一个NVP中任意的一个NVP若确定自身当选主NVP,则向同一NVP集群中的其他NVP发送第二通知消息,以通知同一NVP集群中的其他NVP自身已当选主NVP,此时同一NVP集群中的其他NVP为从NVP。若确定自身不能当选主NVP,则结束申请成为主NVP的操作,也即不再广播第二消息,退出此次主NVP的选举。如此是在一个NVP集群整体启动后,第一次选举出这个NVP集群的主NVP。In this case, if any NVP in the at least one NVP determines that it is elected as the master NVP, it sends a second notification message to other NVPs in the same NVP cluster to notify other NVPs in the same NVP cluster that it has been elected as the master NVP. , other NVPs in the same NVP cluster are slave NVPs. If it is determined that it cannot be elected as the main NVP, the operation of applying to become the main NVP is ended, that is, the second message is not broadcast, and the election of the main NVP is withdrawn. In this way, after an NVP cluster is started as a whole, the primary NVP of the NVP cluster is elected for the first time.
可选地,第二通知消息中可以携带自身(即主NVP)的节点标识。这种情况下,若这个NVP集群中任意的一个从NVP接收到第二通知消息,可以将自身的节点标识与第二通知消息携带的节点标识进行比较,以确定第二通知消息中携带的节点标识所标识的NVP是否能够继续当选主NVP;这个从NVP若确定第二通知消息携带的节点标识所标识的NVP不能继续当选主NVP,则向当前的主NVP(即发送第二通知消息的NVP)发送携带自身节点标识的请求消息;当前的主NVP接收到这个从NVP发送的请求消息后,将自身的节点标识与请求消息中携带的节点标识进行比较,以确定自身是否能继续当选主NVP;当前的主NVP若确定自身不能继续当选主NVP,则向这个从NVP发送确认消息;这个从NVP接收到确认消息后,确定自身当选主NVP,则向这个NVP集群中的其他NVP广播第二通知消息。Optionally, the second notification message may carry the node identifier of itself (ie, the primary NVP). In this case, if any one of the NVP clusters receives the second notification message from the NVP, it can compare its own node ID with the node ID carried in the second notification message to determine the node carried in the second notification message. Whether the NVP identified by the identifier can continue to be elected as the master NVP; if the slave NVP determines that the NVP identified by the node identifier carried in the second notification message cannot continue to be elected as the master NVP, it will send the current master NVP (that is, the NVP that sent the second notification message) to the current master NVP. ) sends a request message carrying its own node ID; after the current master NVP receives the request message sent from the NVP, it compares its own node ID with the node ID carried in the request message to determine whether it can continue to be elected as the master NVP ; If the current master NVP determines that it cannot continue to be the master NVP, it will send a confirmation message to the slave NVP; after receiving the confirmation message, the slave NVP determines that it is elected as the master NVP, and broadcasts the second NVP to other NVPs in the NVP cluster. notification message.
该请求消息用于指示发送请求消息的从NVP申请成为主NVP。请求消息中携带发送请求消息的从NVP的节点标识。The request message is used to instruct the slave NVP sending the request message to apply for becoming the master NVP. The request message carries the node identifier of the slave NVP that sends the request message.
该确认消息用于指示当前的主NVP确认自身不能继续当选主NVP,且用于指示发送请求消息的从NVP可以当选主NVP。The confirmation message is used to indicate that the current master NVP confirms that it cannot continue to be elected as the master NVP, and is used to indicate that the slave NVP sending the request message can be elected as the master NVP.
一个从NVP接收到第二通知消息后,将自身的节点标识与第二通知消息携带的节点标识进行比较时,可以根据预设选举条件来将自身的节点标识与第二通知消息携带的节点标识进行比较,以确定第二通知消息中携带的节点标识所标识的NVP是否能够继续当选主NVP。具体来讲,这个从NVP将自身的节点标识与第二通知消息携带的节点标识进行比较后,若确定第二通知消息中携带的节点标识不符合预设选举条件,则可以确定第二通知消息中携带的节点标识所标识的NVP不能继续当选主NVP;而若确定这个从NVP的节点标识不符合预设选举条件,则可以确定第二通知消息中携带的节点标识所标识的NVP能够继续当选主NVP,此时也确定自身仍旧为从NVP。After receiving the second notification message from the NVP, when comparing its own node ID with the node ID carried in the second notification message, it can compare its own node ID with the node ID carried in the second notification message according to preset election conditions. A comparison is performed to determine whether the NVP identified by the node identifier carried in the second notification message can continue to be elected as the master NVP. Specifically, after the slave NVP compares its own node identifier with the node identifier carried in the second notification message, if it is determined that the node identifier carried in the second notification message does not meet the preset election conditions, the second notification message can be determined. The NVP identified by the node identification carried in the NVP cannot continue to be elected as the master NVP; and if it is determined that the node identification of the slave NVP does not meet the preset election conditions, it can be determined that the NVP identified by the node identification carried in the second notification message can continue to be elected. The master NVP also determines that it is still a slave NVP at this time.
同理,当前的主NVP接收到这个从NVP发送的请求消息后,也可以根据预设选举条件来将自身的节点标识与请求消息中携带的节点标识进行比较,以确定自身是否能继续当选主NVP。具体来讲,当前的主NVP将自身的节点标识与请求消息中携带的节点标识进行比较后,若确定请求消息中携带的节点标识不符合预设选举条件,则可以确定自身能继续当选主NVP;而若确定自身的节点标识不符合预设选举条件,则可以确定自身不能继续当选主NVP。Similarly, after the current master NVP receives the request message sent from the NVP, it can also compare its own node ID with the node ID carried in the request message according to the preset election conditions to determine whether it can continue to be elected as the master. NVP. Specifically, after the current master NVP compares its own node identifier with the node identifier carried in the request message, if it is determined that the node identifier carried in the request message does not meet the preset election conditions, it can determine that it can continue to be elected as the master NVP. ; and if it is determined that its own node identifier does not meet the preset election conditions, it can be determined that it cannot continue to be elected as the main NVP.
这种情况下,这个NVP集群能够选举出更符合预设选举条件的主NVP,也即能够选举出更有资格当选主NVP的NVP。In this case, the NVP cluster can elect a master NVP that better meets the preset election conditions, that is, it can elect an NVP that is more qualified to be the master NVP.
例如:第二通知消息中携带的节点标识为03,一个从NVP的节点标识为02。这个NVP集群中的一个从NVP接收到第二通知消息,之后将自身的节点标识(02)与第二通知消息中携带的节点标识(03)进行比较,确定第二通知消息中携带的节点标识(03)所标识的NVP(即当前的主NVP)不能继续当选主NVP,则这个NVP向当前主NVP发送携带自身的节点标识(02)的请求消息。当前的主NVP接收到该请求消息后,将自身的节点标识(03)与该请求消息中携带的节点标识(02)进行比较,确定自身不能继续当选主NVP。之后当前的主NVP可以向这个NVP发送确认消息,确认自身不能继续当选主NVP。在这个NVP接收到该确认消息后,确定自身当选主NVP,则向这个NVP集群中的其他NVP广播第二通知消息,以通知这个NVP集群中的其他NVP自身已当选主NVP。For example, the node identifier carried in the second notification message is 03, and the node identifier of a slave NVP is 02. One of the NVP clusters receives the second notification message from the NVP, and then compares its own node ID (02) with the node ID (03) carried in the second notification message to determine the node ID carried in the second notification message (03) If the identified NVP (ie, the current master NVP) cannot continue to be elected as the master NVP, the NVP sends a request message carrying its own node identifier (02) to the current master NVP. After the current master NVP receives the request message, it compares its own node identifier (03) with the node identifier (02) carried in the request message, and determines that it cannot continue to be elected as the master NVP. After that, the current master NVP can send a confirmation message to this NVP to confirm that it cannot continue to be elected as the master NVP. After the NVP receives the confirmation message and determines that it is elected as the master NVP, it broadcasts a second notification message to other NVPs in the NVP cluster to notify other NVPs in the NVP cluster that it has been elected as the master NVP.
值得注意的是,若一个NVP集群中的主NVP为宕机状态,则这个NVP集群需要重新选举出新的主NVP。It is worth noting that if the master NVP in an NVP cluster is down, the NVP cluster needs to re-elect a new master NVP.
由于这个NVP集群的主NVP为宕机状态时,主NVP无法与对应的VP进行通信,也即所在的NVP集群与对应的VP无法进行通信,且主NVP无法与所在的NVP集群中的其他NVP进行通信。所以这个NVP集群要重新选举出一个新的主NVP,以保持这个NVP集群与对应的VP的通信连接,也即保证这个NVP集群可以接收到对应的VP发送的消息,以及保证这个NVP集群内主NVP与从NVP之间的通信连接。Because the main NVP of this NVP cluster is in the down state, the main NVP cannot communicate with the corresponding VP, that is, the NVP cluster where it is located cannot communicate with the corresponding VP, and the main NVP cannot communicate with other NVPs in the NVP cluster where it is located. to communicate. Therefore, the NVP cluster needs to re-elect a new master NVP to maintain the communication connection between the NVP cluster and the corresponding VP, that is, to ensure that the NVP cluster can receive the messages sent by the corresponding VP, and to ensure that the master NVP in the NVP cluster Communication connection between NVP and slave NVP.
具体地,若一个NVP集群中的主NVP为宕机状态,则这个NVP集群重新选举出新的主NVP的操作可以通过如下步骤(1)-步骤(5)实现。Specifically, if the master NVP in an NVP cluster is in a down state, the operation of re-electing a new master NVP in the NVP cluster may be implemented through the following steps (1) to (5).
(1)这个NVP集群中任意的一个从NVP若在第三预设时长内未接收到第二通知消息,则向同一NVP集群中的其他NVP广播第二消息。(1) If any slave NVP in the NVP cluster does not receive the second notification message within the third preset time period, it broadcasts the second message to other NVPs in the same NVP cluster.
第三预设时长可以预先进行设置,且第三预设时长大于或等于第二预设时长,以使这个从NVP有充足的时间接收这个NVP集群的主NVP发送的第二通知消息。The third preset duration may be preset, and the third preset duration is greater than or equal to the second preset duration, so that the slave NVP has sufficient time to receive the second notification message sent by the master NVP of the NVP cluster.
这种情况下,这个从NVP若在第三预设时长内未接收到第二通知消息,说明这个NVP集群的主NVP未在第二预设时长发送第二通知消息,则可以确定所在NVP集群的主NVP很有可能为宕机状态。为了保持这个NVP集群与对应的VP的通信连接,这个从NVP可以向同一NVP集群中的其他NVP广播第二消息,以申请成为这个NVP集群的主NVP。In this case, if the slave NVP does not receive the second notification message within the third preset time period, indicating that the master NVP of this NVP cluster has not sent the second notification message within the second preset time period, it can determine the NVP cluster to which it belongs. The primary NVP is likely to be down. In order to maintain the communication connection between the NVP cluster and the corresponding VP, the slave NVP may broadcast a second message to other NVPs in the same NVP cluster, so as to apply for becoming the master NVP of the NVP cluster.
(2)这个NVP集群中任意的一个NVP若接收到这个从NVP广播的第二消息,则在将自身的节点标识与这个从NVP广播的第二消息携带的节点标识进行比较后,确定这个从NVP不能当选主NVP的情况下,向同一NVP集群中的其他NVP广播第二消息。(2) If any NVP in the NVP cluster receives the second message broadcast from the NVP, after comparing its own node identifier with the node identifier carried in the second message broadcast from the NVP, determine the slave. If the NVP cannot be elected as the master NVP, broadcast the second message to other NVPs in the same NVP cluster.
一个NVP接收到这个从NVP广播的第二消息后,可以根据预设选举条件来将自身的节点标识与第二消息中携带的节点标识进行比较,以确定是自身还是这个从NVP不能当选主NVP。具体来讲,一个NVP将自身的节点标识与第二消息中携带的节点标识进行比较后,若确定第二消息中携带的节点标识不符合预设选举条件,则可以确定这个从NVP不能当选主NVP;而若确定自身的节点标识不符合预设选举条件,则可以确定自身不能当选主NVP。After an NVP receives the second message broadcasted by the slave NVP, it can compare its own node ID with the node ID carried in the second message according to the preset election conditions to determine whether it is itself or the slave NVP cannot be elected as the master NVP. . Specifically, after an NVP compares its own node ID with the node ID carried in the second message, if it is determined that the node ID carried in the second message does not meet the preset election conditions, it can be determined that the slave NVP cannot be elected as the master NVP; and if it is determined that its own node identifier does not meet the preset election conditions, it can be determined that it cannot be elected as the main NVP.
这个从NVP在广播第二消息后,这个NVP集群中的其他NVP中的任意的一个NVP会接收到这个NVP广播的第二消息。之后这个NVP可以根据预设选举条件将自身的节点标识与这个从NVP广播的第二消息中携带的节点标识进行比较,以确定是自身还是这个从NVP不能当选主NVP。若确定这个从NVP不能当选主NVP,则这个NVP可以向同一NVP集群中的其他NVP广播第二消息,以申请自身成为主NVP。若确定自身不能当选主NVP,则这个NVP可以结束广播第二消息的操作,也即退出这个NVP集群中新的主NVP的选举。After the slave NVP broadcasts the second message, any one of the other NVPs in the NVP cluster will receive the second message broadcast by the NVP. Afterwards, the NVP can compare its own node identifier with the node identifier carried in the second message broadcasted by the slave NVP according to the preset election condition to determine whether it or the slave NVP cannot be elected as the master NVP. If it is determined that the slave NVP cannot be elected as the master NVP, the NVP may broadcast a second message to other NVPs in the same NVP cluster to apply for itself to be the master NVP. If it is determined that it cannot be elected as the master NVP, the NVP can end the operation of broadcasting the second message, that is, quit the election of the new master NVP in the NVP cluster.
(3)这个NVP集群中任意的一个NVP在最新广播第二消息后的第一预设时长内接收其他NVP广播的第二消息。(3) Any NVP in the NVP cluster receives the second message broadcast by other NVPs within the first preset time period after the latest broadcast of the second message.
这个NVP集群中任意的一个NVP在最新广播第二消息后,可以接收其他NVP广播的第二消息,以知道这个NVP集群中还有哪些NVP申请成为主NVP。After the latest broadcast of the second message, any NVP in the NVP cluster can receive the second message broadcast by other NVPs, so as to know which NVPs in the NVP cluster apply to become the master NVP.
(4)这个NVP集群中任意的一个NVP将自身的节点标识与在第一预设时长内接收到的其他NVP广播的第二消息携带的节点标识进行比较,以确定自身是否当选主NVP。(4) Any NVP in the NVP cluster compares its own node identification with the node identification carried in the second message broadcast by other NVPs received within the first preset time period to determine whether it is elected as the master NVP.
具体地,步骤(4)的操作与上述该至少一个NVP中任意的一个NVP将自身的节点标识与在第一预设时长内接收到的其他NVP广播的第二消息携带的节点标识进行比较,以确定自身是否当选主NVP的操作类似,此处不再赘述。Specifically, the operation of step (4) and any one of the above-mentioned at least one NVP compares its own node identifier with the node identifier carried in the second message broadcast by other NVPs received within the first preset duration, The operation of determining whether it is elected as the main NVP is similar, and will not be repeated here.
(5)这个NVP集群中任意的一个NVP若确定自身当选主NVP,则每隔第二预设时长向同一NVP集群中的其他NVP发送第二通知消息。(5) If any NVP in the NVP cluster determines that it is elected as the master NVP, it sends a second notification message to other NVPs in the same NVP cluster every second preset time period.
这种情况下,这个NVP集群中任意的一个NVP若确定自身当选主NVP,则向同一NVP集群中的其他NVP发送第二通知消息,以通知同一NVP集群中的其他NVP自身已当选新的主NVP,此时同一NVP集群中的其他NVP为从NVP。如此是在一个NVP集群中的主NVP宕机时,重新选举出了新的主NVP。In this case, if any NVP in this NVP cluster determines that it is elected as the master NVP, it will send a second notification message to other NVPs in the same NVP cluster to notify other NVPs in the same NVP cluster that it has been elected as the new master. NVP, at this time other NVPs in the same NVP cluster are slave NVPs. In this way, when the primary NVP in an NVP cluster goes down, a new primary NVP is re-elected.
步骤202:该m个NVP集群中每个NVP集群中的每个NVP若接收到第一消息,则将第一消息携带的该区块存储至区块链,并向同一NVP集群中相邻的NVP发送第一消息。Step 202: If each NVP in each NVP cluster in the m NVP clusters receives the first message, it stores the block carried in the first message in the blockchain, and sends the message to the adjacent NVP cluster in the same NVP cluster. The NVP sends the first message.
每个NVP可以将第一消息携带的该区块存储至自身的区块链。Each NVP can store the block carried in the first message to its own blockchain.
该m个NVP集群中每个NVP集群中的第一NVP先接收到对应的VP发送的第一消息,则第一NVP可以将第一消息中携带的该区块存储至自身的区块链,并向同一NVP集群中相邻的NVP发送第一消息。之后,同一NVP集群中与第一NVP相邻的NVP中任意的一个NVP接收到第一NVP发送的第一消息后,也可以将第一消息中携带的该区块存储至自身的区块链,并向同一NVP集群中相邻的NVP发送第一消息。以此类推,同一NVP集群中的每个NVP均会将第一消息携带的该区块存储至自身的区块链,并向同一NVP集群中相邻的NVP发送第一消息。The first NVP in each NVP cluster in the m NVP clusters first receives the first message sent by the corresponding VP, and the first NVP can store the block carried in the first message in its own blockchain, and send the first message to adjacent NVPs in the same NVP cluster. After that, after receiving the first message sent by the first NVP, any one of the NVPs adjacent to the first NVP in the same NVP cluster can also store the block carried in the first message to its own blockchain , and send the first message to adjacent NVPs in the same NVP cluster. By analogy, each NVP in the same NVP cluster will store the block carried in the first message in its own blockchain, and send the first message to adjacent NVPs in the same NVP cluster.
可选地,步骤202可以通过GOSSIP协议实现。也即每个NVP集群中的第一NVP接收到第一消息后,通过GOSSIP协议向所在的NVP集群中的每个NVP广播第一消息,以使所在的NVP集群中的每个NVP将第一消息中携带的区块存储至自身的区块链。Optionally,
这种情况下,通过GOSSIP协议传播第一消息,则每个NVP集群中的每个NVP均会将第一消息中携带的该区块存储至自身的区块链,从而实现将对应的VP中添加的该区块同步至每个NVP集群中的每个NVP。In this case, if the first message is propagated through the GOSSIP protocol, each NVP in each NVP cluster will store the block carried in the first message in its own blockchain, thereby realizing the storage of the corresponding VP in the This added block is synchronized to each NVP in each NVP cluster.
可选地,该m个NVP集群中每个NVP集群中的每个NVP具有节点列表,节点列表中包括同一NVP集群中相邻的NVP的节点标识。Optionally, each NVP in each NVP cluster of the m NVP clusters has a node list, and the node list includes node identifiers of adjacent NVPs in the same NVP cluster.
一个NVP中的节点列表用于指示与这个NVP相邻的NVP,示例地,一个NVP的节点标识为02,从如下表1所示的这个NVP中的节点列表中可以知道这个NVP相邻的NVP的节点标识为01、03、04。The node list in an NVP is used to indicate the NVP adjacent to this NVP. For example, the node identifier of an NVP is 02. From the node list in this NVP shown in Table 1 below, we can know the NVP adjacent to this NVP. The node IDs are 01, 03, 04.
表1Table 1
本申请实施例仅以上表1为例来对一个NVP的节点列表进行示例性说明,上表1并不对本申请实施例构成限定。In this embodiment of the present application, only the above Table 1 is taken as an example to illustrate the node list of one NVP, and the above Table 1 does not limit the embodiment of the present application.
这种情况下,步骤202的操作可以通过如下步骤(1)-步骤(3)实现。In this case, the operation of
(1)该m个NVP集群中每个NVP集群中任意的一个NVP若接收到第一消息,将第一消息携带的该区块存储至自身的区块链。(1) If any NVP in each NVP cluster of the m NVP clusters receives the first message, it stores the block carried in the first message in its own blockchain.
这种情况下,一个NVP接收到第一消息后先将第一消息中携带的该区块存储至自身的区块链,也即是实现了将对应的VP中添加的该区块同步至这个NVP中。In this case, after receiving the first message, an NVP first stores the block carried in the first message to its own blockchain, that is, the block added in the corresponding VP is synchronized to this block. in NVP.
可选地,VP生成的第一消息中还可以携带第一消息的消息序号。这种情况下,该m个NVP集群中每个NVP集群中任意的一个NVP若接收到第一消息,可以先判断最新接收到的第一消息的消息序号是否大于上一次接收到的历史第一消息的消息序号;在最新接收到的第一消息的消息序号大于上一次接收到的历史第一消息的消息序号的情况下,再将第一消息携带的该区块存储至自身的区块链;而在最新接收到的第一消息的消息序号小于或等于上一次接收到的历史第一消息的消息序号的情况下,丢弃最新接收到的第一消息。Optionally, the first message generated by the VP may further carry the message sequence number of the first message. In this case, if any NVP in each NVP cluster of the m NVP clusters receives the first message, it can first determine whether the message sequence number of the newly received first message is greater than the historical first message received last time. The message sequence number of the message; if the message sequence number of the newly received first message is greater than the message sequence number of the historical first message received last time, the block carried in the first message will be stored in its own blockchain. ; and in the case that the message sequence number of the newly received first message is less than or equal to the message sequence number of the historical first message received last time, the newly received first message is discarded.
第一消息的消息序号用于唯一标识第一消息,且VP生成的第一消息的消息序号是递增的。The message sequence number of the first message is used to uniquely identify the first message, and the message sequence number of the first message generated by the VP is incremented.
历史第一消息为一个NVP在最新接收到的第一消息之前已经接收到的第一消息。The historical first message is the first message that an NVP has received before the newly received first message.
若一个NVP最新接收到的第一消息的消息序号大于上一次接收到的历史第一消息的消息序号,说明最新接收到的第一消息为对应的VP最新生成的,也即最新接收到的第一消息中携带的该区块为对应的VP最新添加至区块链中的,也就可以确定最新接收到的第一消息中携带的该区块为这个NVP的区块链中未存储的区块。如此,这个NVP可以将第一消息中携带的该区块存储至区块链,以实现对该区块的同步。If the message sequence number of the latest first message received by an NVP is greater than the message sequence number of the historical first message received last time, it means that the newly received first message is newly generated by the corresponding VP, that is, the latest received first message The block carried in a message is newly added to the blockchain by the corresponding VP, so it can be determined that the block carried in the newly received first message is an unstored area in the blockchain of this NVP. piece. In this way, the NVP can store the block carried in the first message to the blockchain to synchronize the block.
若一个NVP最新接收到的第一消息的消息序号小于或等于上一次接收到的历史第一消息的消息序号,说明最新接收到的第一消息不是对应VP最新生成的第一消息,也即最新接收到的第一消息中携带的该区块很有可能已被这个NVP的区块链存储,如此就不需要再对该区块进行存储,所以可以将最新接收到的第一消息丢弃。If the message sequence number of the latest first message received by an NVP is less than or equal to the message sequence number of the historical first message received last time, it indicates that the newly received first message is not the first message newly generated by the corresponding VP, that is, the latest The block carried in the received first message is likely to have been stored by the blockchain of the NVP, so there is no need to store the block, so the newly received first message can be discarded.
这种情况下,该m个NVP集群中每个NVP集群中任意的一个NVP的区块链中每次存储的区块为对应的VP中新添加的区块。如此可以保证该m个NVP集群中每个NVP集群中任意的一个NVP的区块链中存储的区块不会重复。In this case, the block stored each time in the blockchain of any NVP in each NVP cluster in the m NVP clusters is the newly added block in the corresponding VP. In this way, it can be ensured that the blocks stored in the blockchain of any NVP in each NVP cluster in the m NVP clusters will not be repeated.
(2)若该m个NVP集群中每个NVP集群中任意的一个NVP接收到的第一消息来自对应的VP,则向第一消息中添加自身的节点标识,以更新第一消息;向自身的节点列表中的每个节点标识所标识的NVP发送更新后的第一消息。(2) If the first message received by any NVP in each NVP cluster in the m NVP clusters is from the corresponding VP, add its own node identifier to the first message to update the first message; The NVP identified by each node identifier in the node list sends the updated first message.
第一消息用于指示第一消息携带的节点标识所标识的NVP已接收到第一消息,即指示第一消息携带的节点标识所标识的NVP已存储第一消息携带的区块至区块链。The first message is used to indicate that the NVP identified by the node ID carried in the first message has received the first message, that is, to indicate that the NVP identified by the node ID carried in the first message has stored the block carried by the first message to the blockchain .
这个NVP向第一消息中添加自身的节点标识,以更新第一消息,这样可以保证下一个接收到更新后的第一消息的NVP知道哪些NVP已接收到第一消息。The NVP adds its own node identifier to the first message to update the first message, so as to ensure that the next NVP that receives the updated first message knows which NVPs have received the first message.
若一个NVP接收到的第一消息来自对应的VP,说明这个NVP为第一NVP,则可知此时所在NVP集群中除这个NVP之外的其他NVP尚未接收到第一消息,也即这个NVP的相邻的NVP均没有接收到第一消息,则这个NVP在更新第一消息后可以向自身的节点列表中的每个节点标识所标识的NVP发送更新后的第一消息。If the first message received by an NVP comes from the corresponding VP, indicating that this NVP is the first NVP, it can be known that other NVPs in the NVP cluster except this NVP have not received the first message, that is, the NVP of this NVP has not yet received the first message. If none of the adjacent NVPs has received the first message, after updating the first message, this NVP may send the updated first message to the NVP identified by each node identifier in its own node list.
(3)若该m个NVP集群中每个NVP集群中任意的一个NVP接收到的第一消息来自同一NVP集群中的NVP,则将第一消息携带的节点标识确定为目标节点标识;向第一消息中添加自身的节点标识,以更新第一消息;向自身的节点列表中除目标节点标识之外的其他每个节点标识所标识的NVP发送更新后的第一消息。(3) If the first message received by any NVP in each NVP cluster in the m NVP clusters is from an NVP in the same NVP cluster, the node identifier carried in the first message is determined as the target node identifier; Add its own node identification to a message to update the first message; send the updated first message to the NVP identified by each node identification except the target node identification in the own node list.
若一个NVP接收到的第一消息来自同一NVP集群中的NVP,说明这个NVP是第二NVP,则可知此时所在NVP集群中除这个NVP之外的其他NVP中至少存在部分NVP(包括第一NVP)已接收到第一消息。因而这个NVP接收到的第一消息中已经携带节点标识(即目标节点标识),目标节点标识所标识的NVP即是已经接收到第一消息的NVP。从而这个NVP可以不用向目标节点标识所标识的NVP发送更新后的第一消息。也即,这个NVP在更新第一消息后可以向自身的节点列表中除目标节点标识之外的其他每个节点标识所标识的NVP发送更新后的第一消息。If the first message received by an NVP comes from an NVP in the same NVP cluster, indicating that this NVP is the second NVP, it can be known that there are at least some NVPs (including the first NVP) in other NVPs except this NVP in the NVP cluster at this time. NVP) has received the first message. Therefore, the first message received by this NVP already carries the node identifier (ie, the target node identifier), and the NVP identified by the target node identifier is the NVP that has received the first message. Therefore, the NVP does not need to send the updated first message to the NVP identified by the target node identification. That is, after updating the first message, the NVP can send the updated first message to the NVP identified by each node identification except the target node identification in its own node list.
如此可以保证该m个NVP集群中每个NVP集群中各个NVP不会接收到重复的第一消息,从而可以保证各个NVP的区块链中存储的区块不会重复。In this way, it can be ensured that each NVP in each NVP cluster in the m NVP clusters will not receive a duplicate first message, thereby ensuring that the blocks stored in the blockchain of each NVP will not be duplicated.
可选地,一个NVP的节点列表中还可以包括相邻的NVP的节点标识对应的出接口。Optionally, the node list of one NVP may further include outgoing interfaces corresponding to the node identifiers of adjacent NVPs.
该出接口为一个NVP向节点列表中的节点标识所标识的NVP发送第一消息时,从这个NVP发出第一消息的网络接口。示例地,一个NVP的节点标识为02,这个NVP的节点列表中包括这个NVP的三个相邻的NVP的节点标识为01、03、04。则节点列表中包括的这三个相邻的NVP的节点标识对应的出接口如下表2所示。The outgoing interface is a network interface that sends the first message from the NVP when an NVP sends the first message to the NVP identified by the node identifier in the node list. For example, the node identifier of one NVP is 02, and the node identifiers of three adjacent NVPs including this NVP in the node list of this NVP are 01, 03, and 04. The outbound interfaces corresponding to the node identifiers of the three adjacent NVPs included in the node list are shown in Table 2 below.
表2Table 2
本申请实施例仅以上表2为例来对一个NVP的节点列表进行示例性说明,上表2并不对本申请实施例构成限定。In this embodiment of the present application, only the above Table 2 is taken as an example to illustrate the node list of an NVP, and the above Table 2 does not constitute a limitation to the embodiment of the present application.
这种情况下,一个NVP向自身的节点列表中除目标节点标识之外的其他每个节点标识所标识的NVP发送更新后的第一消息的操作可以为:这个NVP从自身的节点列表中获取除目标节点标识之外的其他每个节点标识对应的出接口;对于自身的节点列表中除目标节点标识之外的其他每个节点标识中任意的一个节点标识,这个NVP通过这个节点标识对应的出接口向这个节点标识所标识的NVP发送更新后的第一消息。In this case, the operation of an NVP sending the updated first message to the NVP identified by each node identification except the target node identification in its own node list may be: the NVP obtains from its own node list The outgoing interface corresponding to each other node identifier except the target node identifier; for any node identifier in each node identifier except the target node identifier in its own node list, the NVP passes the node identifier corresponding to the The outbound interface sends the updated first message to the NVP identified by the node identification.
如此,节点列表中的每个节点标识对应一个出接口,该m个NVP集群中每个NVP集群中任意的一个NVP可以从相邻的NVP的节点标识对应的出接口向相邻的NVP发送更新后的第一消息。从而可以避免网络拥堵,进而提高消息传输速率。In this way, each node identifier in the node list corresponds to an outgoing interface, and any NVP in each NVP cluster in the m NVP clusters can send an update to the adjacent NVP from the outgoing interface corresponding to the node identifier of the adjacent NVP. After the first news. As a result, network congestion can be avoided, thereby increasing the message transmission rate.
可选地,该m个NVP集群中每个NVP集群中任意的一个NVP可以包括第一模块和第二模块,第一模块用于与同一NVP集群中相邻的NVP进行通信,还用于与对应的VP进行通信。第二模块用于处理第一消息中携带的区块。Optionally, any one NVP in each NVP cluster in the m NVP clusters may include a first module and a second module, and the first module is used to communicate with adjacent NVPs in the same NVP cluster, and is also used to communicate with NVPs in the same NVP cluster. communicate with the corresponding VP. The second module is used to process the block carried in the first message.
这种情况下,步骤202的操作可以为:第一模块若接收到第一消息,将第一消息携带的该区块发送给第二模块;第二模块接收到第一模块发送的该区块后,将该区块存储至自身的区块链;若第一模块接收到的第一消息来自对应的VP,则第一模块向第一消息中添加第一模块所属的NVP的节点标识,以更新第一消息,向自身的节点列表中的每个节点标识所标识的NVP发送更新后的第一消息;若第一模块接收到的第一消息来自同一NVP集群中的NVP,则第一模块将第一消息携带的节点标识确定为目标节点标识,向第一消息中添加第一模块所属的NVP的节点标识,以更新第一消息,向自身的节点列表中除目标节点标识之外的其他节点标识所标识的NVP发送更新后的第一消息。In this case, the operation of
如此,由第一模块接收、更新和发送第一消息,由第二模块接收第一模块发送的该区块,并将该区块存储至自身的区块链。也即第一模块和第二模块具有各自的分工,可以提高区块同步效率。In this way, the first module receives, updates and sends the first message, and the second module receives the block sent by the first module, and stores the block in its own blockchain. That is, the first module and the second module have their own division of labor, which can improve the block synchronization efficiency.
其中,第一模块和第二模块执行的操作与上述一个NVP在接收到第一消息,将第一消息携带的该区块存储至区块链,并向同一NVP集群中相邻的NVP发送第一消息的操作类似,此处不再赘述。The operations performed by the first module and the second module are the same as the above-mentioned one NVP receives the first message, stores the block carried in the first message to the blockchain, and sends the first message to the adjacent NVP in the same NVP cluster. The operation of a message is similar and will not be repeated here.
可选地,该m个NVP集群中每个NVP集群对应的VP可以在区块共识过程中生成检查消息,VP还可以向对应的NVP集群中的第一NVP发送该检查消息。Optionally, the VP corresponding to each NVP cluster in the m NVP clusters may generate a check message during the block consensus process, and the VP may also send the check message to the first NVP in the corresponding NVP cluster.
该检查消息用于指示NVP检查自身的区块链中存储的区块是否正确,该检查消息中携带第一目标区块标识和第一目标区块哈希值。第一目标区块标识为VP进行共识处理的区块的区块标识,第一目标区块哈希值为VP进行共识处理的区块的区块哈希值。The check message is used to instruct the NVP to check whether the blocks stored in its own blockchain are correct, and the check message carries the identifier of the first target block and the hash value of the first target block. The first target block identifier is the block identifier of the block that VP performs consensus processing, and the first target block hash value is the block hash value of the block that VP performs consensus processing.
可选地,VP可以在如下两种情况下生成检查消息,并向对应的NVP集群中的第一NVP发送该检查消息。Optionally, the VP may generate a check message in the following two cases, and send the check message to the first NVP in the corresponding NVP cluster.
第一种情况,VP在每完成对一个区块的共识,并将这个区块添加至区块链,且向对应的NVP集群中的第一NVP发送携带有这个区块的第一消息后,可以再向对应的NVP集群中的第一NVP发送该检查消息,该检查消息中携带的第一目标区块标识为这个区块的区块标识,第一目标区块哈希值为这个区块的区块哈希值。In the first case, after the VP completes the consensus on a block, adds the block to the blockchain, and sends the first message carrying the block to the first NVP in the corresponding NVP cluster, The check message can be sent to the first NVP in the corresponding NVP cluster, the first target block identifier carried in the check message is the block identifier of this block, and the hash value of the first target block is this block. the block hash value.
这种情况下,每向对应的NVP集群中的第一NVP发送携带有这个区块的第一消息后,就向对应的NVP集群中的第一NVP发送针对这个区块的检查消息。如此可以保证对应的NVP集群中的每个NVP每存储一个区块就会接收到这个区块对应的检查消息,可以保证每个NVP能够对自身的区块链中存储的每个区块进行检查,从而确保自身的区块链中存储的区块的正确性。In this case, after each sending the first message carrying the block to the first NVP in the corresponding NVP cluster, a check message for the block is sent to the first NVP in the corresponding NVP cluster. This ensures that each NVP in the corresponding NVP cluster will receive a check message corresponding to this block every time it stores a block, and can ensure that each NVP can check each block stored in its own blockchain. , so as to ensure the correctness of the blocks stored in its own blockchain.
第二种情况,VP在完成对一个区块的共识,并将这个区块添加至区块链,且向对应的NVP集群中的第一NVP发送携带有这个区块的第一消息后,若这个区块是在执行区块回滚操作后最新生成的,则VP可以再向对应的NVP集群中的第一NVP发送针对这个区块的检查消息。若这个区块不是在执行区块回滚操作后最新生成的,则VP可以不向对应的NVP集群中的第一NVP发送针对这个区块的检查消息。In the second case, after the VP completes the consensus on a block, adds the block to the blockchain, and sends the first message carrying the block to the first NVP in the corresponding NVP cluster, if This block is newly generated after the block rollback operation is performed, and the VP can then send a check message for this block to the first NVP in the corresponding NVP cluster. If the block is not newly generated after the block rollback operation is performed, the VP may not send a check message for this block to the first NVP in the corresponding NVP cluster.
由于在执行区块回滚操作后最新生成的区块的区块标识与执行区块回滚操作之前最后生成的区块的区块标识相同,所以VP执行区块回滚操作,会导致VP向对应的NVP集群的第一NVP发送两个区块标识相同的区块,那么对应的NVP集群中的每个NVP会接收到两个区块标识相同的区块,但是每个NVP不知道哪个区块才是正确的区块,如此,会导致每个NVP的区块链出现短暂的分叉,也即区块链中的一个区块的下一个区块会分为两个区块标识相同的区块。这种情况下,在这两个相同的区块标识所标识的区块的下一个区块到来时,要想将下一个区块存储至区块链,还需要将下一个区块的父区块哈希值与这两个区块的区块哈希值进行比较,以确定这两个区块中哪一个区块才是下一个区块的父区块。Since the block identifier of the newly generated block after the block rollback operation is performed is the same as the block identifier of the last block generated before the block rollback operation is performed, the VP performs the block rollback operation, which will cause the VP to The first NVP of the corresponding NVP cluster sends two blocks with the same block identifier, then each NVP in the corresponding NVP cluster will receive two blocks with the same block identifier, but each NVP does not know which block The block is the correct block. This will cause a short-term fork in the blockchain of each NVP, that is, the next block of a block in the blockchain will be divided into two blocks with the same identifier. block. In this case, when the next block of the block identified by the two same block identifiers arrives, in order to store the next block in the blockchain, the parent area of the next block needs to be stored. The block hash is compared with the block hash of the two blocks to determine which of the two blocks is the parent of the next block.
这种情况下,VP在执行区块回滚操作后生成最新的区块后,可以向对应的NVP集群中的第一NVP发送针对该区块的检查消息。对应的NVP集群中的每个NVP接收到该检查消息后,能够检查出区块链中存储的两个区块标识相同的区块哪个才是正确的。如此可以确保区块链中存储的区块的正确性。由于仅在执行区块回滚操作后生成最新的区块时,VP才向对应的NVP集群中的第一NVP发送检查消息,所以可以节省区块链系统资源。In this case, after the VP generates the latest block after performing the block rollback operation, it can send a check message for the block to the first NVP in the corresponding NVP cluster. After each NVP in the corresponding NVP cluster receives the check message, it can check which of the two blocks stored in the blockchain with the same identifier is correct. This ensures the correctness of the blocks stored in the blockchain. Since the VP sends a check message to the first NVP in the corresponding NVP cluster only when the latest block is generated after the block rollback operation is performed, the blockchain system resources can be saved.
进一步地,该m个NVP集群中每个NVP集群中任意的一个NVP接收到对应的VP生成的检查消息后,可以在自身的区块链中查找第一区块;若在自身的区块链中查找到第一区块,则在第一区块的区块哈希值与第一目标区块哈希值不同的情况下,从自身的区块链中删除第一区块。Further, after any NVP in each NVP cluster of the m NVP clusters receives the check message generated by the corresponding VP, it can search for the first block in its own blockchain; If the block hash value of the first block is different from the hash value of the first target block, the first block will be deleted from its own blockchain.
第一区块为区块标识与第一目标区块标识相同的区块。The first block is a block with the same block identification as the first target block identification.
一个NVP接收到对应的VP生成的检查消息后,在自身的区块链中查找第一区块,也即在自身的区块链中查找区块标识与第一目标区块标识相同的区块。若在自身的区块链中查找到第一区块,则将第一区块的区块哈希值与第一目标区块哈希值进行对比。若第一区块的区块哈希值与第一目标区块哈希值相同,说明第一区块是正确的,则不需要做任何处理。若第一区块的区块哈希值与第一目标区块哈希值不同,说明第一区块与第一目标区块哈希值对应的区块不相同,则可以确定第一区块不正确,也即第一区块很有可能是已经被回滚的区块,所以可以从自身的区块链中删除第一区块。After an NVP receives the check message generated by the corresponding VP, it searches for the first block in its own blockchain, that is, it searches its own blockchain for a block with the same block ID as the first target block ID. . If the first block is found in its own blockchain, the block hash value of the first block is compared with the hash value of the first target block. If the block hash value of the first block is the same as the first target block hash value, it means that the first block is correct, and no processing is required. If the block hash value of the first block is different from the hash value of the first target block, it means that the block corresponding to the hash value of the first block and the first target block is not the same, and the first block can be determined. Incorrect, that is, the first block is likely to be a block that has been rolled back, so the first block can be deleted from its own blockchain.
示例地,一个VP完成了对一个区块标识为50的区块的共识后,向对应的NVP集群中的第一NVP发送携带区块标识为50的区块的第一消息。但是VP在完成对这个区块的共识后,又对这个区块进行了回滚,这个VP在执行区块回滚操作后,又继续生成了一个区块标识为50的区块并完成了对这个区块的共识。之后这个VP会向对应的NVP集群中的第一NVP发送携带新生成的这个区块标识为50的区块的第一消息,且会发送针对这个区块的检查消息。这种情况下,对应的NVP集群中的每个NVP会接收到两个区块标识为50的区块,那么自身的区块链中也会相应存储两个区块标识为50的区块,此时根据该检查消息就可以删除在先存储的区块标识为50的区块。For example, after a VP completes consensus on a block with a block identifier of 50, it sends a first message carrying a block with a block identifier of 50 to the first NVP in the corresponding NVP cluster. However, after the VP completed the consensus on the block, it rolled back the block. After the VP performed the block rollback operation, it continued to generate a block with a block ID of 50 and completed the verification of the block. The consensus of this block. After that, the VP will send the first message carrying the newly generated block with the
例如:图3是NVP的区块链中存储的区块的示意图。参见图3,图3包括区块链300以及区块链300中存储的多个区块301。该多个区块301中包括两个区块标识为50的区块301,且这两个区块标识为50的区块301导致了区块链300出现了暂时的分叉。一个NVP接收到对应的VP发送的检查消息,该检查消息中携带的第一目标区块标识为50。这个NVP可以从自身的区块链300中查找区块标识为50的区块301,则会查找到两个区块标识为50的区块301。之后这个NVP确定这两个区块标识为50的区块301中在先存储的区块标识为50的区块301的区块哈希值与该检查消息中携带的第一目标区块哈希值不同,则这个NVP可以删除自身的区块链300中在先存储的区块标识为50的区块301,如此,这个NVP的区块链300中存储的均为正确的区块301,此时这个NVP的区块链300可以如图4所示,图4所示的区块链300中存储的均为正确的区块301。For example: Figure 3 is a schematic diagram of blocks stored in the blockchain of NVP. Referring to FIG. 3 , FIG. 3 includes a
以上对该m个NVP集群中每个NVP集群中的每个NVP接收到第一消息后,执行的操作进行了详细的说明,可实现该m个NVP集群中每个NVP集群中的每个NVP将第一消息中携带的区块存储至自身的区块链中,如此保证了该m个NVP集群中每个NVP集群中的每个NVP将该多个VP中存储的该区块同步至自身的区块链。The operations performed by each NVP in each NVP cluster in the m NVP clusters after receiving the first message are described in detail above, and each NVP in each NVP cluster in the m NVP clusters can be implemented. Store the block carried in the first message in its own blockchain, thus ensuring that each NVP in each NVP cluster in the m NVP clusters synchronizes the block stored in the multiple VPs to itself blockchain.
值得注意的是,该m个NVP集群中每个NVP集群中的任意的一个NVP可能因为网络拥堵或者网络分区等原因,很长时间不能接收到区块,那么这个NVP就不能实现对区块的同步。下面对这种情况下需要执行的操作进行详细说明,以解决因为网络原因无法同步区块的问题。It is worth noting that any NVP in each NVP cluster in the m NVP clusters may be unable to receive blocks for a long time due to network congestion or network partitions, etc., then this NVP cannot realize the block. Synchronize. The following is a detailed description of what needs to be done in this case to solve the problem of not being able to synchronize blocks due to network reasons.
具体地,该m个NVP集群中每个NVP集群中的每个NVP每隔第四预设时长向同一NVP集群中相邻的其他NVP发送区块链状态,该区块链状态包括自身的节点标识以及区块链中最新区块的区块标识;该m个NVP集群中每个NVP集群中任意的一个NVP将接收到的相邻的NVP发送的该区块链状态确定为目标区块链状态,若在第五预设时长内没有接收到区块,则在自身的区块链中最新区块的区块标识小于目标区块链状态中的区块标识的情况下,从目标区块链状态中的节点标识所标识的目标NVP的区块链中,获取区块标识大于自身的区块链中最新区块的区块标识的区块,将获取到的区块存储至自身的区块链。Specifically, each NVP in each NVP cluster in the m NVP clusters sends a blockchain state to other adjacent NVPs in the same NVP cluster every fourth preset time period, where the blockchain state includes its own node ID and the block ID of the latest block in the blockchain; any NVP in each NVP cluster in the m NVP clusters determines the state of the blockchain sent by the received adjacent NVP as the target blockchain If no block is received within the fifth preset time period, if the block ID of the latest block in the own blockchain is smaller than the block ID in the target blockchain In the blockchain of the target NVP identified by the node ID in the chain state, obtain the block whose block ID is greater than the block ID of the latest block in its own blockchain, and store the obtained block in its own area. blockchain.
第四预设时长可以预先进行设置,且第四预设时长可以由技术人员根据需求进行设置。例如,第四预设时长可以设置为1分钟。The fourth preset duration can be set in advance, and the fourth preset duration can be set by a technician according to requirements. For example, the fourth preset duration may be set to 1 minute.
一个NVP的区块链状态用于表示自身的区块链中存储的最新区块的情况。目标区块链状态为一个NVP接收到的相邻的NVP发送的区块链状态,若这个NVP具有多个相邻的NVP,则这个NVP可以接收到多个目标区块链状态。An NVP's blockchain state is used to represent the state of the latest block stored in its own blockchain. The target blockchain state is the blockchain state received by an NVP and sent by an adjacent NVP. If this NVP has multiple adjacent NVPs, this NVP can receive multiple target blockchain states.
第五预设时长可以预先进行设置,且第五预设时长可以设置的较大,以保证有充足的时间接收区块。例如,第五预设时长可以设置为2分钟。The fifth preset duration can be set in advance, and the fifth preset duration can be set larger to ensure sufficient time to receive blocks. For example, the fifth preset duration may be set to 2 minutes.
目标NVP为这个NVP接收到的多个目标区块链状态中区块标识大于这个NVP的区块链中的最新区块的区块标识的目标区块链状态中的节点标识所标识的NVP。The target NVP is the NVP identified by the node identifier in the target blockchain state where the block identifier in the multiple target blockchain states received by the NVP is greater than the block identifier of the latest block in the blockchain of the NVP.
该m个NVP集群中每个NVP集群中的每个NVP每隔第四预设时长向同一NVP集群中相邻的其他NVP发送区块链状态,则每个NVP可以知道相邻的NVP的区块链中存储的最新区块的情况。如果一个NVP在第五预设时长内没有接收到区块,说明这个NVP在很长时间内没有接收到区块了,则这个NVP可以查看多个目标区块链状态中任意的一个目标区块链状态中是否存在比自身区块链中的最新区块的区块标识大的区块标识,若多个目标区块链状态中存在一个目标区块链状态中的区块标识大于自身的区块链中的最新区块的区块标识,则这个NVP可以从这个目标区块链状态中的节点标识所标识的目标NVP的区块链中,获取区块标识大于自身的区块链中最新区块的区块标识的区块。之后可以将获取的区块存储至自身的区块链,以实现对自身区块链中未存储的区块的同步。若多个目标区块链状态中的每个目标区块链状态中的区块标识均小于或等于自身的区块链中的最新区块的区块标识,则这个NVP继续等待接收区块。Each NVP in each NVP cluster in the m NVP clusters sends the blockchain status to other adjacent NVPs in the same NVP cluster every fourth preset time period, then each NVP can know the area of the adjacent NVP The condition of the latest block stored in the blockchain. If an NVP does not receive a block within the fifth preset time period, it means that the NVP has not received a block for a long time, and the NVP can view any target block in the status of multiple target blockchains Whether there is a block ID in the chain state that is larger than the block ID of the latest block in its own blockchain, if there is a block ID in the target blockchain state that is larger than itself in multiple target blockchain states The block ID of the latest block in the blockchain, the NVP can obtain the latest block ID from the blockchain of the target NVP identified by the node ID in the target blockchain state. The block identified by the block's block. Afterwards, the acquired blocks can be stored in their own blockchain to synchronize unstored blocks in their own blockchain. If the block ID in each target blockchain state of the multiple target blockchain states is less than or equal to the block ID of the latest block in its own blockchain, the NVP continues to wait to receive blocks.
如此,在一个NVP长时间未接收到区块的情况下,直接从相邻的目标NVP的区块链中获取大于自身区块链中最新区块的区块标识的区块,可以节省系统资源,且节约区块同步时间,从而提高区块同步效率。In this way, when an NVP has not received a block for a long time, it can directly obtain a block with a block ID larger than the latest block in its own block chain from the block chain of the adjacent target NVP, which can save system resources. , and saves the block synchronization time, thereby improving the block synchronization efficiency.
可选地,区块链状态还包括区块链中最新区块的区块哈希值,这种情况下这个NVP从目标区块链状态中的节点标识所标识的目标NVP的区块链中,获取区块标识大于自身的区块链中最新区块的区块标识的区块的操作可以为:这个NVP向目标区块链状态中的节点标识所标识的目标NVP发送第三消息;目标NVP若接收到第三消息,则从自身的区块链中查找第二区块,若从自身的区块链中查找到第二区块,则在第二区块的区块哈希值与第二目标区块哈希值相同的情况下,将自身的区块链中区块标识大于第三目标区块标识且小于或等于第二目标区块标识的所有区块发送给这个NVP。Optionally, the blockchain state also includes the block hash value of the latest block in the blockchain. In this case, this NVP is obtained from the blockchain of the target NVP identified by the node ID in the target blockchain state. , the operation of obtaining a block whose block identifier is greater than the block identifier of the latest block in its own blockchain may be: the NVP sends a third message to the target NVP identified by the node identifier in the target blockchain state; the target If the NVP receives the third message, it will search for the second block from its own blockchain, and if it finds the second block from its own blockchain, the block hash value of the second block will be the same as that of the second block. If the hash value of the second target block is the same, all blocks in its own blockchain whose block identifier is greater than the third target block identifier and less than or equal to the second target block identifier are sent to this NVP.
在这里,这个目标区块链状态为多个目标区块链状态中区块标识大于这个NVP的区块链中的最新区块的区块标识的目标区块链状态。Here, the target blockchain state is the target blockchain state in which the block ID of the multiple target blockchain states is greater than the block ID of the latest block in the blockchain of the NVP.
第三消息用于指示目标NVP将自身的区块链中大于这个NVP的区块链中最新区块的区块标识的区块发送给这个NVP。第三消息中携带第二目标区块标识、第二目标区块哈希值和第三目标区块标识。第二目标区块标识为目标区块链状态中的区块标识,也即是这个NVP的区块链中未存储的一个区块的区块标识。第二目标区块哈希值为目标区块链状态中的区块哈希值,也即是这个NVP的区块链中未存储的一个区块的区块哈希值。第三目标区块标识为这个NVP的区块链中的最新区块的区块标识。The third message is used to instruct the target NVP to send a block in its own blockchain that is larger than the block identifier of the latest block in the blockchain of this NVP to this NVP. The third message carries the second target block identifier, the second target block hash value and the third target block identifier. The second target block identifier is the block identifier in the target blockchain state, that is, the block identifier of a block that is not stored in the blockchain of the NVP. The second target block hash value is the block hash value in the target blockchain state, that is, the block hash value of a block not stored in the NVP's blockchain. The third target block identifier is the block identifier of the latest block in the blockchain of this NVP.
第二区块是区块标识与第二目标区块标识相同的区块。The second block is a block with the same block identifier as the second target block identifier.
这种情况下,目标NVP接收到第三消息后,先查找自身的区块链中是否存在区块标识与第二目标区块标识相同的区块(即第二区块),若查找到自身的区块链中存在第二区块,则将第二区块的区块哈希值与第三消息中携带的第二目标区块哈希值进行对比,若第二区块的区块哈希值与第二目标区块哈希值相同,说明第二区块就是这个NVP的区块链中未存储的区块之一,在此情况下,目标NVP的区块链中区块标识大于这个NVP的区块链中的最新区块的区块标识(即第三目标区块标识),且小于或等于第二区块的区块标识(即第二目标区块标识)的所有区块均为这个NVP的区块链中未存储的区块。则目标NVP可以将自身的区块链中区块标识大于第三目标区块标识且小于或等于第二目标区块标识的所有区块发送给这个NVP。这个NVP接收到目标NVP发送的区块后,可以将接收到的区块存储至自身的区块链,以实现对自身区块链中未存储的区块的同步,从而保证自身的区块链中存储的区块与其他NVP的区块链中存储的区块相同。In this case, after receiving the third message, the target NVP first checks whether there is a block with the same block ID as the second target block ID (ie, the second block) in its own blockchain, and if it finds itself If there is a second block in the blockchain of the second block, the block hash value of the second block is compared with the hash value of the second target block carried in the third message. The hash value is the same as the hash value of the second target block, indicating that the second block is one of the unstored blocks in the blockchain of this NVP. In this case, the block ID in the blockchain of the target NVP is greater than The block ID of the latest block in the blockchain of this NVP (ie, the third target block ID), and all blocks that are less than or equal to the block ID of the second block (ie, the second target block ID) All are unstored blocks in the blockchain of this NVP. Then the target NVP can send all the blocks in its own blockchain whose block identifier is greater than the third target block identifier and less than or equal to the second target block identifier to this NVP. After the NVP receives the block sent by the target NVP, it can store the received block in its own blockchain to synchronize the unstored blocks in its own blockchain, thus ensuring its own blockchain The blocks stored in the blockchain are the same as those stored in other NVP's blockchains.
可选地,在区块链系统运行的过程中,该m个NVP集群中任意的一个NVP集群中可能会新增一个NVP,新增的NVP的区块链中可能还未存储区块,因而新增的NVP可以同步所在的NVP集群中的其他NVP的区块链中存储的所有区块。这种情况下,新增的NVP可以执行上述从目标NVP中获取所有区块的步骤,以实现对所在的NVP集群中的其他NVP的区块链中存储的区块的同步。Optionally, during the operation of the blockchain system, an NVP may be added to any one of the m NVP clusters, and blocks may not yet be stored in the blockchain of the newly added NVP. The newly added NVP can synchronize all blocks stored in the blockchains of other NVPs in the NVP cluster. In this case, the newly added NVP can perform the above steps of obtaining all blocks from the target NVP, so as to synchronize the blocks stored in the blockchains of other NVPs in the NVP cluster.
以上对该m个NVP集群中的每个NVP集群中任意的一个NVP主动从目标NVP获取自身的区块链中未存储的区块的操作进行了详细说明。本申请实施例中在该m个NVP集群中的每个NVP集群中任意的一个NVP发现自身的区块链中缺少某些区块时,主动从目标NVP中获取缺少的所有区块(即点对点拉取),来实现对缺少的所有区块的同步。如此,可以节省系统资源,提高区块同步效率。The operation of any one NVP in each NVP cluster in the m NVP clusters actively acquires blocks not stored in its own blockchain from the target NVP has been described in detail above. In the embodiment of this application, when any NVP in each NVP cluster of the m NVP clusters finds that some blocks are missing in its own blockchain, it actively obtains all the missing blocks from the target NVP (that is, point-to-point pull) to synchronize all missing blocks. In this way, system resources can be saved and block synchronization efficiency can be improved.
在本申请实施例中,区块链系统包括多个VP和m个NVP集群,该多个VP中的m个VP与该m个NVP集群一一对应,且m个NVP集群中每个NVP集群包括第一NVP和至少一个第二NVP。第一NVP为与对应的VP进行通信的NVP,第一NVP与至少一个第二NVP中的每个第二NVP之间均具有网络路径,所以NVP集群中的第一NVP既可以与对应的VP进行通信,也可以与同一NVP集群中的其他NVP进行通信。该多个VP每完成对一个区块的共识并将该区块添加至区块链后,该m个VP中的每个VP向对应的NVP集群中的第一NVP发送携带有该区块的第一消息。该m个NVP集群中每个NVP集群中的每个NVP若接收到第一消息,则将第一消息携带的该区块存储至区块链,并向同一NVP集群中相邻的NVP发送第一消息,如此每个NVP集群中的每个NVP都可以同步该区块。这种情况下,m个VP中的每个VP只需要向对应的NVP集群中的第一NVP发送携带有该区块的第一消息,就可以实现对应的NVP集群中的每个NVP对该区块的同步,从而减轻了VP的压力,进而可以提高区块共识效率。In this embodiment of the present application, the blockchain system includes multiple VPs and m NVP clusters, m VPs in the multiple VPs are in one-to-one correspondence with the m NVP clusters, and each NVP cluster in the m NVP clusters A first NVP and at least one second NVP are included. The first NVP is an NVP that communicates with the corresponding VP, and there is a network path between the first NVP and each second NVP in the at least one second NVP, so the first NVP in the NVP cluster can both communicate with the corresponding VP It can also communicate with other NVPs in the same NVP cluster. After the multiple VPs complete the consensus on a block and add the block to the blockchain, each of the m VPs sends a message carrying the block to the first NVP in the corresponding NVP cluster. First news. If each NVP in each NVP cluster in the m NVP clusters receives the first message, it stores the block carried in the first message in the blockchain, and sends the first message to the adjacent NVP in the same NVP cluster. A message so that every NVP in every NVP cluster can sync the block. In this case, each VP in the m VPs only needs to send the first message carrying the block to the first NVP in the corresponding NVP cluster, so that each NVP in the corresponding NVP cluster can perform the The synchronization of blocks reduces the pressure on VPs, which in turn can improve the efficiency of block consensus.
图5为本申请实施例提供的一种计算机设备的结构示意图。如图5所示,计算机设备5包括:处理器50、存储器51以及存储在存储器51中并可在处理器50上运行的计算机程序52,处理器50执行计算机程序52时实现上述实施例中的区块同步方法中的步骤。FIG. 5 is a schematic structural diagram of a computer device according to an embodiment of the present application. As shown in FIG. 5 , the
计算机设备5可以是包括有多个服务器的服务器集群,该服务器集群可以为区块链系统。本领域技术人员可以理解,图5仅仅是计算机设备5的举例,并不构成对计算机设备5的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,比如还可以包括输入输出设备、网络接入设备等。The
处理器50可以是中央处理单元(Central Processing Unit,CPU),处理器50还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者也可以是任何常规的处理器。The
存储器51在一些实施例中可以是计算机设备5的内部存储单元,比如计算机设备5的硬盘或内存。存储器51在另一些实施例中也可以是计算机设备5的外部存储设备,比如计算机设备5上配备的插接式硬盘、智能存储卡(Smart Media Card,SMC)、安全数字(SecureDigital,SD)卡、闪存卡(Flash Card)等。进一步地,存储器51还可以既包括计算机设备5的内部存储单元也包括外部存储设备。存储器51用于存储操作系统、应用程序、引导装载程序(Boot Loader)、数据以及其他程序等。存储器51还可以用于暂时地存储已经输出或者将要输出的数据。The
本申请实施例还提供了一种计算机设备,该计算机设备包括:至少一个处理器、存储器以及存储在该存储器中并可在该至少一个处理器上运行的计算机程序,该处理器执行该计算机程序时实现上述任意各个方法实施例中的步骤。Embodiments of the present application further provide a computer device, the computer device comprising: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, the processor executing the computer program The steps in any of the foregoing method embodiments are implemented at the same time.
本申请实施例还提供了一种计算机可读存储介质,该计算机可读存储介质存储有计算机程序,该计算机程序被处理器执行时可实现上述各个方法实施例中的步骤。Embodiments of the present application further provide a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the steps in the foregoing method embodiments can be implemented.
本申请实施例提供了一种计算机程序产品,当其在计算机上运行时,使得计算机执行上述各个方法实施例中的步骤。The embodiments of the present application provide a computer program product, which, when running on a computer, enables the computer to execute the steps in the foregoing method embodiments.
集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现上述方法实施例中的全部或部分流程,可以通过计算机程序来指令相关的硬件来完成,该计算机程序可存储于一计算机可读存储介质中,该计算机程序在被处理器执行时,可实现上述各个方法实施例的步骤。其中,该计算机程序包括计算机程序代码,该计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。该计算机可读介质至少可以包括:能够将计算机程序代码携带到拍照装置/终端设备的任何实体或装置、记录介质、计算机存储器、ROM(Read-Only Memory,只读存储器)、RAM(Random Access Memory,随机存取存储器)、CD-ROM(Compact Disc Read-Only Memory,只读光盘)、磁带、软盘和光数据存储设备等。本申请提到的计算机可读存储介质可以为非易失性存储介质,换句话说,可以是非瞬时性存储介质。The integrated unit, if implemented as a software functional unit and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the foregoing method embodiments can be implemented by a computer program that instructs the relevant hardware. The computer program can be stored in a computer-readable storage medium, and the computer program can be When executed by the processor, the steps of the foregoing method embodiments may be implemented. Wherein, the computer program includes computer program code, and the computer program code may be in the form of source code, object code, executable file or some intermediate form, and the like. The computer-readable medium may include at least: any entity or device capable of carrying the computer program code to the photographing device/terminal device, recording medium, computer memory, ROM (Read-Only Memory, read-only memory), RAM (Random Access Memory) , random access memory), CD-ROM (Compact Disc Read-Only Memory, CD-ROM), magnetic tape, floppy disk and optical data storage devices, etc. The computer-readable storage medium mentioned in this application may be a non-volatile storage medium, in other words, may be a non-transitory storage medium.
应当理解的是,实现上述实施例的全部或部分步骤可以通过软件、硬件、固件或者其任意结合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。该计算机程序产品包括一个或多个计算机指令。该计算机指令可以存储在上述计算机可读存储介质中。It should be understood that, all or part of the steps of implementing the above embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented in software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. The computer instructions may be stored in the computer-readable storage medium described above.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。In the foregoing embodiments, the description of each embodiment has its own emphasis. For parts that are not described or described in detail in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each particular application, but such implementations should not be considered beyond the scope of this application.
在本申请所提供的实施例中,应该理解到,所揭露的装置/计算机设备和方法,可以通过其它的方式实现。例如,以上所描述的装置/计算机设备实施例仅仅是示意性的,例如,模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通讯连接可以是通过一些接口,装置或单元的间接耦合或通讯连接,可以是电性,机械或其它的形式。In the embodiments provided in this application, it should be understood that the disclosed apparatus/computer equipment and method may be implemented in other manners. For example, the apparatus/computer equipment embodiments described above are only illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components. May be combined or may be integrated into another system, or some features may be omitted, or not implemented. On the other hand, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, and may be in electrical, mechanical or other forms.
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。Units described as separate components may or may not be physically separated, and components shown as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。The above-mentioned embodiments are only used to illustrate the technical solutions of the present application, but not to limit them; although the present application has been described in detail with reference to the above-mentioned embodiments, those of ordinary skill in the art should understand that: it is still possible to implement the above-mentioned implementations. The technical solutions described in the examples are modified, or some technical features thereof are equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions in the embodiments of the application, and should be included in the within the scope of protection of this application.
Claims (13)
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211064387.8A CN115174598B (en) | 2022-09-01 | 2022-09-01 | Block synchronization method, block chain system, device and storage medium |
JP2023134043A JP7623444B2 (en) | 2022-09-01 | 2023-08-21 | Block synchronization method, block chain system, device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211064387.8A CN115174598B (en) | 2022-09-01 | 2022-09-01 | Block synchronization method, block chain system, device and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN115174598A true CN115174598A (en) | 2022-10-11 |
CN115174598B CN115174598B (en) | 2022-12-27 |
Family
ID=83482191
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211064387.8A Active CN115174598B (en) | 2022-09-01 | 2022-09-01 | Block synchronization method, block chain system, device and storage medium |
Country Status (2)
Country | Link |
---|---|
JP (1) | JP7623444B2 (en) |
CN (1) | CN115174598B (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104202430A (en) * | 2014-09-26 | 2014-12-10 | 浪潮电子信息产业股份有限公司 | HTTP (hyper text transport protocol) -based cluster management system and method |
CN108881231A (en) * | 2018-06-21 | 2018-11-23 | 郑州云海信息技术有限公司 | The method, apparatus and storage medium of synchronous account information in a kind of group system |
WO2020235512A1 (en) * | 2019-05-21 | 2020-11-26 | 株式会社医療情報技術研究所 | Document management system |
CN113342893A (en) * | 2021-06-09 | 2021-09-03 | 网易(杭州)网络有限公司 | Node synchronization method and device based on block chain, storage medium and server |
CN113395363A (en) * | 2021-08-18 | 2021-09-14 | 腾讯科技(深圳)有限公司 | Data processing method, device and equipment based on block chain and storage medium |
CN114218331A (en) * | 2021-12-30 | 2022-03-22 | 杭州趣链科技有限公司 | Data synchronization method, alliance block chain system, electronic device and storage medium |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109902091B (en) | 2019-02-21 | 2021-08-10 | 腾讯科技(深圳)有限公司 | Method for recording data blocks on block chain, leading accounting node and medium |
-
2022
- 2022-09-01 CN CN202211064387.8A patent/CN115174598B/en active Active
-
2023
- 2023-08-21 JP JP2023134043A patent/JP7623444B2/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104202430A (en) * | 2014-09-26 | 2014-12-10 | 浪潮电子信息产业股份有限公司 | HTTP (hyper text transport protocol) -based cluster management system and method |
CN108881231A (en) * | 2018-06-21 | 2018-11-23 | 郑州云海信息技术有限公司 | The method, apparatus and storage medium of synchronous account information in a kind of group system |
WO2020235512A1 (en) * | 2019-05-21 | 2020-11-26 | 株式会社医療情報技術研究所 | Document management system |
CN113342893A (en) * | 2021-06-09 | 2021-09-03 | 网易(杭州)网络有限公司 | Node synchronization method and device based on block chain, storage medium and server |
CN113395363A (en) * | 2021-08-18 | 2021-09-14 | 腾讯科技(深圳)有限公司 | Data processing method, device and equipment based on block chain and storage medium |
CN114218331A (en) * | 2021-12-30 | 2022-03-22 | 杭州趣链科技有限公司 | Data synchronization method, alliance block chain system, electronic device and storage medium |
Non-Patent Citations (1)
Title |
---|
ALEXANDRU STANCIU: "Blockchain based distributed control system for Edge Computing", 《2017 21ST INTERNATIONAL CONFERENCE ON CONTROL SYSTEMS AND COMPUTER SCIENCE》 * |
Also Published As
Publication number | Publication date |
---|---|
CN115174598B (en) | 2022-12-27 |
JP2024035121A (en) | 2024-03-13 |
JP7623444B2 (en) | 2025-01-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10764369B2 (en) | Data storage method and server applicable to distributed server cluster | |
CN108200210B9 (en) | Method, apparatus and computer readable medium for chain management based on blockchain | |
US20210256007A1 (en) | Blockchain system and blockchain transaction data processing method based on ethereum | |
CN110754070B (en) | Rapid propagation of recent transactions on the blockchain network | |
WO2018112805A1 (en) | Blockchain storage method and device, and node device | |
KR101871383B1 (en) | Method and system for using a recursive event listener on a node in hierarchical data structure | |
JP7589886B2 (en) | Blockchain-based data processing method, data processing device, computer device, and computer program | |
CN105656653A (en) | Network access method of newly added node in distributed coordination system, device and system | |
WO2022134797A1 (en) | Data fragmentation storage method and apparatus, a computer device, and a storage medium | |
CN114338715B (en) | Data synchronization method, blockchain system, terminal equipment and storage medium | |
EP4231167A1 (en) | Data storage method and apparatus based on blockchain network | |
CN113157450A (en) | Method and apparatus for performing blocks in a blockchain system | |
CN111813795B (en) | Method and apparatus for confirming transactions in a blockchain network | |
CN109525678B (en) | Blockchain network system and corresponding node device discovery method | |
CN111355600A (en) | Method and device for determining main node | |
CN109542981B (en) | Data synchronization system and method, electronic device and storage medium | |
CN115174598B (en) | Block synchronization method, block chain system, device and storage medium | |
CN114466034A (en) | Block chain consensus method based on anonymous main node | |
CN118838960A (en) | Data synchronization method and related device | |
CN107370716B (en) | Multicast information processing method and device | |
CN112650735B (en) | Method, device, equipment and storage medium for determining lost block of alliance chain | |
CN116170155A (en) | Consortium Blockchain Consensus Method Based on PBFT Improvement | |
CN112398934A (en) | Trusting broadcasting method based on block chain | |
CN110049082B (en) | Apparatus and method for data propagation in a distributed network | |
CN111917826A (en) | PBFT consensus algorithm based on block chain intellectual property protection |
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 |