Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
unique runtime api instances in loops
Browse files Browse the repository at this point in the history
  • Loading branch information
Wizdave97 committed Sep 24, 2023
1 parent 5a57aeb commit 4a598c1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pallet-ismp/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,10 @@ where
&self,
block_numbers: Vec<BlockNumberOrHash<Block::Hash>>,
) -> Result<HashMap<String, Vec<Event>>> {
let mut api = self.client.runtime_api();
api.register_extension(OffchainDbExt::new(self.offchain_db.clone()));
let mut events = HashMap::new();
for block_number_or_hash in block_numbers {
let mut api = self.client.runtime_api();
api.register_extension(OffchainDbExt::new(self.offchain_db.clone()));
let at = match block_number_or_hash {
BlockNumberOrHash::Hash(block_hash) => block_hash,
BlockNumberOrHash::Number(block_number) => {
Expand All @@ -319,8 +319,9 @@ where
let mut response_indices = vec![];
let mut temp: Vec<Event> = api
.block_events(at)
.ok()
.ok_or_else(|| runtime_error_into_rpc_error("failed to read block events"))?
.map_err(|e| {
runtime_error_into_rpc_error(format!("failed to read block events {:?}", e))
})?
.into_iter()
.filter_map(|event| match event {
pallet_ismp::events::Event::Request {
Expand Down

0 comments on commit 4a598c1

Please sign in to comment.