我克隆了底物库。在bin/node-template/runtime/src/lib.rs
中,调用construct_runtime!
来创建运行时。我在frame/support/procedural/src/construct_runtime/mod.rs
中找到了construct_runtime
的定义。它调用construct_runtime_parsed
,后者在运行时构建一个代码块。
let res = quote!(
#scrate_decl
#[derive(Clone, Copy, PartialEq, Eq, #scrate::sp_runtime::RuntimeDebug)]
pub struct #name;
impl #scrate::sp_runtime::traits::GetNodeBlockType for #name {
type NodeBlock = #node_block;
}
impl #scrate::sp_runtime::traits::GetRuntimeBlockType for #name {
type RuntimeBlock = #block;
}
#outer_event
#outer_origin
#all_modules
#module_to_index
#dispatch
#metadata
#outer_config
#inherent
#validate_unsigned
#integrity_test
);
有什么方法可以打印或检查传递给construct_runtime_parsed
构建的quote!
的代码吗?
您可以将cargo expand
指向runtime/src/lib.rs
文件,它将输出扩展的源代码。