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 886e778
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 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
5 changes: 1 addition & 4 deletions subxt/src/backend/rpc/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,7 @@ impl<Res: DeserializeOwned> Stream for RpcSubscription<Res> {
mod jsonrpsee_helpers {
pub use jsonrpsee::{
client_transport::ws::{Receiver, Sender, Url, WsTransportClientBuilder},
core::{
client::{Client, ClientBuilder},
Error,
},
core::{client::Client, Error},
};

/// Build WS RPC client from URL
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
5 changes: 1 addition & 4 deletions testing/test-runtime/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,7 @@ async fn run() {
mod client {
pub use jsonrpsee::{
client_transport::ws::{Receiver, Sender, Url, WsTransportClientBuilder},
core::{
client::{Client, ClientBuilder},
Error,
},
core::{client::Client, Error},
};

pub use jsonrpsee::core::{client::ClientT, rpc_params};
Expand Down

0 comments on commit 886e778

Please sign in to comment.