Research Article
Blockchain Consensus Mechanism for Distributed Energy Transactions
Algorithm 3
Description of the main chain consensus algorithm.
Algorithm: Main Chain Consensus Algorithm | Input: Transaction Collection | Output: New Block | 1. The master node sends the packaged transaction set to the blockchain network | 2. Broad coast pre-prepare message to consensus node | 3. The master node starts the timer | 4. When the consensus node receives the pre-preparation message | Perform verification | If verification passed | Send prepare message back to master node | If the number of messages received by the master node within the timer ≥ 2f | Then multicast a prepare message | Else | End this round of consensus | 5. When the consensus node receives the prepare message | Perform verification | If verification passed | Then send a commit message to the master | When the number of commit messages received by the master node ≥ 2f | The master node sends a commit collection message to the non-master node | When the non-master node receives the commit collection message | Perform verification | If verification passed | Then copy the new block content to the local | End if | End if | 6. End |
|