Companion for refactor election score #10834 (#4927)

* Companion for refactor election score #10834

https://github.com/paritytech/substrate/pull/10834

* update lockfile for {"substrate"}

Co-authored-by: parity-processbot <>
This commit is contained in:
Niklas Adolfsson
2022-02-16 13:57:31 +01:00
committed by GitHub
parent c40c4bcbe9
commit 7273c4b03f
2 changed files with 170 additions and 163 deletions
+162 -162
View File
File diff suppressed because it is too large Load Diff
+8 -1
View File
@@ -22,6 +22,7 @@ use crate::{
use codec::Encode;
use frame_support::traits::Currency;
use jsonrpsee::rpc_params;
use sp_npos_elections::ElectionScore;
/// Forcefully create the snapshot. This can be used to compute the election at anytime.
fn force_create_snapshot<T: EPM::Config>(ext: &mut Ext) -> Result<(), Error<T>> {
@@ -63,10 +64,16 @@ async fn print_info<T: EPM::Config>(
let snapshot_size =
<EPM::Pallet<T>>::snapshot_metadata().expect("snapshot must exist by now; qed.");
let deposit = EPM::Pallet::<T>::deposit_for(raw_solution, snapshot_size);
let score = {
let ElectionScore { minimal_stake, sum_stake, sum_stake_squared } = raw_solution.score;
[Token::from(minimal_stake), Token::from(sum_stake), Token::from(sum_stake_squared)]
};
log::info!(
target: LOG_TARGET,
"solution score {:?} / deposit {:?} / length {:?}",
&raw_solution.score.iter().map(|x| Token::from(*x)).collect::<Vec<_>>(),
score,
Token::from(deposit),
raw_solution.encode().len(),
);