mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 20:29:23 +00:00
Cache the block's events within TemporalSerai
Event retrieval was prior: - Retrieve all events in the block, which may be hundreds of KB - Filter to just a few Since it's frequent to want multiple sets of events, each filtered in their own way, this caused the retrieval to happen multiple times. Now, it only will happen once. Also has the scoped clients take a reference, not an owned TemporalSerai.
This commit is contained in:
@@ -54,6 +54,7 @@ serai_test!(
|
||||
|
||||
let block = provide_batch(&serai, batch.clone()).await;
|
||||
|
||||
let instruction = {
|
||||
let serai = serai.as_of(block);
|
||||
let batches = serai.in_instructions().batch_events().await.unwrap();
|
||||
assert_eq!(
|
||||
@@ -82,19 +83,20 @@ serai_test!(
|
||||
OsRng.fill_bytes(&mut rand_bytes);
|
||||
let data = Data::new(rand_bytes).unwrap();
|
||||
|
||||
let instruction = OutInstructionWithBalance {
|
||||
OutInstructionWithBalance {
|
||||
balance,
|
||||
instruction: OutInstruction { address: external_address, data: Some(data) },
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
let serai = serai.into_inner();
|
||||
let block = publish_tx(
|
||||
serai,
|
||||
&serai,
|
||||
&serai.sign(&pair, SeraiCoins::burn_with_instruction(instruction.clone()), 0, 0),
|
||||
)
|
||||
.await;
|
||||
|
||||
let serai = serai.as_of(block).coins();
|
||||
let serai = serai.as_of(block);
|
||||
let serai = serai.coins();
|
||||
let events = serai.burn_with_instruction_events().await.unwrap();
|
||||
assert_eq!(events, vec![CoinsEvent::BurnWithInstruction { from: address, instruction }]);
|
||||
assert_eq!(serai.coin_supply(coin).await.unwrap(), Amount(0));
|
||||
|
||||
@@ -48,7 +48,8 @@ serai_test!(
|
||||
);
|
||||
|
||||
{
|
||||
let vs_serai = serai.as_of_latest_finalized_block().await.unwrap().validator_sets();
|
||||
let vs_serai = serai.as_of_latest_finalized_block().await.unwrap();
|
||||
let vs_serai = vs_serai.validator_sets();
|
||||
let participants = vs_serai.participants(set.network).await
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
@@ -64,7 +65,8 @@ serai_test!(
|
||||
|
||||
// While the set_keys function should handle this, it's beneficial to
|
||||
// independently test it
|
||||
let serai = serai.as_of(block).validator_sets();
|
||||
let serai = serai.as_of(block);
|
||||
let serai = serai.validator_sets();
|
||||
assert_eq!(
|
||||
serai.key_gen_events().await.unwrap(),
|
||||
vec![ValidatorSetsEvent::KeyGen { set, key_pair: key_pair.clone() }]
|
||||
|
||||
Reference in New Issue
Block a user