feat(traverse): Expose block number value (#140)
This commit is contained in:
parent
41ee169917
commit
c7227c0234
2 changed files with 35 additions and 0 deletions
|
|
@ -85,6 +85,27 @@ impl<'b> MultiEraBlock<'b> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn number(&self) -> u64 {
|
||||
match self {
|
||||
MultiEraBlock::EpochBoundary(x) => x
|
||||
.header
|
||||
.consensus_data
|
||||
.difficulty
|
||||
.first()
|
||||
.cloned()
|
||||
.unwrap_or_default(),
|
||||
MultiEraBlock::AlonzoCompatible(x, _) => x.header.header_body.block_number,
|
||||
MultiEraBlock::Babbage(x) => x.header.header_body.block_number,
|
||||
MultiEraBlock::Byron(x) => x
|
||||
.header
|
||||
.consensus_data
|
||||
.2
|
||||
.first()
|
||||
.cloned()
|
||||
.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn era(&self) -> Era {
|
||||
match self {
|
||||
MultiEraBlock::EpochBoundary(_) => Era::Byron,
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue