Skip to content

Commit

Permalink
feat: cli add list of vns for next epoch (#5743)
Browse files Browse the repository at this point in the history
Description
---
Add list of VNs for next epoch.

Motivation and Context
---

How Has This Been Tested?
---
I used dan-testing to create VNs and to check if they are printed for
the next epoch as well.

What process can a PR reviewer use to test or verify this change?
---
Same as above.

<!-- Checklist -->
<!-- 1. Is the title of your PR in the form that would make nice release
notes? The title, excluding the conventional commit
tag, will be included exactly as is in the CHANGELOG, so please think
about it carefully. -->


Breaking Changes
---

- [x] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [ ] Other - Please specify

<!-- Does this include a breaking change? If so, include this line as a
footer -->
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a
database, resync the chain -->
  • Loading branch information
Cifko committed Sep 7, 2023
1 parent 3fba04e commit d2a0c8c
Showing 1 changed file with 18 additions and 4 deletions.
Expand Up @@ -69,20 +69,34 @@ impl CommandContext {
.epoch
.map(|epoch| constants.epoch_to_block_height(epoch))
.unwrap_or_else(|| metadata.height_of_longest_chain());
let current_epoch = constants.block_height_to_epoch(height);
let next_epoch = VnEpoch(current_epoch.as_u64() + 1);
let next_epoch_height = constants.epoch_to_block_height(next_epoch);
let vns = self.blockchain_db.fetch_active_validator_nodes(height).await?;
let next_vns = self
.blockchain_db
.fetch_active_validator_nodes(next_epoch_height)
.await?;

println!();
println!(
"Registered validator nodes for epoch {}",
constants.block_height_to_epoch(height).as_u64()
);
println!("Registered validator nodes for epoch {}", current_epoch.as_u64());
println!("----------------------------------");
if vns.is_empty() {
println!("No active validator nodes.");
} else {
println!();
self.print_validator_nodes_list(&vns).await;
}
println!();
println!("Registered validator nodes for next epoch {}", next_epoch.as_u64());
println!("----------------------------------");
if next_vns.is_empty() {
println!("No active validator nodes.");
} else {
println!();
self.print_validator_nodes_list(&next_vns).await;
}

Ok(())
}
}

0 comments on commit d2a0c8c

Please sign in to comment.