【发布时间】:2021-12-12 17:26:37
【问题描述】:
我正在尝试修改基于我正在尝试开发的 Substrate 的区块链的块结构。特别是我想在标题中添加一个向量,在块的主体中添加另一个向量。有人知道如何做到这一点吗?
我是 Substrate 的新手 :'(
提前感谢所有愿意做出贡献的人!
【问题讨论】:
标签: blockchain substrate
我正在尝试修改基于我正在尝试开发的 Substrate 的区块链的块结构。特别是我想在标题中添加一个向量,在块的主体中添加另一个向量。有人知道如何做到这一点吗?
我是 Substrate 的新手 :'(
提前感谢所有愿意做出贡献的人!
【问题讨论】:
标签: blockchain substrate
Substrate 中的 block 和 header 类型是通用的。
header需要实现https://docs.rs/sp-runtime/latest/sp_runtime/traits/trait.Header.html,block需要实现https://docs.rs/sp-runtime/latest/sp_runtime/traits/trait.Block.html。
Substrate 本身已经为 https://docs.rs/sp-runtime/latest/sp_runtime/generic/struct.Block.html 和 https://docs.rs/sp-runtime/latest/sp_runtime/generic/struct.Header.html 提供了两种类型。
当您设置区块链时,您主要通过运行时进行设置,您可以选择这些类型。
【讨论】:
如果您为每个块添加了一些数据,那么它被称为固有外部 (https://docs.substrate.io/v3/concepts/extrinsics/#inherents),并且不会产生相关费用。
Header 是在您的运行时定义的类型,因此您可以更改它以包含您想要的任何其他数据。搜索这个定义:
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
【讨论】: