feat(traverse): Expose block number value (#140)

This commit is contained in:
Santiago Carmuega 2022-06-27 18:01:48 -03:00 committed by GitHub
parent fb2ea893e9
commit 0fd3a7b20e
2 changed files with 35 additions and 0 deletions

View file

@ -29,6 +29,20 @@ impl<'b> MultiEraHeader<'b> {
}
}
pub fn number(&self) -> u64 {
match self {
MultiEraHeader::EpochBoundary(x) => x
.consensus_data
.difficulty
.first()
.cloned()
.unwrap_or_default(),
MultiEraHeader::AlonzoCompatible(x) => x.header_body.block_number,
MultiEraHeader::Babbage(x) => x.header_body.block_number,
MultiEraHeader::Byron(x) => x.consensus_data.2.first().cloned().unwrap_or_default(),
}
}
pub fn slot(&self) -> u64 {
match self {
MultiEraHeader::EpochBoundary(x) => x.to_abs_slot(),