EOS 源代码解读 区块数据结构
Posted thefist11
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了EOS 源代码解读 区块数据结构相关的知识,希望对你有一定的参考价值。
1.chain/types.hpp
using block_id_type = fc::sha256;
using checksum_type = fc::sha256;
using checksum256_type = fc::sha256;
using checksum512_type = fc::sha512;
using checksum160_type = fc::ripemd160;
using transaction_id_type = checksum_type;
using digest_type = checksum_type;
using weight_type = uint16_t;
using block_num_type = uint32_t;
using share_type = int64_t;
using int128_t = __int128;
using uint128_t = unsigned __int128;
using bytes = vector<char>;
using digests_t = deque<digest_type>;
2. block_header
struct block_header
{
block_timestamp_type timestamp;//区块时间戳
account_name producer;//帐户标识符 13字节
uint16_t confirmed = 1;
block_id_type previous;//前一块的HASH
checksum256_type transaction_mroot; /// mroot of cycles_summary
checksum256_type action_mroot; /// mroot of all delivered action receipts
uint32_t schedule_version = 0;//见证人排序版本号
optional<producer_schedule_type> new_producers;//新生产者(可以为空)
extensions_type header_extensions;
digest_type digest()const;//摘要哈希
block_id_type id() const; //自己的哈希
uint32_t block_num() const { return num_from_id(previous) + 1; }
static uint32_t num_from_id(const block_id_type& id);//ID是任意数字,区块号是从零长到现在的排序号 ID=HASH+n
};
struct signed_block_header : public block_header
{
signature_type producer_signature;//生产者签名
};
3. block.hpp
using signed_block_ptr = std::shared_ptr<signed_block>;//重定义一个新的数据类型,方便使用
struct signed_block : public signed_block_header{
vector<transaction_receipt> transactions; /// new or generated transactions
extensions_type block_extensions;
flat_multimap<uint16_t, block_extension> validate_and_extract_extensions()const;
};
以上是关于EOS 源代码解读 区块数据结构的主要内容,如果未能解决你的问题,请参考以下文章