# A Blockchain Solution for the Internet of Vehicles with Better Filtering and Adaptive Capabilities
## 4 Gradually Accelerating Environment Adaptive Consensus Algorithm
### Node Trust Management Model Based on Gradual Acceleration Mechanism
#### 4.1.2 Trust Management Model Based on Gradual Acceleration Mechanism
5: Complete the consensus process to the reply stage
6: Start update
7:if result ==  accepted_response then
8:\(\mathcal{W}_{h}[\mathcal{N}_{Node\_id}][0]\) += 1
9:if\(\mathcal{W}_{h}[\mathcal{N}_{Node\_id}][1]<0\)then
10:\(\mathcal{W}_{h}[\mathcal{N}_{Node\_id}][1]\) = 0
11:\(\mathcal{W}_{t}[\mathcal{N}_{Node\_id}][1]\) = 1
12: If there is a continuous bonus behavior, the reward weight coefficient \(\mathcal{W}_{t}[\mathcal{N}_{Node\_id}][0]\) will continue to increase
13:\(\widetilde{a}\leftarrow\mathcal{W}_{t}[\mathcal{N}_{Node\_id}][0]\)
14:if Scores[\(\mathcal{N}_{Node\_id}]<90\)then
15:\(\widetilde{a}\gets 4\)
16: Scores[\(\mathcal{N}_{Node\_id}]\) += \(\widetilde{a}\) *1
17:else
18:\(\mathcal{W}_{h}[\mathcal{N}_{Node\_id}][1]\) = 1
19:if\(\mathcal{W}_{h}[\mathcal{N}_{Node\_id}][0]>0\)then
20:\(\mathcal{W}_{h}[\mathcal{N}_{Node\_id}][0]\) = 0
21:\(\mathcal{W}_{t}[\mathcal{N}_{Node\_id}][0]\) = 1;
22: If there is a continuous deduction behavior, the penalty weight coefficient \(\mathcal{W}_{t}[\mathcal{N}_{Node\_id}][1]\) will continue to increase
23:\(\widetilde{b}\leftarrow\mathcal{W}_{t}[\mathcal{N}_{Node\_id}][1]\)
24: Scores[\(\mathcal{N}_{Node\_id}]\) = \(\widetilde{b}\) *1
25: Update completed
```  
**Algorithm 1** Trust Management Model Based on Gradual Acceleration Mechanism  
.1.3 Recording Historical Continuous Behavior by Simulating the Mutual Exclusion Semaphore Mechanism  
To avoid multiple threads simultaneously occupying the same system resources and causing interlocking in the operating system, a recording semaphore mechanism is proposed, as shown in Figure 5. By setting a mutual exclusion semaphore and performing PV \begin{table}
\begin{tabular}{c c c} \hline \hline
**Consecutive Bonus Behaviors \(\xi_{1}\)** & **Reward Weight Coefficient \(\alpha\)** & **Penalty Weight Coefficient \(\beta\)** \\ \hline
[0,3) & 1 & No adjustments \\
[3,4) & 2 & No adjustments \\
[4,5) & 3 & No adjustments \\
[5,) & 4 & No adjustments \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Gradient acceleration mechanism for continuous bonus behavior. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Consecutive Deduction Behaviors \(\xi_{2}\)** & **Reward Weight Coefficient \(\alpha\)** & **Penalty Weight Coefficient \(\beta\)** \\ \hline \((-3,0]\) & No adjustments & 1 \\ \((-4,-3]\) & No adjustments & 2 \\ \((-5,-4]\) & No adjustments & 3 \\ \((-5]\) & No adjustments & 4 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Gradient acceleration mechanism for continuous score reduction behavior. operations before and after a thread enters the critical section, the plannable use of limited system resources by the thread is achieved. We designed a simulated mutual exclusion semaphore mechanism, as illustrated in Figure 6, to track the historical continuous changes in node credit scores. When one of the count value parameters in a node's history (\(\mathcal{W}_{h}\)) accumulates to a non-zero value and another count value suddenly changes, it indicates that the node's historical behavior has been interrupted. At this point, following the mutual exclusion mechanism, we reset the accumulated value to zero, and all parameters begin counting anew. For instance, when a node is verified as correct and its credit score needs to be increased, \(\xi_{1}\) is typically incremented by 1, \(\xi_{2}\) is immediately reset to 0, and \(\beta\) is initialized to 1. This indicates that the previous continuous deduction behavior has been interrupted, prompting all parameters to start counting again. The advantage of this approach is that it ensures data consistency and mitigates potential errors that may arise from complex concurrent parameter updates.