feat(traverse): Expose block number value (#140)
This commit is contained in:
parent
fb2ea893e9
commit
0fd3a7b20e
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 {
|
pub fn era(&self) -> Era {
|
||||||
match self {
|
match self {
|
||||||
MultiEraBlock::EpochBoundary(_) => Era::Byron,
|
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 {
|
pub fn slot(&self) -> u64 {
|
||||||
match self {
|
match self {
|
||||||
MultiEraHeader::EpochBoundary(x) => x.to_abs_slot(),
|
MultiEraHeader::EpochBoundary(x) => x.to_abs_slot(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue