EOS块数据结构(一)主要的数据结构解析

1、区块头
struct block_header
{
      digest_type    digest() const;
      uint32_t         block_num() const {return num_from_id(previous)+1}
      static uint32_t num_from_id(const block_id_type & id);
      
      block_id_type  previous;                  //上一个块的HASH  (SHA  256)
      block_timestamp_type    timestamp; //本块生成的时间
      
      checksum256_type  transaction_mroot; //merkle根 ,用于快速验证交易的完整性
      checksum256_type  action_mroot; //merkle根 
      checksum256_type  block_mroot;  //merkle根 
      
      account_name    producer;  //出这个块的见证人的账户
      
      uint32_t           schedule_version =0; //见证人排序的编号, 见证人的商议制定的
      optional<producer_schedule_type> new_producers;   //下一个见证人的账户,可以为空。如果为空,还是producer出块,如果不为空,就是下一个见证人账户。
};

2、签名区块头
struct signed_block_header:public block_header
{
       block_id_type     id() const;
       public_key_type   signee() const;
       void     sign(const private_key_type& signer);
       bool     validate_signee(const public_key_type& expected_signee) const;
       signature_type     producer_signature;//见证人的签名,一旦签名,就表明对该块确认了。这样就可以分发给其他见证人。
};


3、签了名区块摘要(签了名的区块总结)
struct signed_block_summary : public  signed_block_header {
       vector<region_summary>   regions;    // // 分区(地区,概念比cycles大)
};

4、块结构(比特币是线性的再一块,但是EOS的块结构是分层的,分级的)
    Block 
           Region   // 分区(地区,概念比cycles大)
                Cycles(sequential)          //小循环     很多的片区组成了小循环(cycle)
                       Shards(parallel)      //片   交易为了并行所以分了片,交易是在块中分到不同的片区
                               Transaction(sequential)     //交易是用N个动作(action)组成 
                                      Actions(sequential)
                                             Receiver and Notified Accounts (parallel)


5、struct region_summary{
       uint16_t  region = 0;
       vector<cycle>  cycles_summary;
};

6、  typedef vector<shard_summary>  cycle;


7、  struct shard_summary{
        vector<shard_lock>       read_locks;
        vector<shard_lock>       write_locks;
        vector<transaction_receipt>  transactions;  
        bool empty() const{
               return read_locks.empty() && write_locks.empty() && transactions.empty();
        }
};
transaction_receipt具体的交易(但是不是交易内容)
交易的摘要,不是交易的具体内容。分成等级森严的各个组,这样做是为了以后大规模的并发执行做准备。


8、struct signed_block : public signed_block_summary{
       signed_block ()=default;
       signed_block(const signed_block&) =default;
       signed_block(const signed_block_summary & base):signed_block_summary(base),input_transactions(){}
       vector<packed_transaction>  input_transactions;  //交易的具体的内容,加载了区块的最后面。
}


如下图:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

akai9898

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值