lpbottle avatar

EOS 区块数据结构

lpbottle

Published: 11 May 2018 › Updated: 11 May 2018EOS 区块数据结构

EOS 区块数据结构

对于一个区块链项目来说,最核心的数据莫过于区块数据,区块数据结构是整个区块链项目的技术基础。不过由于 EOS 项目一直在快速迭代,区块数据结构也不断更新,所以今天才向大家介绍。

区块头(block_header)

首先是区块头数据结构,包括了哈希、时间戳、默克尔根、见证人账户等。

//区块头结构体

structblock_header

{

//前一区块哈希

block_id_type previous;

//区块时间戳

block_timestamp_type timestam

交易的默克尔根

checksum256_type transaction_mroot;/// mroot of cycles_summary

//Action 的默克尔根

checksum256_type action_mroot;

//区块默克尔根

checksum256_type block_mroot;

//见证人账号

account_name producer;

//见证人排序版本号

uint32_t schedule_version =0;

//下一个见证人(可以为空)

optional new_producers;

};

区块头(已签名)(signed_block_header)

在区块头的基础上,出块见证人进行签名,就是签名区块头:

//签名区块头结构体

structsigned_block_header :public block_header

{

见证人签名

signature_type producer_signature;

};

区块摘要(已签名)(signed_block_summary)

签名区块摘要的目的是将区块中的交易(Transactions)分配到各个层级中,这里并没有交易的完整信息,只展示了交易的层级和分组结构。

structsigned_block_summary :public signed_block_header {

vector regions;

};

EOS 白皮书里说明了区块摘要的结构:

Region

Cycles (sequential)(串行)

Shards (parallel)(并行)

Transactions (sequential)(串行)

可以看到,多个 Transactions 组成了一个 Shards(片区),多个 Shards 组成了一个 Cycles(周期),多个周期组成一个 Region(区域)。每个区块所包含的交易就被这样的层级结构组织起来,并将最终的组织结构单独记录在区块中。这也是 EOS 以后开发并行执行的基础。

区块(已签名)(signed_block)

前面提到区块摘要只说明了交易的组织结构,并没有具体的交易信息,我们要在区块最后添加完整的交易信息,就形成了一个 EOS 完整区块。

structsigned_block :public signed_block_summary {

//完整交易信息

vector input_transactions;

};

总结

我们用图形绘出了 EOS 区块数据结构,便于大家理解。

10800206-f7e5417f0893903d.png

Leave EOS 区块数据结构 to:

Written by

Read more #eos posts


Best Posts From lpbottle

We have not curated any of lpbottle's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From lpbottle