Research Article
Blockchain Consensus Mechanism for Distributed Energy Transactions
Algorithm 1
Algorithm description of node health score evaluation strategy.
Algorithm: Health Score Evaluation Algorithm | Input (smart contract trigger condition): New node joins and a round of consensus ends. | Output: Node health score value. | 1. When new nodes are added | Trigger health score evaluation smart contract. | 2. If trust base = "A" | health score =0.6 | 3. If trust base = "B" | health score =0.6 | 4. If trust base = "C" | health score =0.4 | 5. End if | 6. when a round of consensus ends / a new block is generated. | Trigger health score evaluation smart contract | 7. If node type = primary | If the master node sends messages consistently during the consensus phase | Calculate the master node health score value according to formula (3) : | | If the master node does not send the message in time. | Calculate the master node health score value according to formula (3): | | If the master node sends messages inconsistently | | Execute the view-change protocol | 8. If node type = candidate | If candidate nodes send consistent messages | Calculate the candidate node health score value according to formula (4): | | If the candidate node did not send the message in time | | If the candidate node sends a message different from other nodes | | 9. End if | 10. End |
|