Skip to content

Commit

Permalink
Native prices: Implement generic buffered batching system 1/3 (#2869)
Browse files Browse the repository at this point in the history
# Description
Implements a generic batching system for the native prices.

The implementation has a blocking function
`blocking_buffered_estimate_prices()` that belongs to a struct which
runs a thread. The thread gathers the requests either by time (it waits
X time to gather request and then fires them) or by number of requests
(as soon ass it reaches a number of requests, fires them).

This generic implementation allow for any native price fetcher to batch
buffer the request as long as they implement the trait
`NativePriceBatchFetcher`.

This code is heavily based on the `ethrpc` crate code.

In the upcoming PR:
- the configuration will be propagated to the services configuration
- implement the trait `NativePriceBatchFetcher` for CoinGecko

# Changes
- Generic buffered batching system for native prices

## How to test
1. Unit test

---------

Co-authored-by: MartinquaXD <[email protected]>
  • Loading branch information
m-lord-renkse and MartinquaXD authored Aug 13, 2024
1 parent 7cc3778 commit b156d29
Show file tree
Hide file tree
Showing 3 changed files with 570 additions and 6 deletions.
1 change: 1 addition & 0 deletions crates/shared/src/price_estimation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use {
thiserror::Error,
};

mod buffered;
pub mod competition;
pub mod external;
pub mod factory;
Expand Down
Loading

0 comments on commit b156d29

Please sign in to comment.