Skip to content

Commit 59b7aa4

Browse files
committed
ethereum: Refactor to use DynTryFuture
1 parent e7eaa01 commit 59b7aa4

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

chain/ethereum/src/ethereum_adapter.rs

+13-14
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use futures::prelude::*;
44
use lazy_static::lazy_static;
55
use std::collections::HashSet;
66
use std::iter::FromIterator;
7-
use std::pin::Pin;
87
use std::sync::Arc;
98
use std::time::Instant;
109

@@ -13,8 +12,8 @@ use graph::components::ethereum::{EthereumAdapter as EthereumAdapterTrait, *};
1312
use graph::prelude::{
1413
debug, err_msg, error, ethabi, format_err,
1514
futures03::{self, compat::Future01CompatExt, FutureExt, StreamExt, TryStreamExt},
16-
hex, retry, stream, tiny_keccak, trace, warn, web3, ChainStore, Error, EthereumCallCache,
17-
Logger, TimeoutError,
15+
hex, retry, stream, tiny_keccak, trace, warn, web3, ChainStore, DynTryFuture, Error,
16+
EthereumCallCache, Logger, TimeoutError,
1817
};
1918
use web3::api::Web3;
2019
use web3::transports::batch::Batch;
@@ -260,7 +259,7 @@ where
260259
from: u64,
261260
to: u64,
262261
filter: EthGetLogsFilter,
263-
) -> Pin<Box<dyn std::future::Future<Output = Result<Vec<Log>, Error>> + Send>> {
262+
) -> DynTryFuture<'static, Vec<Log>, Error> {
264263
// Codes returned by Ethereum node providers if an eth_getLogs request is too heavy.
265264
// The first one is for Infura when it hits the log limit, the rest for Alchemy timeouts.
266265
const TOO_MANY_LOGS_FINGERPRINTS: &[&str] = &[
@@ -1035,18 +1034,18 @@ where
10351034
from: u64,
10361035
to: u64,
10371036
log_filter: EthereumLogFilter,
1038-
) -> Box<dyn std::future::Future<Output = Result<Vec<Log>, Error>> + Send + Unpin> {
1037+
) -> DynTryFuture<'static, Vec<Log>, Error> {
10391038
let eth: Self = self.clone();
10401039
let logger = logger.clone();
1041-
Box::new(
1042-
futures03::stream::iter(log_filter.eth_get_logs_filters().map(move |filter| {
1043-
eth.clone()
1044-
.log_stream(logger.clone(), subgraph_metrics.clone(), from, to, filter)
1045-
.into_stream()
1046-
}))
1047-
.flatten()
1048-
.try_concat(),
1049-
)
1040+
1041+
futures03::stream::iter(log_filter.eth_get_logs_filters().map(move |filter| {
1042+
eth.clone()
1043+
.log_stream(logger.clone(), subgraph_metrics.clone(), from, to, filter)
1044+
.into_stream()
1045+
}))
1046+
.flatten()
1047+
.try_concat()
1048+
.boxed()
10501049
}
10511050

10521051
fn calls_in_block_range(

graph/src/components/ethereum/adapter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ pub trait EthereumAdapter: Send + Sync + 'static {
739739
from: u64,
740740
to: u64,
741741
log_filter: EthereumLogFilter,
742-
) -> Box<dyn std::future::Future<Output = Result<Vec<Log>, Error>> + Send + Unpin>;
742+
) -> DynTryFuture<'static, Vec<Log>, Error>;
743743

744744
fn calls_in_block_range(
745745
&self,

0 commit comments

Comments
 (0)