CN109728941A - A kind of block chain leader election method and device thereof - Google Patents

A kind of block chain leader election method and device thereof Download PDF

Info

Publication number
CN109728941A
CN109728941A CN201811560491.XA CN201811560491A CN109728941A CN 109728941 A CN109728941 A CN 109728941A CN 201811560491 A CN201811560491 A CN 201811560491A CN 109728941 A CN109728941 A CN 109728941A
Authority
CN
China
Prior art keywords
node
leader
core
information
election
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201811560491.XA
Other languages
Chinese (zh)
Inventor
王春峰
李军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wang Chunfeng
Original Assignee
Beijing Bixin Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Bixin Technology Co Ltd filed Critical Beijing Bixin Technology Co Ltd
Priority to CN201811560491.XA priority Critical patent/CN109728941A/en
Publication of CN109728941A publication Critical patent/CN109728941A/en
Pending legal-status Critical Current

Links

Abstract

The present invention provides a kind of block chain leaders to elect method and device thereof, the method of the present invention is according to node capacity and the predetermined backup node of set strategy, to fast implement the change of leader's node upon expiration or under emergency case, core node can quickly switch to node of participating in the election of, and new leader's node is quickly selected by ballot mode, prevent leader in license chain vacant.Leader's change speed is fast as a result, high-efficient, while can choose more complicated node selection rule, takes into account effect, efficiency and flexibility.

Description

A kind of block chain leader election method and device thereof
Technical field
The present invention relates to information technology fields, elect method and device thereof more particularly, to a kind of block chain leader.
Background technique
Block chain is a distributed system, and consistency is the critical issue of distributed system.So-called consistency refers to: right Multiple service nodes in system, under the guarantee of common recognition mechanism, multiple service nodes reach an agreement to processing result.Cause This, block chain solves the problems, such as to trust each other between distributed scene interior joint by common recognition mechanism and consistency.
The common recognition mechanism method used in existing block chain includes: that proof of work (POW), equity prove (POS), practical Byzantine failure tolerance algorithm (PBFT) and Raft etc..Some common recognition algorithms are suitable for public chain, and some is suitable for license chain (alliance's chain With privately owned chain).In license chain, although its common recognition mechanism is run on, previously selected service node is supreme, the efficiency of more public chain There is very big promotion, but how further to promote license chain common recognition mechanism performance and be still a key.Wherein, leadership candidate Lifting algorithm is the key that distributed common recognition algorithm.
Current leader's election algorithm is difficult to take into account efficiency and flexibility;Some is using how simple election algorithm, such as Side's hair in practical Byzantine failure tolerance algorithm (PBFT) based on node ID;Although what is had is flexible, many computer hardwares are relied on Factor is needed as election factor, such as IP address, CPU core number, memory size, custom list number etc. by competition The random calculation election mechanism of window wastes system time, influences system effectiveness.
Therefore, how to design and take into account leader's election algorithm of efficiency and flexibility and seem extremely important to common recognition algorithm.
Summary of the invention
It is an object of the invention to propose a kind of block chain leader election method and device thereof based on hot standby mode. The method not only can avoid the efficiency of the random electoral machinery based on the period, but also can effectively consider the ability and system of node Strategy, always selector close system strategy most suitable backup leader node alternately, thus pass through quick leader Switching avoids the time waste elected at random, to realize a kind of efficient, flexible leader's election mechanism.
To achieve the above object, a kind of block chain leader's electoral machinery provided by the invention, including
Step 1: the multiple nodes for constituting a license chain include several core nodes, and the core node is by recognizing Card authorization can participate in leader's election of common recognition algorithm, and be likely to become the node of leader in license chain;All core Heart node constitutes core node set;
The connection between core node is safeguarded by heartbeat message mode between core node two-by-two, each core node passes through Capabilities message broadcasts the ability information of itself to other core nodes;
Step 2: core node set includes one and uniquely shows leader's node (Leader-Status node);Now lead Declaration information of people's node periodically to the broadcast of every other core node about core node set is led, so that all cores The identical core node aggregate information of node maintenance;
Step 3: existing leader's node selects core node that one meets setting constraint condition alternately node (Standby-Status node);Other core nodes except existing leader's node and alternate node are both candidate nodes (Candidate-Status node);
Existing leader's node broadcasts alternative section to every other core node (including all both candidate nodes and alternate node) Oneself state is set to alternative state by point information, the core node for being selected as alternate node;
Both candidate nodes persistently keep preparing to participate in the common recognition algorithm leader election for taking over existing leader's node and then become Permit the candidate state of new leader in chain;
Step 4: when existing leader detects that predetermined period expires, issuing handover request to backup node;Backup node is received To handover request, switching confirmation message is sent to existing leader's node, existing leader's node is changed into both candidate nodes, backup node It is converted into new leader's node, new leader's node sends leader to all both candidate nodes and declares information;New leader's section Point selects new backup node according to step 3;
Step 5: (such as show leader's meshed network failure in case of anomalous event, show leader's node delay machine), Backup node can not receive the announcement message of existing leader's node within the regular hour, then backup node automatically switches to become new Leader's node;New leader's node sends leader to all both candidate nodes and declares information;New leader's node is according to step 2 Select new backup node;
Step 6: both candidate nodes persistently monitor the declaration information of existing leader's node and alternate node in license chain, such as exist The declaration information of existing leader's node and alternate node is not heard in setting time, one or more both candidate nodes (think to be permitted Existing leader's node and alternate node can be lacked in chain) by oneself state be changed to participation in the election state (Electing-Status) into And it is changed to participation in the election node;
Step 7: participation in the election node other core nodes into license chain broadcast the election declaration of oneself, and the election is declared as Advertisement information including node capacity and node state, license chain will select new leader's node in participation in the election node;
Strategy is preset according to for any core node for receiving election declaration or rule checks a participation in the election node If appropriate for becoming leader's node, or check which participation in the election node more properly becomes leader's node, and then to each Participation in the election node reverts back supports the confirmation message of its elected new leader, or does not support that it is elected new to each participation in the election node reverts back The refusal information of leader, or vote a go-ahead which participation in the election node becomes new leader's node to all participation in the election node reverts backs;
If a participation in the election node receives the core section of 2/3 or more quantity in both candidate nodes set (or core node set) The confirmation message of point, the participation in the election node are automatically converted to leader's state and become new leader's node, unsuccessful participation in the election node Automatically oneself state is changed into candidate state (Candidate-Status), transformed back into as both candidate nodes;
New leader's node checks current core node set information, declares core node aggregate information according to step 2, with And alternate node is selected according to step 3.
Wherein, heartbeat message (Heartbeat Message) is the message that a kind of transmission source is sent to recipient, this to disappear Breath can allow recipient to determine whether and when transmission source breaks down or terminate.In general, heartbeat message starts from transmission source When start to send, until transmission source close, during which transmission source can continual sending cycle or repetition message.When recipient exists Some does not receive message in the message sink period, recipient may think that transmission source has been switched off, breaks down or currently It is unavailable.Heartbeat message may be commonly used for the purpose of high availability or fault-tolerant processing.
And capabilities message is the message of periodic broadcast formula, to reflect the variation of node capacity.Capabilities message and heartbeat disappear Breath can be together.
Further, in step 1, if capabilities message or heartbeat message can not be sent to core node (i.e. other cores Heart nodal test is lost to the core node), then the core node is deleted from the core node set.
Further, constraint condition is set described in step 3 are as follows: by preset strategy or rule, selection comes the One core node is alternate node.
Further, the preset strategy or rule are for priority orders, Weight Queue or according to node energy Force information obtains function result.
Wherein, the node capacity includes CPU speed, memory size or storage size etc..
It further, further include several non-core nodes on the license chain, non-core node is through passing through Certificate Authority After can become core node, the core node being newly added persistently is monitored as both candidate nodes permits to show leader's node and standby in chain Select the declaration information of node.
Wherein, a license chain due to network or other reasons may be split into two or more subchains or two or Multiple license chains are merged into a federation chain.
Further, a license chain can split into several subchains, and the subchain is divided into: while being saved including existing leader First subchain of point and alternate node, including existing leader's node without the second subchain including alternate node, including is alternatively saved Point is without including the third subchain of existing leader's node, and neither include existing leader's node does not again include the of alternate node Four subchains;Wherein, the selected step of the leader in subchain includes:
Step 8.1: the first subchain carries out the change of leader's node according to step 4-7;
Step 8.2: existing leader selects the alternate node of the second subchain according to step 3 in the second subchain, referring next to step Rapid 4-7 carries out the change of leader's node;
Step 8.3: in third subchain, backup node can switch to new leader's node, new leader's node according to step 5 New backup node is selected according to step 3;
Step 8.4: in the 4th subchain, both candidate nodes are due to can't detect existing leader's node and backup node according to step 6 and 7 elect new leader's node, and new leader's node selects alternate node according to step 3.
Further, more than two license chains merge to form a federation chain, include more than two existing in federation chain Oneself state is changed to participation in the election state and then becomes participation in the election node by leader's node, existing leader's node, and federation chain is according to step Rapid 7 elect new leader's node, and new leader's node selects alternate node according to step 3, are led afterwards referring to step 4-7 People's node alternates.
Specifically, existing leader's node broadcasts the election of oneself as participation in the election node other core nodes into federation chain Declare, the core node of any ability of receiving declaration presets strategy according in federation chain or rule votes in new neck Lead people's node.
By adopting the above technical scheme, the invention has the following beneficial effects:
A kind of block chain leader's electoral machinery based on hot standby mode provided by the invention, according to node capacity and set The predetermined backup node of strategy, to fast implement the change of leader's node, core section upon expiration or under emergency case Point can quickly switch to node of participating in the election of, and new leader's node is quickly selected by ballot mode, prevent leader in license chain It is vacant.Leader's change speed is fast as a result, high-efficient, while can choose more complicated node selection rule, takes into account effect Fruit, efficiency and flexibility.
In addition, invention additionally discloses a kind of leader's voting device for above-mentioned block chain leader's electoral machinery, it should Voting device can be also possible to software module with the hardware cell in server.Wherein leader's voting device includes: node shape State maintenance module, both candidate nodes maintenance module, node capacity computing module, inter-node communication module, system information block and match Set policy management module;
Node state maintenance module manages and maintains the state conversion of core node, tactful or regular according to presetting, The ability information of license chain interior joint is obtained from node capacity computing module, and from both candidate nodes maintenance module and inter-node communication Module obtains the state of core node and safeguards the state conversion of core node;
Both candidate nodes maintenance module is mainly responsible for state, ability and the configuration strategy of all both candidate nodes in maintenance chain;It waits It selects node maintenance module that can receive the ability announcement message of both candidate nodes, adds and safeguard the ability information of both candidate nodes;It is candidate Node maintenance module can receive strategy and rule configuration information from configuration management module, with the row for both candidate nodes ability Sequence;Both candidate nodes maintenance module is according to the strategy and rule of the information of each both candidate nodes, and configuration, to all both candidate nodes It is ranked up, and the ability information of ranking results and each both candidate nodes is supplied to node state maintenance module;
Node capacity computing module calculates the ability information of core node, receives corresponding ability ginseng from configuration management module Number configuration obtains system information from system information block, calculates the ability value of each core node, and provide and be given to both candidate nodes Maintenance module provides the ability information of both candidate nodes, provides the status information of all core nodes to node state maintenance module;
Configuration management module provides human-computer interaction interface, is allowed for input and configuration node ability information data and leader The selection strategy information that person lifts;The selection strategy information that configuration management module elects node capacity information data and leader It is conveyed to node state maintenance module, both candidate nodes maintenance module and node capacity computing module;
System information block be responsible for interact with operating system acquisition needs system information (system can be Linux, Windows, OSX etc. and other any embedded systems);
Information transmission and exchange between network communication module responsible node, declare including leader's declaration, ability, Backup node declaration, leader elect message;Network communication module, node state maintenance module and both candidate nodes maintenance module phase It connects and realizes between core node the interaction of node state and ability information and uniformly.
Detailed description of the invention
It below will be to specific in order to illustrate more clearly of the specific embodiment of the invention or technical solution in the prior art Embodiment or attached drawing needed to be used in the description of the prior art be briefly described, it should be apparent that, it is described below Attached drawing is some embodiments of the present invention, for those of ordinary skill in the art, before not making the creative labor It puts, is also possible to obtain other drawings based on these drawings.
Fig. 1 is to permit chain interior joint deployment architecture figure in the embodiment of the present invention 1;
Fig. 2 is the structure chart of leader's voting device in the embodiment of the present invention 2;
Fig. 3 is a kind of broad flow diagram for leader's electoral machinery that the embodiment of the present invention 3 provides;
Fig. 4 is the state transition graph of core node in the embodiment of the present invention;
Fig. 5 is the flow chart that new leader elects link in the embodiment of the present invention.
Specific embodiment
Below with reference to specific embodiment the present invention will be further explained explanation.
Embodiment 1
A kind of block chain leader's electoral machinery provided in this embodiment, including
Step 1: the multiple nodes for constituting a license chain include several core nodes, and the core node is by recognizing Card authorization can participate in leader's election of common recognition algorithm, and be likely to become the node of leader in license chain;All core Heart node constitutes core node set;
Fig. 1 is to permit chain interior joint deployment architecture figure in the present embodiment.As shown in Figure 1, have 6 nodes in license chain, Its interior joint 101,102,103 and 104 is core node, and constitutes core node set 100={ 101,102,103,104 }, Node 105,106 is non-core node.
Each core node (i.e. all core nodes of 101-104) periodically calculates the node capacity of oneself, and to its His its state of core node periodic broadcast and ability, so that existing leader's node and whole network understand the shape of this node State, and safeguard newest core node aggregate information.
Safeguard the company between core node in core node 101,102,103,104 by heartbeat message mode between any two Logical, each core node handling capacity message broadcasts the ability information of itself to other core nodes.Specifically, each node Between by virtual link 107-112 safeguard any two node between message communicating.
Wherein, if capabilities message or heartbeat message can not be sent to a core node, (i.e. other core nodes are detected The core node is lost), then the core node is deleted from the core node set.
Step 2: core node set includes one and uniquely shows leader's node (Leader-Status node);Now lead Declaration information of people's node periodically to the broadcast of every other core node about core node set is led, so that all cores The identical core node aggregate information of node maintenance.
Wherein, node 101 is existing leader's node, is in leader's state (Leader-Status);Existing leader's node 101 periodically broadcast the declaration information about core node set to core node 102,103 and 104, so that all cores Identical core node aggregate information is safeguarded between node 101,102,103 and 104.
Step 3: existing leader's node selects core node that one meets setting constraint condition alternately node (Standby-Status node);Other core nodes except existing leader's node and alternate node are both candidate nodes (Candidate-Status node);
Existing leader's node broadcasts alternative section to every other core node (including all both candidate nodes and alternate node) Oneself state is set to alternative state by point information, the core node for being selected as alternate node;
Both candidate nodes persistently keep preparing to participate in the common recognition algorithm leader election for taking over existing leader's node and then become Permit the candidate state of new leader in chain;
When existing leader's node 101 generates, existing leader's node 101 can select an alternate node, example immediately Such as according to the rule of agreement and strategy, core node 102 is to be chosen as backup node, and existing leader's node 101 can send backup Message is changed into backup node to core node 102, core node 102.
Core node 103 and 104 item becomes both candidate nodes, and is in candidate state (Candidate-status).
In addition, the node in license chain constantly safeguards that the state of itself is converted, any one core node being newly added, just Beginning state is in candidate state automatically, and becomes both candidate nodes.
Such as assume that non-core 104 node is changed into core node, before this, core node after compound setting condition Set 100 is { 101,102,103 }, and leader's declaration that marquis listens to existing leader's node 101 is added in node 104, as new The core node of addition automatically becomes both candidate nodes.
104 issue the ability declaration of oneself to other core nodes simultaneously, and existing leader's node 101 receives 104 ability Declaration, existing leader's node 101 update core node aggregate information, 104 are added in both candidate nodes, and both candidate nodes set= { 103,104 }, core node set { 101,102,103 } become core node set { 101,102,103,104 }, existing leader New core node aggregate information publication is permitted chain node, unified the whole network information by node 101 entirely.
Wherein setting constraint condition can be by preset strategy or rule, choose the core node to make number one For alternate node.Such as preset strategy or rule are for priority orders, Weight Queue or according to node capacity information Obtain function result.Wherein node capacity includes CPU speed, memory size or storage size etc..
Step 4: when existing leader detects that predetermined period expires, issuing handover request to backup node;Backup node is received To handover request, switching confirmation message is sent to existing leader's node, existing leader's node is changed into both candidate nodes, backup node It is converted into new leader's node, new leader's node sends leader to all both candidate nodes and declares information;New leader's section Point selects new backup node according to step 3.
After i.e. about fixed cycle expires, alternate node 102 automatically becomes new leader node.
Step 5: (such as show leader's meshed network failure in case of anomalous event, show leader's node delay machine), Backup node can not receive the announcement message of existing leader's node within the regular hour, and backup node automatically switches to become new neck Lead people's node;New leader's node sends leader to all both candidate nodes and declares information;New leader's node is selected according to step 2 Select new backup node;
If existing 101 delay machine of leader's node, backup node 102 can not receive the leader from 101 in the regular hour People's announcement message, backup node 102 automatically switch to become new leader's node (alternatively, backup node 102 can give core node collection The handover request of other core nodes hair backup node in conjunction, after the reply wait receive other core nodes 103 and 104, New leader's node can be automatically become).
Step 6: both candidate nodes persistently monitor the declaration information of existing leader's node and alternate node in license chain, such as exist The declaration information of existing leader's node and alternate node is not heard in setting time, one or more both candidate nodes (think to be permitted Existing leader's node and alternate node can be lacked in chain) by oneself state be changed to participation in the election state (Electing-Status) into And it is changed to participation in the election node;
Step 7: participation in the election node other core nodes into license chain broadcast the election declaration of oneself, and the election is declared as Advertisement information including node capacity and node state, license chain will select new leader's node in participation in the election node;
Strategy is preset according to for any core node for receiving election declaration or rule checks a participation in the election node If appropriate for becoming leader's node, or check which participation in the election node more properly becomes leader's node, and then to each Participation in the election node reverts back supports the confirmation message of its elected new leader, or does not support that it is elected new to each participation in the election node reverts back The refusal information of leader, or vote a go-ahead which participation in the election node becomes new leader's node to all participation in the election node reverts backs;
If a participation in the election node receives the core section of 2/3 or more quantity in both candidate nodes set (or core node set) The confirmation message of point, the participation in the election node are automatically converted to leader's state and become new leader's node, unsuccessful participation in the election node Automatically oneself state is changed into candidate state (Candidate-Status), transformed back into as both candidate nodes;
New leader's node checks current core node set information, declares core node aggregate information according to step 2, with And alternate node is selected according to step 3.
Wherein, heartbeat message (Heartbeat Message) is the message that a kind of transmission source is sent to recipient, this to disappear Breath can allow recipient to determine whether and when transmission source breaks down or terminate.In general, heartbeat message starts from transmission source When start to send, until transmission source close, during which transmission source can continual sending cycle or repetition message.When recipient exists Some does not receive message in the message sink period, recipient may think that transmission source has been switched off, breaks down or currently It is unavailable.Heartbeat message may be commonly used for the purpose of high availability or fault-tolerant processing.
And capabilities message is the message of periodic broadcast formula, to reflect the variation of node capacity.Capabilities message and heartbeat disappear Breath can be together.
For example, existing leader's node 101 and backup node 102 all go wrong, both candidate nodes 103 are within the regular hour 101 leader's declaration and the declaration of 102 backup nodes are not monitored, then it is assumed that save in license chain without leader and backup Point needs to elect new leader's node, then the state of oneself is changed to participation in the election state (Electing- by core node 103 Status), the election that other core nodes broadcast oneself into license chain is declared.If receive core node 104 support its The confirmation message of leader-elect, both candidate nodes 103 are then converted to new leader's node, are otherwise still converted to candidate state.
One license chain is since network or other reasons may be split into two or more subchains or two or more be permitted Can chain be merged into a federation chain.One license chain can split into several subchains, and the subchain is divided into: while including now leading First subchain of people's node and alternate node, including existing leader's node without the second subchain including alternate node, including it is standby It selects node without including the third subchain of existing leader's node, and neither includes existing leader's node and do not include alternate node The 4th subchain;Wherein, the selected step of the leader in subchain includes:
Step 8.1: the first subchain carries out the change of leader's node according to step 4-7;
Step 8.2: existing leader selects the alternate node of the second subchain according to step 3 in the second subchain, referring next to step Rapid 4-7 carries out the change of leader's node;
Step 8.3: in third subchain, backup node can switch to new leader's node, new leader's node according to step 5 New backup node is selected according to step 3;
Step 8.4: in the 4th subchain, both candidate nodes are due to can't detect existing leader's node and backup node according to step 6 and 7 elect new leader's node, and new leader's node selects alternate node according to step 3.
And more than two license chains merge to form a federation chain, include more than two existing leader's sections in federation chain Oneself state is changed to participation in the election state and then becomes participation in the election node by point, existing leader's node, and federation chain is elected according to step 7 New leader's node, new leader's node select alternate node according to step 3, rear to carry out leader's node more referring to step 4-7 Repeatedly.
Specifically, existing leader's node broadcasts the election of oneself as participation in the election node other core nodes into federation chain Declare, the core node of any ability of receiving declaration presets strategy according in federation chain or rule votes in new neck Lead people's node.Its interior joint can be server, desktop computer, laptop or handheld-type intelligent machine etc..
A kind of block chain leader's electoral machinery based on hot standby mode provided by the invention, according to node capacity and set The predetermined backup node of strategy, to fast implement the change of leader's node, core section upon expiration or under emergency case Point can quickly switch to node of participating in the election of, and new leader's node is quickly selected by ballot mode, prevent leader in license chain It is vacant.Leader's change speed is fast as a result, high-efficient, while can choose more complicated node selection rule, takes into account effect Fruit, efficiency and flexibility.
Embodiment 2
Present embodiment discloses a kind of leader's voting devices for leader's election, which can be with server In hardware cell, be also possible to software module.From figure 2 it can be seen that leader's voting device for leader's election 200 include node state maintenance module 201, both candidate nodes maintenance module 202, node capacity computing module 203, inter-node communication Module 204, system information block 205 and configuration strategy management module 206 form.
Node state maintenance module 201 manages and maintains the state conversion of core node, and foundation presets strategy or rule Then, the ability information of license chain interior joint is obtained from node capacity computing module 203, and from 202 He of both candidate nodes maintenance module Inter-node communication module 204 obtains the state of core node and safeguards the state conversion of core node.
Both candidate nodes maintenance module 202 is mainly responsible for state, ability and the configuration strategy of all both candidate nodes in maintenance chain Deng.Both candidate nodes maintenance module can receive the ability announcement message of both candidate nodes, add and safeguard the ability information of both candidate nodes; Both candidate nodes maintenance module can receive strategy and rule configuration information from configuration management module 206, to be used for both candidate nodes The sequence of ability;Both candidate nodes maintenance module 202 is according to the strategy and rule of the information of each both candidate nodes, and configuration, to institute Some both candidate nodes are ranked up, and the ability information of ranking results and each both candidate nodes is supplied to node state maintenance mould Block 201.
Node capacity computing module 203 calculates the ability information of core node, receives accordingly from configuration management module 206 Ability parameter configuration obtains system information from system information block 205, calculates the ability value of each core node, and be supplied to The ability information of both candidate nodes is provided to both candidate nodes maintenance module 202, provides all cores to node state maintenance module 201 The status information of node.
Configuration management module 206 provides human-computer interaction interface, is allowed for input and configuration node ability information data, neck The information such as the selection strategy of person's act are led, the selection strategy of leader's election includes but is not limited to priority policy, weighting node Power strategy etc..These information are supplied to node state maintenance module 201, both candidate nodes maintenance module 202 and node capacity Computing module 203 uses.
System information block 205 be responsible for system interaction obtain need system information, system can be Linux, Windows, OSX etc. and other any embedded systems.
Information transmission and exchange between 204 responsible node of network communication module, are declared including leader's declaration, ability It accuses, backup node is declared, leader elects message etc..Network communication module 204, node state maintenance module 201 and candidate Node maintenance module 202 is interengageable for the interaction of node state and information between node.
Embodiment 3
Present embodiment discloses a kind of main flows of leader's electoral machinery.As shown in figure 3, it is based on this process, neck The state of node can be safeguarded automatically by leading people's voting device, and common recognition algorithm can be automatically run between each core node, from And in guarantee system information consistency.The algorithm includes:
Step S1: core node set is added in any one new node, and original state is all candidate state, both candidate nodes The node capacity information of itself is collected first, and handling capacity declaration is sent to other all core nodes.
Step S2: both candidate nodes monitor the existing leader declaration (declaration or wide that existing leader's node issues in license chain Accuse information) or backup node declaration (declaration or advertising information that alternate node issues);
Step S2.1: judge whether to receive existing leader's declaration or backup node declaration, step is turned to if receiving S2.3;If confiscated, step S2.2 is turned to.
Step S2.2: both candidate nodes and alternate node do not receive existing leader's declaration, and each core node checks oneself Whether it is in alternative state, i.e., oneself whether is alternate node, if it is, alternate node, which executes step S3, realizes that leader cuts It changes.If it is not, core node is in candidate state, both candidate nodes do not receive the declaration of alternate node yet, then follow the steps S3.1 carries out new leader's election.
Step S2.3: both candidate nodes receive existing leader declaration, then can check whether receive existing leader's node about The assignment messages of backup node, if a both candidate nodes receive assignment information, which thens follow the steps S2.5, will be certainly Body state is changed to alternative state;If not receiving assignment information, thens follow the steps S2.4 core node and keep candidate state.
Step S4: the ability information of each core node periodic harvest and more new node, and send ability information declaration.
Fig. 4 transition diagram between core node state;As shown in figure 4, any core node is there are four types of operating status, and this four Kind state is in dynamic transition, these four states are: candidate state (Candidate-Status) 401, participation in the election state (Electing-Status) 402, leader's state (Leader-Status) 403 and and alternative state (Standby- Status)404.Wherein, participation in the election state is changed by candidate state, i.e., there are candidate states and participation in the election state for both candidate nodes.
Wherein, candidate state indicates that the core node is pure both candidate nodes, the node of any new addition, initialization State is candidate state.Node in candidate state receives any leader's declaration or backup leader's declaration, keeps candidate State.
If the core node of candidate state receives backup leader's assignment messages of existing leader's node, it is switched to standby Select state.
If existing leader's declaration or backup section is not detected in the core node in candidate state within the regular hour The declaration of point then enters participation in the election state and issues leadership candidate and lifts request.
If supporting to reply in the core node that the core node in participation in the election state receives shows the section less than 2/3 Point can't be new leader, then switches back into candidate state.
If if the confirmation letter of the support for 2/3 or more the core node that the core node in participation in the election state receives Breath, then the core node will become new leader, then the core node is switched to leader's state.
Node in alternative state, if detecting that without response, leader's switching, switching occur for existing leader's node To leader's state.If being in the node of leader's state, after leader's switching occurs, state switches back into candidate state.
Fig. 5 is the flow chart that new leader elects link.As shown in figure 5, if a core node does not monitor perhaps It can leader's declaration and backup leader's declaration in chain, then it is assumed that without leader and backup leader's node in license chain, need New leader's node is elected, new leader's election process is triggered.The process is as follows:
Step M1: the state of oneself is changed to participation in the election state by both candidate nodes, and into chain, other both candidate nodes broadcast oneself Election declaration.Election declaration is the announcement message for including node capacity information and status information.And wait other both candidate nodes It replys.
Step M2: check that receiving election confirmation message (supports it to save as new leader before election declaration time-out Point confirmation message) quantity whether be greater than the 2/3 of both candidate nodes quantity;
Step M3: if the election confirmation message quantity received 2/3 or more of both candidate nodes quantity, the both candidate nodes New leader's node can be become, and issue leader's declaration.
Step M4: if election declaration time-out, or the election confirmation message quantity received would be less than both candidate nodes quantity 2/3, then the both candidate nodes then can't be new leader's node;
Check whether that receive new leader's declaration or backup leader's announcement message starts if all confiscated at this time New wheel new leader's election, the both candidate nodes still keep participation in the election state, repeat step 1-4 until new leader's node selects Out.
Step M5: if the both candidate nodes in participation in the election state receive new leader's declaration or backup leader's declaration, Then switch back into candidate state.
Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention., rather than its limitations;To the greatest extent Pipe present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that: its according to So be possible to modify the technical solutions described in the foregoing embodiments, or to some or all of the technical features into Row equivalent replacement;And these are modified or replaceed, various embodiments of the present invention technology that it does not separate the essence of the corresponding technical solution The range of scheme.

Claims (9)

1. a kind of block chain leader's electoral machinery characterized by comprising
Step 1: the multiple nodes for constituting a license chain include several core nodes, and the core node is to award by certification Power can participate in leader's election of common recognition algorithm, and be likely to become the node of leader in license chain;All core sections Point constitutes core node set;
The connection between core node, each core node handling capacity are safeguarded by heartbeat message mode between core node two-by-two Message broadcasts the ability information of itself to other core nodes;
Step 2: core node set includes one and uniquely shows leader's node;Existing leader's node periodically to it is all its His core node broadcasts the declaration information about core node set, so that all core nodes safeguard identical core node collection Close information;
Step 3: existing leader's node selects core node that one meets setting constraint condition alternately node;Existing leader Other core nodes except node and alternate node are both candidate nodes;
Existing leader's node broadcasts alternate node information to every other core node, and the core node for being selected as alternate node will Oneself state is set to alternative state;
Both candidate nodes persistently keep preparing to participate in the common recognition algorithm leader election for taking over existing leader's node and then become license The candidate state of new leader in chain;
Step 4: when existing leader detects that predetermined period expires, issuing handover request to backup node;Backup node, which receives, to be cut Message is changed, sends switching confirmation message to existing leader's node, existing leader's node is changed into both candidate nodes, backup node conversion As new leader's node, new leader's node sends leader to all both candidate nodes and declares information;New leader's node root New backup node is selected according to step 3;
Step 5: in case of anomalous event, the declaration that backup node can not receive existing leader's node within the regular hour disappears Breath, then backup node automatically switches to become new leader's node;New leader's node sends leader a surname to all both candidate nodes Accuse information;New leader's node selects new backup node according to step 2;
Step 6: both candidate nodes persistently monitor the declaration information of existing leader's node and alternate node in license chain, are such as setting The declaration information of existing leader's node and alternate node is not heard in time, one or more both candidate nodes become oneself state More participation in the election state is changed to participation in the election node in turn;
Step 7: participation in the election node to license chain in other core nodes broadcast oneself election declaration, it is described election be declared as include The advertisement information of node capacity and node state, license chain will select new leader's node in participation in the election node;
It is any receive election declaration core node according to preset strategy or rule inspection one participation in the election node if appropriate for As leader's node, or check which participation in the election node more properly becomes leader's node, and then to each participation in the election node The confirmation message for supporting its elected new leader is replied, or does not support its elected new leader's to each participation in the election node reverts back Refuse information, or votes a go-ahead which participation in the election node becomes new leader's node to all participation in the election node reverts backs;
If a participation in the election node receives the confirmation message of the core node of 2/3 or more quantity in both candidate nodes set, the participation in the election Node is automatically converted to leader's state and becomes new leader's node, and oneself state is changed by unsuccessful participation in the election node automatically Candidate state transforms back into as both candidate nodes;
New leader's node checks current core node set information, declares core node aggregate information, Yi Jigen according to step 2 Alternate node is selected according to step 3.
2. block chain leader's electoral machinery according to claim 1, which is characterized in that in step 1, if capabilities message Or heartbeat message can not be sent to a core node, then delete the core node from the core node set.
3. block chain leader's electoral machinery according to claim 1, which is characterized in that set constraint described in step 3 Condition are as follows: by preset strategy or rule, choosing the core node to make number one is alternate node.
4. block chain leader's electoral machinery according to claim 3, which is characterized in that it is described it is preset strategy or Rule is priority orders, Weight Queue or obtains function result according to node capacity information.
5. block chain leader's electoral machinery according to claim 4, which is characterized in that the node capacity includes CPU Speed, memory size or storage size.
6. block chain leader's electoral machinery according to claim 1, which is characterized in that if further including on the license chain Dry non-core node, non-core node can become core node, the core node conduct being newly added after through Certificate Authority Both candidate nodes persistently monitor the declaration information of existing leader's node and alternate node in license chain.
7. block chain leader's electoral machinery according to claim 1, which is characterized in that if a license chain can be split into Dry subchain, the subchain are divided into: while the first subchain including existing leader's node and alternate node, including existing leader section Point is without the second subchain including alternate node, including alternate node without the third subchain including existing leader's node, and It neither include the 4th subchain that existing leader's node does not include alternate node again;Wherein, the leader in subchain selectes step packet It includes:
Step 8.1: the first subchain carries out the change of leader's node according to step 4-7;
Step 8.2: existing leader selects the alternate node of the second subchain according to step 3 in the second subchain, referring next to step 4-7 Carry out the change of leader's node;
Step 8.3: in third subchain, backup node can switch to new leader's node according to step 5, new leader's node according to Step 3 selects new backup node;
Step 8.4: in the 4th subchain, both candidate nodes are due to can't detect existing leader's node and backup node according to step 6 and 7 New leader's node is elected, new leader's node selects alternate node according to step 3.
8. block chain leader's electoral machinery according to claim 1, which is characterized in that more than two license chains merge A federation chain is formed, includes more than two existing leader's nodes in federation chain, existing leader's node changes oneself state For participation in the election state and then become participation in the election node, federation chain elects new leader's node according to step 7, new leader's node according to Step 3 selects alternate node, rear to carry out the change of leader's node referring to step 4-7.
9. a kind of leader's voting device for any block chain leader's electoral machinery of claim 1-8, special Sign is, comprising: node state maintenance module, both candidate nodes maintenance module, node capacity computing module, inter-node communication mould Block, system information block and configuration strategy management module;
Node state maintenance module manages and maintains the state conversion of core node, according to strategy or rule is preset, from section Point capacity calculation module obtains the ability information of license chain interior joint, and from both candidate nodes maintenance module and inter-node communication module It obtains the state of core node and safeguards the state conversion of core node;
Both candidate nodes maintenance module is mainly responsible for state, ability and the configuration strategy of all both candidate nodes in maintenance chain;Candidate's section Point maintenance module can receive the ability announcement message of both candidate nodes, add and safeguard the ability information of both candidate nodes;Both candidate nodes Maintenance module can receive strategy and rule configuration information from configuration management module, with the sequence for both candidate nodes ability; Both candidate nodes maintenance module according to the strategy and rule of the information of each both candidate nodes, and configuration, to all both candidate nodes into Row sequence, and the ability information of ranking results and each both candidate nodes is supplied to node state maintenance module;
Node capacity computing module calculates the ability information of core node, receives corresponding ability parameter from configuration management module and matches It sets, obtains system information from system information block, calculate the ability value of each core node, and provide and be given to both candidate nodes maintenance Module provides the ability information of both candidate nodes, provides the status information of all core nodes to node state maintenance module;
Configuration management module provides human-computer interaction interface, is allowed for input and configuration node ability information data and leadership candidate The selection strategy information of act;The selection strategy information conveyance that configuration management module elects node capacity information data and leader To node state maintenance module, both candidate nodes maintenance module and node capacity computing module;
System information block is responsible for interacting the system information for obtaining and needing with operating system;
Information transmission and exchange between network communication module responsible node, including leader's declaration, ability declaration, backup Node declaration, leader elect message;Network communication module, node state maintenance module are mutually interconnected with both candidate nodes maintenance module Connect the interaction and uniformly for realizing node state and ability information between core node.
CN201811560491.XA 2018-12-20 2018-12-20 A kind of block chain leader election method and device thereof Pending CN109728941A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811560491.XA CN109728941A (en) 2018-12-20 2018-12-20 A kind of block chain leader election method and device thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811560491.XA CN109728941A (en) 2018-12-20 2018-12-20 A kind of block chain leader election method and device thereof

Publications (1)

Publication Number Publication Date
CN109728941A true CN109728941A (en) 2019-05-07

Family

ID=66296210

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811560491.XA Pending CN109728941A (en) 2018-12-20 2018-12-20 A kind of block chain leader election method and device thereof

Country Status (1)

Country Link
CN (1) CN109728941A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110493187A (en) * 2019-07-10 2019-11-22 布比(北京)网络技术有限公司 A kind of the verifying node electoral machinery and system of block chain
CN110855793A (en) * 2019-11-19 2020-02-28 南昌航空大学 Distributed system consensus method
CN111107103A (en) * 2019-12-31 2020-05-05 南京可信区块链与算法经济研究院有限公司 Method, system and storage medium for maintaining performance of alliance chain
CN112073250A (en) * 2020-09-17 2020-12-11 新华三信息安全技术有限公司 Controller cluster fault processing method and device, controller and controller cluster
US20210097538A1 (en) * 2019-09-27 2021-04-01 Cypherium Blockchain Inc. Systems and methods for managing data generation, storage, and verification in a distributed system having a committee of validator nodes

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104283948A (en) * 2014-09-26 2015-01-14 东软集团股份有限公司 Server cluster system and load balancing implementation method thereof
CN106911524A (en) * 2017-04-27 2017-06-30 紫光华山信息技术有限公司 A kind of HA implementation methods and device
CN106952207A (en) * 2017-03-10 2017-07-14 深圳市博信诺达经贸咨询有限公司 Monitor the electoral machinery and system of cloud platform distributed system
EP3247090A1 (en) * 2015-02-10 2017-11-22 Huawei Technologies Co., Ltd. Method, device and system for processing fault in at least one distributed cluster

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104283948A (en) * 2014-09-26 2015-01-14 东软集团股份有限公司 Server cluster system and load balancing implementation method thereof
EP3247090A1 (en) * 2015-02-10 2017-11-22 Huawei Technologies Co., Ltd. Method, device and system for processing fault in at least one distributed cluster
CN106952207A (en) * 2017-03-10 2017-07-14 深圳市博信诺达经贸咨询有限公司 Monitor the electoral machinery and system of cloud platform distributed system
CN106911524A (en) * 2017-04-27 2017-06-30 紫光华山信息技术有限公司 A kind of HA implementation methods and device

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110493187A (en) * 2019-07-10 2019-11-22 布比(北京)网络技术有限公司 A kind of the verifying node electoral machinery and system of block chain
US20210097538A1 (en) * 2019-09-27 2021-04-01 Cypherium Blockchain Inc. Systems and methods for managing data generation, storage, and verification in a distributed system having a committee of validator nodes
US11907174B2 (en) * 2019-09-27 2024-02-20 Cypherium Blockchain Inc. Systems and methods for managing data generation, storage, and verification in a distributed system having a committee of validator nodes
CN110855793A (en) * 2019-11-19 2020-02-28 南昌航空大学 Distributed system consensus method
CN111107103A (en) * 2019-12-31 2020-05-05 南京可信区块链与算法经济研究院有限公司 Method, system and storage medium for maintaining performance of alliance chain
CN111107103B (en) * 2019-12-31 2022-04-15 南京可信区块链与算法经济研究院有限公司 Method, system and storage medium for maintaining performance of alliance chain
CN112073250A (en) * 2020-09-17 2020-12-11 新华三信息安全技术有限公司 Controller cluster fault processing method and device, controller and controller cluster
CN112073250B (en) * 2020-09-17 2022-03-22 新华三信息安全技术有限公司 Controller cluster fault processing method and device, controller and controller cluster

Similar Documents

Publication Publication Date Title
CN109728941A (en) A kind of block chain leader election method and device thereof
Singh Leader election in the presence of link failures
Ramachandran et al. Clustering algorithms for wireless ad hoc networks
CN102402395B (en) Quorum disk-based non-interrupted operation method for high availability system
CN101702721B (en) Reconfigurable method of multi-cluster system
CN101924650B (en) Method for implementing services and intelligent server autonomy of failure information system
CN105471622B (en) A kind of high availability method and system of the control node active-standby switch based on Galera
CN102984042B (en) Deterministic scheduling method and system for realizing bus communication
CN109040184B (en) Host node election method and server
Duolikun et al. Energy-Aware Passive Replication of Processes.
CN202870563U (en) Distributed comprehensive monitoring system
CN113242553B (en) Malicious node detection method based on block chain fragmentation
CN103164262A (en) Task management method and device
CN102387210B (en) Distribution type file system monitoring method based on rapid synchronization network
CN103262470A (en) FCoE network linking management method, device and system
Bounceur et al. A wait-before-starting algorithm for fast, fault-tolerant and low energy leader election in WSNs dedicated to smart-cities and IoT
CN104079663A (en) Distributed type real-time synchronizing network system and data annunciating method thereof
CN101778091B (en) Expandable security server alternate system
Cahng et al. A consensus-based leader election algorithm for wireless ad hoc networks
Amiri et al. New algorithm for leader election in distributed WSN with software agents
CN106844021B (en) Computing environment resource management system and management method thereof
KR101110675B1 (en) asynchronous COMMAND ACHIEVING METHOD OF REMOTE METER READING SYSTEM
CN112395269A (en) Method and device for building MySQL high-availability group
Hutle On omega in sparse networks
Park et al. An election protocol in mobile ad hoc distributed systems

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20200106

Address after: 100080 Beijing Haidian District 19 Zhongguancun Road, Chinese Academy of Sciences Talent Exchange Center

Applicant after: Wang Chunfeng

Address before: 100094 Beijing Haidian District Yongjia North Road, No. 6, Building 5, 2-storey East 162

Applicant before: BEIJING BIXIN TECHNOLOGY Co.,Ltd.

RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20190507