Skip to main content
. 2021 Apr 16;7:e431. doi: 10.7717/peerj-cs.431

Algorithm 4. The default PoS mining algorithm in FoBSim.

Result: Confirmed new block β
initialization miners μ[0,1,…n], miners.wallets, stake random no. of coins from each miner.;
The Network:;
while mempool.qsize() > 0 do
  Randomly choose a predefined no. of miners;
  Choose the miner with the highest Stake value;
  Inform all miners of the ID of the next block generator μg;
end
The Miner:;
if a new ID μg is received from the Network then
  if MyAddress == μg then
    Collect TXs from memPool;
    if BC_function is Payment then
      validate collected TXs
    else
      if BC_function is Computational Services then
        eval(TXs);
        add the evaluation results to TXs
      end
    end
    Accumulate TXs in a new BC block β;
    Broadcast β;
  else
    wait for a new block from μg;
    if b is received then
      if μg == β.generator then
        if BC function is Payment then
          validate and confirm TXs in β
        end
        add block β to the local chain;
        broadcast β to neighbors;
        report a successful block addition [β, μg]
      end
    end
  end
end