Skip to content

Commit c0b4450

Browse files
committed
all: Use a workspace package for tokio
Instead of reexporting from the graph crate, declare tokio once in the workspace and use it as needed
1 parent d3ad11a commit c0b4450

File tree

34 files changed

+68
-45
lines changed

34 files changed

+68
-45
lines changed

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ syn = { version = "2.0.106", features = ["full"] }
9393
test-store = { path = "./store/test-store" }
9494
thiserror = "2.0.16"
9595
tokio = { version = "1.45.1", features = ["full"] }
96+
tokio-stream = { version = "0.1.15", features = ["sync"] }
97+
tokio-retry = "0.3.0"
98+
9699
tonic = { version = "0.12.3", features = ["tls-roots", "gzip"] }
97100
tonic-build = { version = "0.12.3", features = ["prost"] }
98101
tower-http = { version = "0.6.6", features = ["cors"] }

chain/ethereum/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ tiny-keccak = "1.5.0"
1616
hex = "0.4.3"
1717
semver = "1.0.27"
1818
thiserror = { workspace = true }
19+
tokio = { workspace = true }
20+
tokio-stream = { workspace = true }
1921

2022
itertools = "0.14.0"
2123

chain/ethereum/src/chain.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1268,8 +1268,10 @@ impl FirehoseMapperTrait<Chain> for FirehoseMapper {
12681268

12691269
#[cfg(test)]
12701270
mod tests {
1271+
use tokio;
1272+
12711273
use graph::blockchain::mock::MockChainStore;
1272-
use graph::{slog, tokio};
1274+
use graph::slog;
12731275

12741276
use super::*;
12751277
use std::sync::Arc;

chain/ethereum/src/ethereum_adapter.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use async_trait::async_trait;
22
use futures03::{future::BoxFuture, stream::FuturesUnordered};
3+
use tokio::sync::RwLock;
4+
use tokio::time::timeout;
5+
36
use graph::blockchain::client::ChainClient;
47
use graph::blockchain::BlockHash;
58
use graph::blockchain::ChainIdentifier;
@@ -23,8 +26,6 @@ use graph::prelude::ethabi::Token;
2326
use graph::prelude::tokio::try_join;
2427
use graph::prelude::web3::types::U256;
2528
use graph::slog::o;
26-
use graph::tokio::sync::RwLock;
27-
use graph::tokio::time::timeout;
2829
use graph::{
2930
blockchain::{block_stream::BlockWithTriggers, BlockPtr, IngestorError},
3031
prelude::{
@@ -2352,7 +2353,7 @@ async fn fetch_individual_receipts_with_retry(
23522353
}
23532354

23542355
// Use a stream to fetch receipts individually
2355-
let hash_stream = graph::tokio_stream::iter(hashes);
2356+
let hash_stream = tokio_stream::iter(hashes);
23562357
let receipt_stream = hash_stream
23572358
.map(move |tx_hash| {
23582359
fetch_transaction_receipt_with_retry(
@@ -2364,7 +2365,7 @@ async fn fetch_individual_receipts_with_retry(
23642365
})
23652366
.buffered(ENV_VARS.block_ingestor_max_concurrent_json_rpc_calls);
23662367

2367-
graph::tokio_stream::StreamExt::collect::<Result<Vec<Arc<TransactionReceipt>>, IngestorError>>(
2368+
tokio_stream::StreamExt::collect::<Result<Vec<Arc<TransactionReceipt>>, IngestorError>>(
23682369
receipt_stream,
23692370
)
23702371
.await

chain/ethereum/src/network.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ impl EthereumNetworkAdapters {
309309

310310
#[cfg(test)]
311311
mod tests {
312+
use tokio;
313+
312314
use graph::cheap_clone::CheapClone;
313315
use graph::components::network_provider::ProviderCheckStrategy;
314316
use graph::components::network_provider::ProviderManager;
@@ -320,7 +322,6 @@ mod tests {
320322
firehose::SubgraphLimit,
321323
prelude::MetricsRegistry,
322324
slog::{o, Discard, Logger},
323-
tokio,
324325
url::Url,
325326
};
326327
use std::sync::Arc;

chain/ethereum/src/polling_block_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use anyhow::{anyhow, Error};
2-
use graph::tokio;
32
use std::cmp;
43
use std::collections::VecDeque;
54
use std::pin::Pin;
65
use std::sync::Arc;
76
use std::task::{Context, Poll};
87
use std::time::Duration;
8+
use tokio;
99

1010
use graph::blockchain::block_stream::{
1111
BlockStream, BlockStreamError, BlockStreamEvent, BlockWithTriggers, ChainHeadUpdateStream,

chain/near/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ graph-runtime-derive = { path = "../../runtime/derive" }
2020
[dev-dependencies]
2121
diesel = { workspace = true }
2222
trigger-filters.path = "../../substreams/trigger-filters"
23+
tokio = { workspace = true }

chain/near/src/trigger.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ pub struct ReceiptWithOutcome {
154154
mod tests {
155155
use std::convert::TryFrom;
156156

157+
use tokio;
158+
157159
use super::*;
158160

159161
use graph::{
@@ -162,7 +164,6 @@ mod tests {
162164
data::subgraph::API_VERSION_0_0_5,
163165
prelude::{hex, BigInt},
164166
runtime::{gas::GasCounter, DeterministicHostError, HostExportError},
165-
tokio,
166167
util::mem::init_slice,
167168
};
168169

chain/substreams/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ anyhow = "1.0"
1818
hex = "0.4.3"
1919
semver = "1.0.27"
2020
base64 = "0.22.1"
21+
tokio-stream = { workspace = true }
2122

2223
[dev-dependencies]
2324
tokio = { version = "1", features = ["full"] }

0 commit comments

Comments
 (0)