Add weight annotations to Timestamp, Sudo, Democracy, Treasury, et al. (#2694)

* Add some initial weighting notes

* Add Democracy and Sudo

* Add flags, fix formatting

* Add comments on finality-tracker

* Add a few mode modules.

* Update srml/democracy/src/lib.rs

Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* Update srml/democracy/src/lib.rs

Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* Update srml/system/src/lib.rs

Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* Update srml/system/src/lib.rs

Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* Update srml/system/src/lib.rs

Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* Update srml/system/src/lib.rs

Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* Update srml/treasury/src/lib.rs

Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* Update and merge changes

* Update srml/system/src/lib.rs

Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* Remove unneeded comment

* Remove comment line

* Fix comment

* Fix formatting overall

* Apply suggestions from code review

Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* Apply suggestions from code review

Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* Clean up and polish

* Update srml/indices/src/lib.rs

* Update srml/staking/src/lib.rs

Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* Final nits.
This commit is contained in:
lsaether
2019-06-12 09:03:23 +02:00
committed by Bastian Köcher
parent 6feab51069
commit f0f32f9250
11 changed files with 239 additions and 15 deletions
+40
View File
@@ -321,6 +321,11 @@ decl_module! {
fn deposit_event<T>() = default;
/// Propose a sensitive action to be taken.
///
/// # <weight>
/// - O(1).
/// - Two DB changes, one DB entry.
/// # </weight>
fn propose(origin,
proposal: Box<T::Proposal>,
#[compact] value: BalanceOf<T>
@@ -343,6 +348,11 @@ decl_module! {
}
/// Propose a sensitive action to be taken.
///
/// # <weight>
/// - O(1).
/// - One DB entry.
/// # </weight>
fn second(origin, #[compact] proposal: PropIndex) {
let who = ensure_signed(origin)?;
let mut deposit = Self::deposit_of(proposal)
@@ -355,6 +365,11 @@ decl_module! {
/// Vote in a referendum. If `vote.is_aye()`, the vote is to enact the proposal;
/// otherwise it is a vote to keep the status quo.
///
/// # <weight>
/// - O(1).
/// - One DB change, one DB entry.
/// # </weight>
fn vote(origin,
#[compact] ref_index: ReferendumIndex,
vote: Vote
@@ -365,6 +380,11 @@ decl_module! {
/// Vote in a referendum on behalf of a stash. If `vote.is_aye()`, the vote is to enact
/// the proposal; otherwise it is a vote to keep the status quo.
///
/// # <weight>
/// - O(1).
/// - One DB change, one DB entry.
/// # </weight>
fn proxy_vote(origin,
#[compact] ref_index: ReferendumIndex,
vote: Vote
@@ -492,6 +512,10 @@ decl_module! {
}
/// Specify a proxy. Called by the stash.
///
/// # <weight>
/// - One extra DB entry.
/// # </weight>
fn set_proxy(origin, proxy: T::AccountId) {
let who = ensure_signed(origin)?;
ensure!(!<Proxy<T>>::exists(&proxy), "already a proxy");
@@ -499,12 +523,20 @@ decl_module! {
}
/// Clear the proxy. Called by the proxy.
///
/// # <weight>
/// - One DB clear.
/// # </weight>
fn resign_proxy(origin) {
let who = ensure_signed(origin)?;
<Proxy<T>>::remove(who);
}
/// Clear the proxy. Called by the stash.
///
/// # <weight>
/// - One DB clear.
/// # </weight>
fn remove_proxy(origin, proxy: T::AccountId) {
let who = ensure_signed(origin)?;
ensure!(&Self::proxy(&proxy).ok_or("not a proxy")? == &who, "wrong proxy");
@@ -512,6 +544,10 @@ decl_module! {
}
/// Delegate vote.
///
/// # <weight>
/// - One extra DB entry.
/// # </weight>
pub fn delegate(origin, to: T::AccountId, conviction: Conviction) {
let who = ensure_signed(origin)?;
<Delegations<T>>::insert(who.clone(), (to.clone(), conviction));
@@ -527,6 +563,10 @@ decl_module! {
}
/// Undelegate vote.
///
/// # <weight>
/// - O(1).
/// # </weight>
fn undelegate(origin) {
let who = ensure_signed(origin)?;
ensure!(<Delegations<T>>::exists(&who), "not delegated");