## 3 Proposed PBFT Architecture and Model
### Consensus Process of Proposed PBFT
#### 3.3.4 Dynamic Group and Hierarchy Management  
This section explains how the proposed PBFT dynamically changes and manages the number of groups and hierarchical structure. The expected consensus time for each cluster varies according to the hierarchical structure configuration. We can define a function in the form of \(T_{total}(c,g,n)\) based on Equation (8). Here, \(c\) represents the maximum number of child nodes that both CPN and GPN can have, \(g\) denotes the number of nodes composing the group, and \(n\) denotes the total number of nodes within one cluster. For example, in the case of \(T_{total}(4,4,120)\), where the maximum number of child nodes for both CPN and GPN is four, and four nodes form a group and 120 nodes in a single cluster, it calculates the expected time required for consensus. Therefore, using Equation (17), we can determine the best hierarchical structure and estimate the expected consensus time. \[T_{expected}=\min_{c,g,n}T_{total}(c,g,n) \tag{17}\]  
In the proposed PBFT method, we designed an algorithm to dynamically adjust the hierarchical structure for each cluster based on Equation (17). Each CPN periodically monitors changes in the number of nodes participating in the blockchain network. Suppose there is a change in the number of participating nodes, or consensus has been reached more than a certain number of times after restructuring the network's hierarchical structure. In that case, the CPN executes the algorithm to dynamically change the network's hierarchical structure. As previously explained, each CPN uses Equation (17) to derive the best network hierarchical structure. CPN includes information about the new groups and hierarchical structure in the consensus message during the Request phase and transmits it. Upon receiving the message containing group information, GPN carries out the consensus with the new group members. Algorithms 1 and 2 represent our dynamic group and hierarchy management algorithm used in the proposed PBFT method in pseudocode form. ```
1:\(TH_{\textit{consensus}}\leftarrow\) Set the threshold for the number of consensus processes that can be executed after reorganizing the network hierarchical structure
2:\(N_{\textit{consensus}}\gets 0\)
3:while 1 do
4: Do consensus operation
5:\(N_{\textit{consensus}}\leftarrow N_{\textit{consensus}}+1\)
6:if\(N_{\textit{node}}\) is changed? or \(N_{\textit{consensus}}>TH_{\textit{consensus}}\)then
7:\(GHI\leftarrow\) Call the Get_Best_GHI0
8:\(N_{\textit{consensus}}\gets 0\)
9: Propagate the GHI information to other nodes in the network
10:endif
11:endwhile
```  
**Algorithm 1** Check_Status()  
Each CPN performs Algorithm 1. As depicted in Algorithm 1, it operates in a continuous loop to manage consensus operations within a blockchain network. Initially, it set a threshold value \(TH_{\textit{consensus}}\), which means the number of consensus processes permissible after restructuring the network's hierarchical organization. The algorithm then initializes a counter, \(N_{\textit{consensus}}\), to zero. This counter tracks the number of consensus operations executed. As the algorithm enters its continuous loop, it undertakes a consensus operation and subsequently increments the \(N_{\textit{consensus}}\) counter. If either the number of nodes (\(N_{\textit{node}}\)) has changed or the \(N_{\textit{consensus}}\) exceeds the predetermined \(TH_{\textit{consensus}}\) threshold, the algorithm calls the \(Get\_Best\_GHI()\) function. This function's role is to procute the network's best Grouping and Hierarchical Information (GHI). After obtaining the GHI, the counter \(N_{\textit{consensus}}\) is reset to zero. Then, it propagates the obtained GHI to other nodes within the network. This looped process ensures that the CPN constantly monitors and updates its hierarchical structure based on the frequency of consensus operations and any changes in participating nodes.