## 5 Modification of the HBFT Algorithm
### Algorithm  
The HBFT algorithm is an improved version of the PBFT (Practical Byzantine Fault Tolerance) consensus algorithm, where consensus can be reached by a subset of nodes corresponding to less than two-thirds of the total nodes. PBFT consensus requires all nodes to perform repeated verification and confirmation, which increases the operational cost of the network and leads to duplicate processing.  
In our mHBFT algorithm, our goal is to improve the efficiency and stability of the PBFT consensus algorithm in asynchronous networks by adopting flexible node selection and leader node election formulas during the consensus process. Unlike the previous HBFT algorithm, which used a fixed method to select representative nodes, our improved algorithm employs a flexible approach for this purpose. Figure 7 illustrates the consensus process of our improved HBFT algorithm. To enhance the performance of the blockchain, we utilize a more efficient broadcasting method. Instead of broadcasting data to all nodes like in the PBFT algorithm, we only broadcast data to nodes within our own group. Additionally, we only accept reply messages from nodes within our group. This communication strategy significantly reduces the complexity of the algorithm and simplifies the consensus process, thereby improving the overall performance of the blockchain. By leveraging this approach, we can achieve a more streamlined and efficient consensus process in the mHBFT algorithm, leading to increased throughput and reduced latency in the blockchain network.  
Moreover, our algorithm incorporates the RAFT election approach in the election process, granting greater power to individual nodes. This results in increased randomness in the selection of leader nodes, which helps to better protect the blockchain network.  
The RAFT algorithm is a consensus algorithm used in distributed systems. Its goal is to achieve consistency and fault tolerance in a distributed system, ensuring data consistency among multiple nodes and maintaining system availability in the event of node failures. The RAFT algorithm achieves consensus by electing a leader and using a heartbeat mechanism to maintain the continuity of the leader. Each node can be a candidate, leader, or follower. When a node starts up, it becomes a candidate and initiates a new election. During the election process, the candidate requests votes from other nodes and becomes the leader when it receives a majority of votes. Nodes can time out during the election process to prevent the process from indefinitely prolonging. In summary, the RAFT algorithm is a consensus algorithm used to achieve consistency in distributed systems. It employs leader election, log replication, and security mechanisms to achieve fault tolerance and data consistency.  
Based on the characteristics of the RAFT algorithm and drawing inspiration from multiple papers that combine PBFT with the RAFT algorithm, we propose the integration  
Figure 7: The process of reaching consensus.  
of the HBFT algorithm with the RAFT algorithm. In Figure 8, we demonstrate the transition relationships between the leader, candidate, and follower states in the RAFT algorithm. In our assumed scenario, our algorithm ensures that each layer and each group have at least nodes participating in the consensus. By having a minimum of nodes participating in each layer and group, our algorithm satisfies both the minimum node requirement for consensus involved in the PBFT algorithm and the minimum node requirement for the election phase in the RAFT algorithm. Our integrated algorithm can promptly react and elect a new leader when a leader node is either elected or detected to have problems, making our network more stable. This integration allows us to leverage the advantages of both algorithms and enhance consensus efficiency and stability.