mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 20:29:23 +00:00
Fix the async flow with the Router
It had sequential async calls with complexity O(n), with a variety of redundant calls. There was also a constant of... 4? 5? for each item. Now, the total sequence depth is just 3-4.
This commit is contained in:
@@ -32,6 +32,7 @@ impl primitives::BlockHeader for Epoch {
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub(crate) struct FullEpoch {
|
||||
pub(crate) epoch: Epoch,
|
||||
/// The unordered list of `InInstruction`s within this epoch
|
||||
pub(crate) instructions: Vec<EthereumInInstruction>,
|
||||
pub(crate) executed: Vec<Executed>,
|
||||
}
|
||||
|
||||
@@ -162,12 +162,14 @@ impl<D: Db> ScannerFeed for Rpc<D> {
|
||||
router: Router,
|
||||
block: Header,
|
||||
) -> Result<(Vec<EthereumInInstruction>, Vec<Executed>), RpcError<TransportErrorKind>> {
|
||||
let mut instructions = router.in_instructions(block.number, &HashSet::from(TOKENS)).await?;
|
||||
let mut instructions = router
|
||||
.in_instructions_unordered(block.number, block.number, &HashSet::from(TOKENS))
|
||||
.await?;
|
||||
|
||||
for token in TOKENS {
|
||||
for TopLevelTransfer { id, transaction_hash, from, amount, data } in
|
||||
Erc20::new(provider.clone(), **token)
|
||||
.top_level_transfers(block.number, router.address())
|
||||
Erc20::new(provider.clone(), token)
|
||||
.top_level_transfers_unordered(block.number, block.number, router.address())
|
||||
.await?
|
||||
{
|
||||
instructions.push(EthereumInInstruction {
|
||||
|
||||
Reference in New Issue
Block a user