use*_*713 3 substrate polkadot
这是我的结构:
#[derive(PartialEq, Eq, PartialOrd, Ord, Default, Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug))]
pub struct SortitionSumTree<AccountId> {
pub k: u128,
pub stack: Vec<u128>,
pub nodes: Vec<u128>,
pub ids_to_tree_indexes: BTreeMap<AccountId, u128>,
pub node_indexes_to_ids: BTreeMap<u128, AccountId>,
}
Run Code Online (Sandbox Code Playgroud)
我的存储:
#[pallet::storage]
#[pallet::getter(fn sortition_sum_trees)]
pub type SortitionSumTrees<T> = StorageMap<_, Blake2_128Concat, Vec<u8>, SortitionSumTree<T>>;
Run Code Online (Sandbox Code Playgroud)
但它给出了错误:
该特征parity_scale_codec::Encode未实现std::collections::BTreeMap<u128, T>
小智 7
你需要使用这个:
#[pallet::getter(fn sortition_sum_trees)]
pub type SortitionSumTrees<T> = StorageMap<
_,
Blake2_128Concat,
Vec<u8>,
SortitionSumTree<T::AccountId>
>;
Run Code Online (Sandbox Code Playgroud)
确保在 中使用T::AccountIdSortitionSumTree<T::AccountId>。
| 归档时间: |
|
| 查看次数: |
263 次 |
| 最近记录: |