Skip to content

Commit 3cb7dad

Browse files
committed
Mock statement allowance reading
1 parent 04f972e commit 3cb7dad

File tree

1 file changed

+12
-7
lines changed
  • substrate/client/statement-store/src

1 file changed

+12
-7
lines changed

substrate/client/statement-store/src/lib.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ impl Index {
314314
let key_set = self.by_dec_key.get(&key);
315315
if key_set.map_or(0, |s| s.len()) == 0 {
316316
// Key does not exist in the index.
317-
return Ok(())
317+
return Ok(());
318318
}
319319

320320
for t in match_any_topics {
@@ -342,7 +342,7 @@ impl Index {
342342
let key_set = self.by_dec_key.get(&key);
343343
if key_set.map_or(0, |s| s.len()) == 0 {
344344
// Key does not exist in the index.
345-
return Ok(())
345+
return Ok(());
346346
}
347347

348348
for item in key_set.map(|hashes| hashes.iter()).into_iter().flatten() {
@@ -361,7 +361,7 @@ impl Index {
361361
let mut sets: [&HashSet<Hash>; MAX_TOPICS + 1] = [&empty; MAX_TOPICS + 1];
362362
let num_topics = match_all_topics.len();
363363
if num_topics > MAX_TOPICS {
364-
return Ok(())
364+
return Ok(());
365365
}
366366
let key_set = self.by_dec_key.get(&key);
367367
if key_set.map_or(0, |s| s.len()) == 0 {
@@ -668,7 +668,12 @@ impl Store {
668668
ClientWrapper { client, _block: Default::default(), _backend: Default::default() };
669669
let read_allowance_fn =
670670
Box::new(move |account_id: &AccountId, block_hash: Option<BlockHash>| {
671-
storage_reader.read_allowance(account_id, block_hash.map(Into::into))
671+
// storage_reader.read_allowance(account_id, block_hash.map(Into::into))
672+
std::thread::sleep(std::time::Duration::from_millis(10));
673+
Ok(Some(StatementAllowance::new(
674+
DEFAULT_MAX_TOTAL_STATEMENTS as u32,
675+
DEFAULT_MAX_TOTAL_SIZE as u32,
676+
)))
672677
});
673678

674679
let store = Store {
@@ -815,7 +820,7 @@ impl Store {
815820
drop(index);
816821
let mut index = self.index.write();
817822
index.accounts_to_check_for_expiry_stmts = existing_accounts;
818-
return
823+
return;
819824
}
820825

821826
let mut needs_expiry = Vec::new();
@@ -843,7 +848,7 @@ impl Store {
843848
num_accounts_checked >= MAX_EXPIRY_ACCOUNTS_PER_ITERATION ||
844849
start.elapsed().as_millis() >= MAX_EXPIRY_TIME_MS_PER_ITERATION
845850
{
846-
break
851+
break;
847852
}
848853
}
849854

@@ -1242,7 +1247,7 @@ impl StatementStore for Store {
12421247
"Reading statement allowance for account {} failed",
12431248
HexDisplay::from(&account_id),
12441249
);
1245-
return SubmitResult::InternalError(e)
1250+
return SubmitResult::InternalError(e);
12461251
},
12471252
};
12481253

0 commit comments

Comments
 (0)