这是我的结构:
#[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>,
}我的仓库:
#[pallet::storage]
#[pallet::getter(fn sortition_sum_trees)]
pub type SortitionSumTrees<T> = StorageMap<_, Blake2_128Concat, Vec<u8>, SortitionSumTree<T>>;但它的错误是:
属性parity_scale_codec::Encode不是为std::collections::BTreeMap<u128, T>实现的
发布于 2021-12-13 20:51:22
你需要用这个:
#[pallet::getter(fn sortition_sum_trees)]
pub type SortitionSumTrees<T> = StorageMap<
_,
Blake2_128Concat,
Vec<u8>,
SortitionSumTree<T::AccountId>
>;确保在T::AccountId中使用SortitionSumTree<T::AccountId>。
https://stackoverflow.com/questions/70195660
复制相似问题