# A Compute and Wait in PoW (CW-PoW) Consensus Algorithm for Preserving Energy Consumption
## 6 Implementation
We explain that \(p1\) is the last process to find the solution, it wakes up the others, and then starts directly the next round without making any wait. Even though \(p1\) didn't wait, its computing time is less than the one of \(p8\). We explain this by two possibilities. The first is given when \(p8\) started, the second possibility when \(p1\) quickly found the solution in the last round (there is no wait after the last round) and \(p8\) took a long time in the last round. In general, the average gain of the network is 15.63%. Compute and wait implementation: In the original PoW, each process will continue the calculation for 10 min (until one of the processes finds the hash). In the proposed protocol there are two types of processes, winning processes, which are processes that participate in all rounds (noting that the final winner is the process that has the minimum standard deviation of his solutions). The other type are those processes that leave the  
Figure 3: The influence of NbrP for fixed NbrR. competition after such rounds (for example, when the number of solutions of the next round is equal to NbrS). In these two types, no process does the calculation during 10 min, there is a proof-wait (first type) or a proof-abandon (second type). So, there are two main factors that must be handled, the number of rounds \(NbrR\) and the number of solutions to be found in each round \(NbrS\). If \(NbrR>1\) then \(Gain>0\)  
Proof. : Based on the randomness of the hash function (Block + Nonce) \(<\) Target and on the arbitrary speed of each process, we have:  
\[C_{i,x}\
eq C_{j,x},\ \forall i,j\in\left\{1,...,NbrP\right\},\ \forall x\in \left\{1,...,NbrR\right\} \tag{7}\]  
where \(NbrP\) is the number of processes and \(0<x<NbrR\). According to Equation (7), \(|C_{i,x}-C_{j,x}|>0\), so either \(W_{i,x}>0\) or \(W_{j,x}>0\), which implies that \(W_{i,x}/\left(W_{i,x}+C_{i,x}\right)>0\) or \(W_{i,x}/\left(W_{j,x}+C_{j,x}\right)>0\). We obtain \(Gain>0\). If \(NbrP\) increases then \(Gain\) increases when \(NbrP=NbrS\)  
Proof. : We let the probability of finding the solution by 5 (respectively, 10) processes be \(P_{5}\) (respectively, \(P_{10}\)), we have \(P_{10}>P_{5}\). Let \(T_{p}\) be the compute time to find the solution with a probability \(p\). So, \(T_{p_{10}}<T_{ps}\) implies that the wait time \(W_{p_{10}}>W_{ps}\). According to Equation (4), \(gain_{10 processes}>gain_{processes}\). Discussion: In the first scenario shown by Figure 3, we fixed NbrR to 5, and we made several tests, during which we increased the number of processes (NbrP = 5, 10, 15, 20) to study the effect of this increase and its influence on the gain. These tests have shown that the more many processes do compute and wait, the more the gain increases. We explain this by the following example: in the round \(x\), if first process \(p_{i}\) finds a solution after 4 min, we suppose that \(p_{i}\) will wait \(t_{1}=1\) minute to start the next round \(x+1\), so the gain is \(1/(1+4)=20\%\). With \(NbrP=10\), the first process \(p_{i}\) will find a solution in 3 min, \(p_{j}\) will wait for \(t2>t1\) (\(t2=2\) min), so the gain is 2 / (2 + 4) = 30%. In the second curve (curve on the right in Figure 3), where the NbrS is constant, we observe that the gain decreases, because the number of processes (which are waiting) decreases compared to the total number of processes. On the other hand, the number of processes that do not wait is increasing, which implies a decrease in the average gain in the network. While \(NbrR<upper\) bound, if \(NbrR\) increases then \(Gain\) increases. Proof. : Let \(w\) be the wait time, \(c\) the compute time, and \(e\) the execution time, so \(e=w+c\). The gain \(g=\frac{w}{e}\), and if a process does little computation and a lot of wait, then it will have a high gain rate. We know that there is no wait time in the last round, therefore, if \(NbrR=2\), then \(g=\frac{w}{e_{1}+e_{2}}\) where w is the wait time of round 1, \(e_{1}\) the compute time of round 1, and \(e_{2}\) the compute time of round 2.