Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Companion for refactor election score #10834 #4927

Merged
merged 3 commits into from
Feb 16, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion utils/staking-miner/src/dry_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>> {
Expand Down Expand Up @@ -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<_>>(),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kianenigma would be nice if the iterator API is public :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately that iter api is some implementation detail (its order matter). Let's roll with this for now.

score,
Token::from(deposit),
raw_solution.encode().len(),
);
Expand Down