区块链学习笔记

DPoS in pseudo-code

2018-06-05  本文已影响0人  杨小伟的世界

DPoS in general has two parts

Witness election process

Unknown

Block producing process

If I am the producer

on_block_generating(block) {
  broadcast(block);
  add_block(block);
  clear_canditates();
}

If I am the witness

on_block_message(block) {
  if (!valid_block(block)) {
    return;
  }

  if (!contain_irreversible_block(block)) {
    return;
  }

  if (is_longest(block)) {
    add_block(block);
    clear_candidates();
    cal_irreversible_block();
    return;
  }

  if (same_length(block)) {
    add_candidate(block);
  }
}

Reference

EOS: Explanation of New BFT+DPoS w/ Daniel Larimer - Part 1 of 2

EOS: Explanation of New BFT+DPoS w/ Daniel Larimer - Part 2 of 2

上一篇 下一篇

猜你喜欢

热点阅读