mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 15:51:04 +00:00
fix: cache extrinsic events (#1327)
Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
This commit is contained in:
@@ -123,13 +123,15 @@ where
|
|||||||
// Acquire lock on the events cache. We either get back our events or we fetch and set them
|
// 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
|
// 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.
|
// 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 {
|
let events = match &*lock {
|
||||||
Some(events) => events.clone(),
|
Some(events) => events.clone(),
|
||||||
None => {
|
None => {
|
||||||
events::EventsClient::new(client.clone())
|
let events = events::EventsClient::new(client.clone())
|
||||||
.at(block_hash)
|
.at(block_hash)
|
||||||
.await?
|
.await?;
|
||||||
|
lock.replace(events.clone());
|
||||||
|
events
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user