Skip to main content
. 2023 May 17;25(5):811. doi: 10.3390/e25050811
Algorithm 1. The leader node selection algorithm
  1. Input: L, V, l, tN //L is an array to store LV, each element stores an ID of a validating node; V denotes the number of elements in LV; l denotes the number of validating nodes that have already acted as the leader node in a consensus round; tN denotes the timestamp of the latest block BN.

  2. Output: L; L[i]

  3. int i,j;

  4. i = V-l;

  5. {

  6.   C[i] = QRNG(ID(V-l),tN); // ID(V-l) denotes identity of the current leader node

  7.   j = C[i]%(i+1);

  8.     tmp = L[i];    // L[i] stores ID of the i-th validating node in LV

  9.   L[i] = L[j];

  10.   L[j] = tmp;

  11. }

  12. if(l < V)

  13.   l = l + 1;

  14. else

  15.   l = 0;

  16. return L[i]; //The element in ith position in L, that is, L[i] stores the identity IDL[i]will be elected as the leader node in the forthcoming (K+1)th consensus