# A Hierarchical Blockchain-Based Trust Measurement Method for Drone Cluster Nodes
## 2 Trust Metric Model of Unmanned Aerial Vehicle Cluster Nodes Based on Hierarchical Blockchain
### Blockchain Data Sharing Mechanism under Resource Constraints
#### 2.3.2. Election of the Consensus Leader Node  
During PBFT consensus within each cluster, it is necessary to select a leader node to guide the overall consensus process. To ensure fairness in block generation among nodes  
Figure 4. The block structure. Figure 3. Consensus Framework. and reduce the threat of malicious nodes, while selecting nodes with higher computational power as leader nodes, this section designs an election mechanism for the consensus leader node. The algorithm is deployed on the cluster head node, and the cluster head node selects the leader node of each blockchain consensus according to the algorithm. Based on the node's own computational power and block generation behavior, the behavior factor \(RF_{i}\) and computational power factor \(FF_{i}\) are proposed to optimize the election mechanism for the leader node in the PBFT consensus of drone clusters. A score reset strategy is also employed for nodes with excessively high or low scores to enhance the decentralization characteristics of consensus. Behavior factor: \(RF_{i}\in[0,1]\), the initial value is uniformly set to \(r\). Let \(RF_{i}(t)\) denote the reputation value of node \(i\) in the \(t\) round of consensus. The calculation formula for the reputation value \(RF_{i}(t+1)\) of node \(i\) in the \(t+1\) round of consensus can be expressed as  
\[RF_{i}(t+1)=\left\{ \begin{array}{cl}RF_{i}(t)+\alpha(1-RF_{i}(t)),&normal\\ \beta RF_{i}(t),&abnormal\\ RF_{i}(t)e^{-\lambda\Delta b},&offline\\ 0,&byzantine\end{array} \right.. \tag{7}\]  
Normal behavior includes block-producing nodes packaging valid blocks, the leader node leading all network nodes to reach consensus, and the slave nodes participating in consensus and eventually synchronizing their results with the majority of nodes. Abnormal behavior includes block-producing nodes packaging invalid blocks, the master node failing to produce blocks, and slave nodes synchronizing with results that differ from the majority of nodes. Offline nodes refer to nodes that do not participate in consensus, and their reputation gradually decreases over time. Byzantine nodes refer to nodes that send inconsistent messages to different nodes. Among them, the coefficient \(\alpha\in(0,1)\) is used to control the growth rate of reputation, and \(\beta\in(0,1)\) is the punishment coefficient used to control the decline rate of reputation. \(\lambda\) is the decay factor, and \(\Delta b\) is the difference between the block height at which the node last participated in consensus and the current block height. The node with the highest reputation is elected as the leader node, and nodes with a reputation lower than the threshold \(b\) are prohibited from participating in consensus. When the reputation value of a node is higher than the threshold \(r\), it is reset to \(r\) at the beginning of the next cycle to prevent the centralization tendency caused by excessively high reputation values. When the reputation value of a node is lower than \(b\) and it is prohibited from participating in consensus, its reputation value is restored to \(b\) in the next cycle. The computation factor can be expressed as Equation (8), where \(FF_{i}\in[0,1]\). Considering that some verification tasks in the consensus cannot be offloaded and need to be performed locally, and the leader node itself needs to perform more verification tasks than ordinary nodes, the higher the computational power of the leader node, the shorter the consensus delay. We utilize the computational power of all nodes to calculate the computational power factor for each node. \[FF_{i}=\frac{f_{i}}{\max_{j\in U_{n},n\in M}f_{j}} \tag{8}\]  
In conclusion, the scoring of UAV nodes in the election of consensus leader nodes can be expressed as  
\[R_{i}=\Xi_{1}RF_{i}+\Xi_{2}FF_{i}, \tag{9}\]  
where \(\Xi_{1}\) and \(\Xi_{2}\) are corresponding weights and \(\Xi_{1}+\Xi_{2}=1\). The cluster head node evaluates the nodes based on their historical behavior and the situation of unmanned aerial vehicles within the cluster after each block is generated.