Substrate中Collective模块

2019-11-25  本文已影响0人  建怀

Substrate中Collective模块

Substrate中议会的功能模块,议员们需要通过发起提案来推动共识达成。议会成员两种方式,一种是直接Root权限的调用set_members,或者间接的,通过民主选举的方法ChangeMembers

发起的提案需要被投票,投票其实很简单,其记录结构如下:

/// Info for keeping track of a motion being voted on.
pub struct Votes<AccountId> {
    /// The proposal's unique index.
    index: ProposalIndex,
    /// The number of approval votes that are needed to pass the motion.
    threshold: MemberCount,
    /// The current set of voters that approved it.
    ayes: Vec<AccountId>,
    /// The current set of voters that rejected it.
    nays: Vec<AccountId>,
}

存储那些数据呢,其实也很简单:

可以在链初始化的时候,放几个议会成员。

add_extra_genesis {
    config(phantom): rstd::marker::PhantomData<I>;
    config(members): Vec<T::AccountId>;
    build(|config| Module::<T, I>::initialize_members(&config.members))
}

监听链上事件:

然后是定义的几个方法了:

上一篇下一篇

猜你喜欢

热点阅读