Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
add get_last_block_number/get_unfinalized_tail_block_number in eth2-p…
Browse files Browse the repository at this point in the history
…allet-init
  • Loading branch information
baidang201 committed Aug 21, 2023
1 parent c61804f commit 5300122
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions crates/eth2-pallet-init/src/substrate_pallet_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,18 +364,27 @@ impl EthClientPalletTrait for EthClientPallet {
}

async fn get_last_block_number(&self) -> anyhow::Result<u64> {
Err(std::io::Error::new(
std::io::ErrorKind::Other,
"Unable to get value for get_last_block_number".to_string(),
)
.into())
let addr = tangle::storage()
.eth2_client()
.finalized_execution_header(convert_typed_chain_ids(self.chain));

if let Some(head) = self.get_value(&addr).await? {
Ok(head.block_number)
} else {
Ok(0)
}
}

async fn get_unfinalized_tail_block_number(&self) -> anyhow::Result<Option<u64>> {
Err(std::io::Error::new(
std::io::ErrorKind::Other,
"Unable to get value for get_unfinalized_tail_block_number".to_string(),
)
.into())
let addr = tangle::storage()
.eth2_client()
.unfinalized_tail_execution_header(convert_typed_chain_ids(self.chain));

if let Some(head) = self.get_value(&addr).await? {
Ok(Some(head.block_number))
} else {
Ok(None)
}
}
}

Expand Down

0 comments on commit 5300122

Please sign in to comment.