首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >属性`parity_scale_codec::Encode`不是为`std::collections::BTreeMap<u128,T>`实现的

属性`parity_scale_codec::Encode`不是为`std::collections::BTreeMap<u128,T>`实现的
EN

Stack Overflow用户
提问于 2021-12-02 07:39:22
回答 1查看 96关注 0票数 1

这是我的结构:

代码语言:javascript
复制
#[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>,
}

我的仓库:

代码语言:javascript
复制
#[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>实现的

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-12-13 20:51:22

你需要用这个:

代码语言:javascript
复制
#[pallet::getter(fn sortition_sum_trees)]
pub type SortitionSumTrees<T> = StorageMap<
  _, 
  Blake2_128Concat,
  Vec<u8>,
  SortitionSumTree<T::AccountId>
>;

确保在T::AccountId中使用SortitionSumTree<T::AccountId>

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70195660

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档