Skip to content

Commit

Permalink
refactor: restructure dao pallet threefoldtech#735
Browse files Browse the repository at this point in the history
  • Loading branch information
sameh-farouk committed Jun 20, 2023
1 parent 14703da commit 512a6f8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
18 changes: 9 additions & 9 deletions substrate-node/pallets/pallet-dao/src/dao.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl<T: Config> Pallet<T> {
result: result.map(|_| ()).map_err(|e| e.error),
});
// default to the dispatch info weight for safety
let proposal_weight = get_result_weight(result).unwrap_or(dispatch_weight); // P1
let proposal_weight = Self::get_result_weight(result).unwrap_or(dispatch_weight); // P1

Self::remove_proposal(proposal_hash);
proposal_weight
Expand Down Expand Up @@ -313,15 +313,15 @@ impl<T: Config> Pallet<T> {

Ok(().into())
}
}

/// Return the weight of a dispatch call result as an `Option`.
///
/// Will return the weight regardless of what the state of the result is.
fn get_result_weight(result: DispatchResultWithPostInfo) -> Option<Weight> {
match result {
Ok(post_info) => post_info.actual_weight,
Err(err) => err.post_info.actual_weight,
/// Return the weight of a dispatch call result as an `Option`.
///
/// Will return the weight regardless of what the state of the result is.
fn get_result_weight(result: DispatchResultWithPostInfo) -> Option<Weight> {
match result {
Ok(post_info) => post_info.actual_weight,
Err(err) => err.post_info.actual_weight,
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion substrate-node/pallets/pallet-dao/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use frame_support::{
dispatch::{
DispatchResult, DispatchResultWithPostInfo, Dispatchable, GetDispatchInfo, PostDispatchInfo,
},
traits::{EnsureOrigin, Get}};
traits::{EnsureOrigin, Get},
};
use tfchain_support::traits::{ChangeNode, Tfgrid};

pub use pallet::*;
Expand Down

0 comments on commit 512a6f8

Please sign in to comment.