Skip to content

Commit

Permalink
store: Add blocks loaded from the database to the cache
Browse files Browse the repository at this point in the history
This makes sure that the recent blocks cache gets populated on nodes that
don't call upsert_blocks, i.e., index nodes that are not the block
ingestor.
  • Loading branch information
lutter committed Dec 11, 2023
1 parent 444041f commit dd957bb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion store/postgres/src/chain_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use crate::{
};

/// Our own internal notion of a block
#[derive(Clone, Debug)]
struct JsonBlock {
ptr: BlockPtr,
parent_hash: BlockHash,
Expand Down Expand Up @@ -1878,7 +1879,11 @@ impl ChainStoreTrait for ChainStore {
.cloned()
.collect::<Vec<_>>();
let conn = self.get_conn()?;
self.storage.blocks(&conn, &self.chain, &hashes)?
let stored = self.storage.blocks(&conn, &self.chain, &hashes)?;
for block in &stored {
self.recent_blocks_cache.insert_block(block.clone());
}
stored
} else {
Vec::new()
};
Expand Down

0 comments on commit dd957bb

Please sign in to comment.