Skip to content

Commit dc98ac4

Browse files
committed
chain/ethereum: first check the block cache when calling parent_ptr with firehose client
1 parent ae20c82 commit dc98ac4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

chain/ethereum/src/chain.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,17 @@ impl TriggersAdapterTrait<Chain> for TriggersAdapter {
10181018

10191019
let block = match self.chain_client.as_ref() {
10201020
ChainClient::Firehose(endpoints) => {
1021+
let chain_store = self.chain_store.cheap_clone();
1022+
// First try to get the block from the store
1023+
if let Ok(blocks) = chain_store.blocks(vec![block.hash.clone()]).await {
1024+
if let Some(block) = blocks.first() {
1025+
if let Ok(block) = json::from_value::<LightEthereumBlock>(block.clone()) {
1026+
return Ok(block.parent_ptr());
1027+
}
1028+
}
1029+
}
1030+
1031+
// If not in store, fetch from Firehose
10211032
let endpoint = endpoints.endpoint().await?;
10221033
let logger = self.logger.clone();
10231034
let retry_log_message =

0 commit comments

Comments
 (0)