DPoS in pseudo-code

作者: 杨小伟的世界 | 来源:发表于2018-06-05 11:29 被阅读0次

DPoS in general has two parts

  • Witness election process
  • Block producing process

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

相关文章

网友评论

    本文标题:DPoS in pseudo-code

    本文链接:https://www.haomeiwen.com/subject/yldpsftx.html