Skip to content

Commit

Permalink
fix: cache extrinsic events
Browse files Browse the repository at this point in the history
  • Loading branch information
f-squirrel committed Jan 2, 2024
1 parent 47b8c90 commit cc038c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion codegen/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::error::CodegenError;
pub use self::{
composite_def::{CompositeDef, CompositeDefFieldType, CompositeDefFields},
derives::{Derives, DerivesRegistry},
substitutes::{AbsolutePath, TypeSubstitutes},
substitutes::TypeSubstitutes,
type_def::TypeDefGen,
type_def_params::TypeDefParameters,
type_path::{TypeParameter, TypePath, TypePathType},
Expand Down
8 changes: 5 additions & 3 deletions subxt/src/blocks/block_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,15 @@ where
// Acquire lock on the events cache. We either get back our events or we fetch and set them
// before unlocking, so only one fetch call should ever be made. We do this because the
// same events can be shared across all extrinsics in the block.
let lock = cached_events.lock().await;
let mut lock = cached_events.lock().await;
let events = match &*lock {
Some(events) => events.clone(),
None => {
events::EventsClient::new(client.clone())
let events = events::EventsClient::new(client.clone())
.at(block_hash)
.await?
.await?;
lock.replace(events.clone());
events
}
};

Expand Down

0 comments on commit cc038c5

Please sign in to comment.