繁体   English   中英

Substrate Blockchain - 改变区块结构

[英]Substrate Blockchain - Change block structure

我正在尝试基于我正在尝试开发的 Substrate 修改区块链的块结构。 特别是我想在 header 中添加一个向量,在块体中添加另一个向量。 有人知道怎么可能吗?

我是 Substrate 的新手:'(

在此先感谢所有愿意做出贡献的人!

Substrate 中的 block 和 header 类型是通用的。

The header needs to implement https://docs.rs/sp-runtime/latest/sp_runtime/traits/trait.Header.html and the block needs to implement https://docs.rs/sp-runtime/latest/sp_runtime/特征/特征.Block.html

Substrate itself provides two types for that already https://docs.rs/sp-runtime/latest/sp_runtime/generic/struct.Block.html and 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>;

在此处查看上下文: https://github.com/substrate-developer-hub/substrate-node-template/blob/ad7ce8e3dabb2d1f8f4b4094db5b0e754760e9be/runtime/src/lib.rs#L75

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM