Research Article
Blockchain-Based Authentication Scheme with an Adaptive Multi-Factor Authentication Strategy
Algorithm 1
The election algorithm of LRaft.
| | Input: The nodes participating in consensus , the number of nodes , follower node set , Candidate set , Timeout_Max | | | Output: Leader | | | Initialization: | | | //Initializing the blockchain and flags for follower nodes and candidate nodes | | (a) | For follower node in F, . For candidate node in , . | | (b) | For node in , set the initial | | | Procedure: | | | while receive request from user or detect the failure of Leader do: | | | //Start new election | | | (I) For candidate nodes: | | | for ; | | | Set timeout () | | | //Election timeout occurs, candidate nodes invite votes to win the election | | | if timeout do: | | | RequestVote | | | end if | | | (II) For follower nodes: | | | while ReceiveRequestVote do: | | | //Check whether the candidate node is legitimate and has the latest blockchain status | | | if in anddo: | | | SendVote | | | else do: | | | RefuseVote(); | | | end if | | | (III) For leader node: | | | if winElection() do: | | | //The Leader node performs the block generation operation. | | | BecomeLeader | | | | | | GenerateNewBlock() | | | SendCommitMessage() | | | end if | | | end while | | | return Leader |
|