## 3 Improved RE-BPFT Blockchain Consensus Algorithm
### Node Classification

Table 3: Node Credit Evaluation—Secondary and Tertiary Indicators. Within the enhanced RE-PBFT consensus approach, this paper integrates a decision tree-based classification algorithm. After every consensus round, nodes are categorized into \"excellent\", \"good\", \"average\", or \"malicious\" classes according to their comprehensive credit values. Initially, the consortium blockchain aggregates and organizes node attribute information. Subsequently, a primary node election is conducted via a view-change mechanism, concurrently validating nodes throughout this process. Finally, nodes exhibiting problematic behaviors are identified and removed. Excluded Byzantine nodes lose their eligibility to participate in subsequent consensus rounds, and their readmission requires explicit approval from consortium blockchain administrators. To further improve node classification discrimination and reinforce security control in dynamic consortium blockchain environments, this research systematically refines the information entropy and information gain calculations inherent in the traditional ID3 algorithm. The detailed implementation process is presented in Algorithm 1. ```
Input : Node set \(D=\{d1\,d2\,\ldots,dn\ \}\), Information gain threshold \(T_{ig}\), Initial reputation value \(C_{init}\) Output: Classified node sets: Excellent node set \(D_{excellent}\), Good node set \(D_{good}\), Normal node set \(D_{ordinary}\), Malicious node set \(D_{Malicious}\)
1. Initialize node attribute sets: Reputation score \(Credit_{i}\), Continuous consensus count \(Consecutive_{i}\), Downtime countDowntime \(Downtime_{i}\), Communication error count \(Error_{i}\), Node activity level \(Activity_{i}\)
2. Create decision tree training dataset \(Dataset\leftarrow\varnothing\)
3. for each node \(d_{i}\in D\)do
4. Calculate node \(d_{i}\)'s reputation score \(Credit_{i}\), continuous consensus count \(Consecutive_{i}\), downtime count \(Downtime_{i}\), communication error count \(Error_{i}\), activity level \(Activity_{i}\)
5. Extract node features and add to \(Dataset\)
6. endfor
7. Calculate information entropy \(IE(S)\) of each attribute based on dataset \(Dataset\)
8. Calculate information gain \(IG(S,T)\) of each attribute according to formula
9. if maximum information gain \(IG_{max}\geq T_{ig}\)then
10. Partition dataset using attribute with maximum information gain to construct decision tree
11. Predict the category of each node based on the decision tree model
12. if the node category is 'Excellent' then
13. add the node to \(D_{excellent}\)
14. else if the node category is 'Good' then
15. add the node to \(D_{good}\)
16. else if the node category is 'Average' then
17. add the node to \(D_{ordinary}\)
18. else
19. add the node to \(D_{Malicious}\)
20. endif
21. else
22. Output warning: \"Unable to effectively classify, insufficient information gain\"
23. endif
24. Return the classified node set \((D_{excellent}\,D_{good}\,D_{ordinary}\,D_{Malicious}\ )\)
```  
**Algorithm 1**ID3 Decision Tree-Based Consortium Blockchain Node Classification Algorithm  
The decision tree construction process begins by calculating the information entropy, which measures the uniformity of sample categorization within a dataset. Suppose the probabilities that samples in the current training set belong to the categories of excellent, good, ordinary, and malicious nodes are denoted as P1, P2, P3, and P4, respectively; the entropy of category information derived from the training dataset is expressed as shown in Formula (12). \[IE(S)=-\sum_{i=1}^{n}\left(w_{i}\times P_{i}+\epsilon\right)\log_{2}(w_{i}\times P _{i}+\epsilon) \tag{12}\]  
Here, \(n\) represents the number of categories, \(w_{i}\) denotes the importance weight of the i-th category node in the system, and \(\sum w_{i}\ =1\). \(\epsilon\) is a smoothing factor to prevent \(\log 0\), typically set to \(\epsilon=10^{-6}\).