Skip to content

Commit 0a4a2a6

Browse files
author
Zoran Cvetkov
committed
address PR comments
1 parent 70ca609 commit 0a4a2a6

File tree

13 files changed

+41
-44
lines changed

13 files changed

+41
-44
lines changed

chain/arweave/src/chain.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use graph::components::store::{DeploymentCursorTracker, SourceableStore};
1111
use graph::data::subgraph::UnifiedMappingApiVersion;
1212
use graph::env::EnvVars;
1313
use graph::firehose::FirehoseEndpoint;
14-
use graph::prelude::{DeploymentHash, MetricsRegistry};
14+
use graph::prelude::MetricsRegistry;
1515
use graph::substreams::Clock;
1616
use graph::{
1717
blockchain::{
@@ -121,7 +121,7 @@ impl Blockchain for Chain {
121121
deployment: DeploymentLocator,
122122
store: impl DeploymentCursorTracker,
123123
start_blocks: Vec<BlockNumber>,
124-
_source_subgraph_stores: Vec<(DeploymentHash, Arc<dyn SourceableStore>)>,
124+
_source_subgraph_stores: Vec<Arc<dyn SourceableStore>>,
125125
filter: Arc<TriggerFilterWrapper<Self>>,
126126
unified_api_version: UnifiedMappingApiVersion,
127127
) -> Result<Box<dyn BlockStream<Self>>, Error> {

chain/cosmos/src/chain.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use graph::blockchain::firehose_block_ingestor::FirehoseBlockIngestor;
22
use graph::blockchain::{BlockIngestor, NoopDecoderHook, TriggerFilterWrapper};
33
use graph::components::adapter::ChainId;
44
use graph::env::EnvVars;
5-
use graph::prelude::{DeploymentHash, MetricsRegistry};
5+
use graph::prelude::MetricsRegistry;
66
use graph::substreams::Clock;
77
use std::collections::HashSet;
88
use std::convert::TryFrom;
@@ -114,7 +114,7 @@ impl Blockchain for Chain {
114114
deployment: DeploymentLocator,
115115
store: impl DeploymentCursorTracker,
116116
start_blocks: Vec<BlockNumber>,
117-
_source_subgraph_stores: Vec<(DeploymentHash, Arc<dyn SourceableStore>)>,
117+
_source_subgraph_stores: Vec<Arc<dyn SourceableStore>>,
118118
filter: Arc<TriggerFilterWrapper<Self>>,
119119
unified_api_version: UnifiedMappingApiVersion,
120120
) -> Result<Box<dyn BlockStream<Self>>, Error> {

chain/ethereum/src/chain.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use graph::data::subgraph::UnifiedMappingApiVersion;
1212
use graph::firehose::{FirehoseEndpoint, ForkStep};
1313
use graph::futures03::compat::Future01CompatExt;
1414
use graph::prelude::{
15-
BlockHash, ComponentLoggerConfig, DeploymentHash, ElasticComponentLoggerConfig, EthereumBlock,
15+
BlockHash, ComponentLoggerConfig, ElasticComponentLoggerConfig, EthereumBlock,
1616
EthereumCallCache, LightEthereumBlock, LightEthereumBlockExt, MetricsRegistry,
1717
};
1818
use graph::schema::InputSchema;
@@ -128,7 +128,7 @@ impl BlockStreamBuilder<Chain> for EthereumStreamBuilder {
128128
chain: &Chain,
129129
deployment: DeploymentLocator,
130130
start_blocks: Vec<BlockNumber>,
131-
source_subgraph_stores: Vec<(DeploymentHash, Arc<dyn SourceableStore>)>,
131+
source_subgraph_stores: Vec<Arc<dyn SourceableStore>>,
132132
subgraph_current_block: Option<BlockPtr>,
133133
filter: Arc<TriggerFilterWrapper<Chain>>,
134134
unified_api_version: UnifiedMappingApiVersion,
@@ -150,7 +150,7 @@ impl BlockStreamBuilder<Chain> for EthereumStreamBuilder {
150150
chain: &Chain,
151151
deployment: DeploymentLocator,
152152
start_blocks: Vec<BlockNumber>,
153-
source_subgraph_stores: Vec<(DeploymentHash, Arc<dyn SourceableStore>)>,
153+
source_subgraph_stores: Vec<Arc<dyn SourceableStore>>,
154154
subgraph_current_block: Option<BlockPtr>,
155155
filter: Arc<TriggerFilterWrapper<Chain>>,
156156
unified_api_version: UnifiedMappingApiVersion,
@@ -437,7 +437,7 @@ impl Blockchain for Chain {
437437
deployment: DeploymentLocator,
438438
store: impl DeploymentCursorTracker,
439439
start_blocks: Vec<BlockNumber>,
440-
source_subgraph_stores: Vec<(DeploymentHash, Arc<dyn SourceableStore>)>,
440+
source_subgraph_stores: Vec<Arc<dyn SourceableStore>>,
441441
filter: Arc<TriggerFilterWrapper<Self>>,
442442
unified_api_version: UnifiedMappingApiVersion,
443443
) -> Result<Box<dyn BlockStream<Self>>, Error> {

chain/near/src/chain.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use graph::data::subgraph::UnifiedMappingApiVersion;
1313
use graph::env::EnvVars;
1414
use graph::firehose::FirehoseEndpoint;
1515
use graph::futures03::TryFutureExt;
16-
use graph::prelude::{DeploymentHash, MetricsRegistry};
16+
use graph::prelude::MetricsRegistry;
1717
use graph::schema::InputSchema;
1818
use graph::substreams::{Clock, Package};
1919
use graph::{
@@ -152,7 +152,7 @@ impl BlockStreamBuilder<Chain> for NearStreamBuilder {
152152
_chain: &Chain,
153153
_deployment: DeploymentLocator,
154154
_start_blocks: Vec<BlockNumber>,
155-
_source_subgraph_stores: Vec<(DeploymentHash, Arc<dyn SourceableStore>)>,
155+
_source_subgraph_stores: Vec<Arc<dyn SourceableStore>>,
156156
_subgraph_current_block: Option<BlockPtr>,
157157
_filter: Arc<TriggerFilterWrapper<Chain>>,
158158
_unified_api_version: UnifiedMappingApiVersion,
@@ -232,7 +232,7 @@ impl Blockchain for Chain {
232232
deployment: DeploymentLocator,
233233
store: impl DeploymentCursorTracker,
234234
start_blocks: Vec<BlockNumber>,
235-
_source_subgraph_stores: Vec<(DeploymentHash, Arc<dyn SourceableStore>)>,
235+
_source_subgraph_stores: Vec<Arc<dyn SourceableStore>>,
236236
filter: Arc<TriggerFilterWrapper<Self>>,
237237
unified_api_version: UnifiedMappingApiVersion,
238238
) -> Result<Box<dyn BlockStream<Self>>, Error> {

chain/starknet/src/chain.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ use graph::{
2323
firehose::{self, FirehoseEndpoint, ForkStep},
2424
futures03::future::TryFutureExt,
2525
prelude::{
26-
async_trait, BlockHash, BlockNumber, ChainStore, DeploymentHash, Error, Logger,
27-
LoggerFactory, MetricsRegistry,
26+
async_trait, BlockHash, BlockNumber, ChainStore, Error, Logger, LoggerFactory,
27+
MetricsRegistry,
2828
},
2929
schema::InputSchema,
3030
slog::o,
@@ -116,7 +116,7 @@ impl Blockchain for Chain {
116116
deployment: DeploymentLocator,
117117
store: impl DeploymentCursorTracker,
118118
start_blocks: Vec<BlockNumber>,
119-
_source_subgraph_stores: Vec<(DeploymentHash, Arc<dyn SourceableStore>)>,
119+
_source_subgraph_stores: Vec<Arc<dyn SourceableStore>>,
120120
filter: Arc<TriggerFilterWrapper<Self>>,
121121
unified_api_version: UnifiedMappingApiVersion,
122122
) -> Result<Box<dyn BlockStream<Self>>, Error> {
@@ -240,7 +240,7 @@ impl BlockStreamBuilder<Chain> for StarknetStreamBuilder {
240240
_chain: &Chain,
241241
_deployment: DeploymentLocator,
242242
_start_blocks: Vec<BlockNumber>,
243-
_source_subgraph_stores: Vec<(DeploymentHash, Arc<dyn SourceableStore>)>,
243+
_source_subgraph_stores: Vec<Arc<dyn SourceableStore>>,
244244
_subgraph_current_block: Option<BlockPtr>,
245245
_filter: Arc<TriggerFilterWrapper<Chain>>,
246246
_unified_api_version: UnifiedMappingApiVersion,

chain/substreams/src/block_stream.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use graph::{
1111
},
1212
components::store::{DeploymentLocator, SourceableStore},
1313
data::subgraph::UnifiedMappingApiVersion,
14-
prelude::{async_trait, BlockNumber, BlockPtr, DeploymentHash},
14+
prelude::{async_trait, BlockNumber, BlockPtr},
1515
schema::InputSchema,
1616
slog::o,
1717
};
@@ -104,7 +104,7 @@ impl BlockStreamBuilderTrait<Chain> for BlockStreamBuilder {
104104
_chain: &Chain,
105105
_deployment: DeploymentLocator,
106106
_start_blocks: Vec<BlockNumber>,
107-
_source_subgraph_stores: Vec<(DeploymentHash, Arc<dyn SourceableStore>)>,
107+
_source_subgraph_stores: Vec<Arc<dyn SourceableStore>>,
108108
_subgraph_current_block: Option<BlockPtr>,
109109
_filter: Arc<TriggerFilterWrapper<Chain>>,
110110
_unified_api_version: UnifiedMappingApiVersion,

chain/substreams/src/chain.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ use graph::blockchain::{
99
use graph::components::adapter::ChainId;
1010
use graph::components::store::{DeploymentCursorTracker, SourceableStore};
1111
use graph::env::EnvVars;
12-
use graph::prelude::{
13-
BlockHash, CheapClone, DeploymentHash, Entity, LoggerFactory, MetricsRegistry,
14-
};
12+
use graph::prelude::{BlockHash, CheapClone, Entity, LoggerFactory, MetricsRegistry};
1513
use graph::schema::EntityKey;
1614
use graph::{
1715
blockchain::{
@@ -142,7 +140,7 @@ impl Blockchain for Chain {
142140
deployment: DeploymentLocator,
143141
store: impl DeploymentCursorTracker,
144142
_start_blocks: Vec<BlockNumber>,
145-
_source_subgraph_stores: Vec<(DeploymentHash, Arc<dyn SourceableStore>)>,
143+
_source_subgraph_stores: Vec<Arc<dyn SourceableStore>>,
146144
filter: Arc<TriggerFilterWrapper<Self>>,
147145
_unified_api_version: UnifiedMappingApiVersion,
148146
) -> Result<Box<dyn BlockStream<Self>>, Error> {

core/src/subgraph/inputs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use graph::{
66
},
77
data::subgraph::{SubgraphFeature, UnifiedMappingApiVersion},
88
data_source::DataSourceTemplate,
9-
prelude::{BlockNumber, DeploymentHash},
9+
prelude::BlockNumber,
1010
};
1111
use std::collections::BTreeSet;
1212
use std::sync::Arc;
@@ -16,7 +16,7 @@ pub struct IndexingInputs<C: Blockchain> {
1616
pub features: BTreeSet<SubgraphFeature>,
1717
pub start_blocks: Vec<BlockNumber>,
1818
pub end_blocks: BTreeSet<BlockNumber>,
19-
pub source_subgraph_stores: Vec<(DeploymentHash, Arc<dyn SourceableStore>)>,
19+
pub source_subgraph_stores: Vec<Arc<dyn SourceableStore>>,
2020
pub stop_block: Option<BlockNumber>,
2121
pub store: Arc<dyn WritableStore>,
2222
pub debug_fork: Option<Arc<dyn SubgraphFork>>,

core/src/subgraph/instance_manager.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -203,26 +203,25 @@ impl<S: SubgraphStore> SubgraphInstanceManager<S> {
203203
}
204204
}
205205

206-
pub async fn hashes_to_read_store<C: Blockchain>(
206+
pub async fn get_sourceable_stores<C: Blockchain>(
207207
&self,
208208
hashes: Vec<DeploymentHash>,
209209
is_runner_test: bool,
210-
) -> anyhow::Result<Vec<(DeploymentHash, Arc<dyn SourceableStore>)>> {
211-
let mut sourceable_stores = Vec::new();
212-
let subgraph_store = self.subgraph_store.clone();
213-
210+
) -> anyhow::Result<Vec<Arc<dyn SourceableStore>>> {
214211
if is_runner_test {
215-
return Ok(sourceable_stores);
212+
return Ok(Vec::new());
216213
}
217214

215+
let mut sourceable_stores = Vec::new();
216+
let subgraph_store = self.subgraph_store.clone();
217+
218218
for hash in hashes {
219219
let loc = subgraph_store
220220
.active_locator(&hash)?
221221
.ok_or_else(|| anyhow!("no active deployment for hash {}", hash))?;
222222

223223
let sourceable_store = subgraph_store.clone().sourceable(loc.id.clone()).await?;
224-
225-
sourceable_stores.push((loc.hash, sourceable_store));
224+
sourceable_stores.push(sourceable_store);
226225
}
227226

228227
Ok(sourceable_stores)
@@ -469,21 +468,21 @@ impl<S: SubgraphStore> SubgraphInstanceManager<S> {
469468

470469
let decoder = Box::new(Decoder::new(decoder_hook));
471470

472-
let subgraph_data_source_read_stores = self
473-
.hashes_to_read_store::<C>(subgraph_ds_source_deployments, is_runner_test)
471+
let subgraph_data_source_stores = self
472+
.get_sourceable_stores::<C>(subgraph_ds_source_deployments, is_runner_test)
474473
.await?;
475474

476475
let triggers_adapter = Arc::new(TriggersAdapterWrapper::new(
477476
triggers_adapter,
478-
subgraph_data_source_read_stores.clone(),
477+
subgraph_data_source_stores.clone(),
479478
));
480479

481480
let inputs = IndexingInputs {
482481
deployment: deployment.clone(),
483482
features,
484483
start_blocks,
485484
end_blocks,
486-
source_subgraph_stores: subgraph_data_source_read_stores,
485+
source_subgraph_stores: subgraph_data_source_stores,
487486
stop_block,
488487
store,
489488
debug_fork,

graph/src/blockchain/block_stream.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub trait BlockStreamBuilder<C: Blockchain>: Send + Sync {
149149
chain: &C,
150150
deployment: DeploymentLocator,
151151
start_blocks: Vec<BlockNumber>,
152-
source_subgraph_stores: Vec<(DeploymentHash, Arc<dyn SourceableStore>)>,
152+
source_subgraph_stores: Vec<Arc<dyn SourceableStore>>,
153153
subgraph_current_block: Option<BlockPtr>,
154154
filter: Arc<TriggerFilterWrapper<C>>,
155155
unified_api_version: UnifiedMappingApiVersion,
@@ -160,7 +160,7 @@ pub trait BlockStreamBuilder<C: Blockchain>: Send + Sync {
160160
chain: &C,
161161
deployment: DeploymentLocator,
162162
start_blocks: Vec<BlockNumber>,
163-
source_subgraph_stores: Vec<(DeploymentHash, Arc<dyn SourceableStore>)>,
163+
source_subgraph_stores: Vec<Arc<dyn SourceableStore>>,
164164
subgraph_current_block: Option<BlockPtr>,
165165
filter: Arc<TriggerFilterWrapper<C>>,
166166
unified_api_version: UnifiedMappingApiVersion,
@@ -320,13 +320,13 @@ impl<C: Blockchain> BlockWithTriggers<C> {
320320
/// logic for each chain, increasing code repetition.
321321
pub struct TriggersAdapterWrapper<C: Blockchain> {
322322
pub adapter: Arc<dyn TriggersAdapter<C>>,
323-
pub source_subgraph_stores: Vec<(DeploymentHash, Arc<dyn SourceableStore>)>,
323+
pub source_subgraph_stores: Vec<Arc<dyn SourceableStore>>,
324324
}
325325

326326
impl<C: Blockchain> TriggersAdapterWrapper<C> {
327327
pub fn new(
328328
adapter: Arc<dyn TriggersAdapter<C>>,
329-
source_subgraph_stores: Vec<(DeploymentHash, Arc<dyn SourceableStore>)>,
329+
source_subgraph_stores: Vec<Arc<dyn SourceableStore>>,
330330
) -> Self {
331331
Self {
332332
adapter,

0 commit comments

Comments
 (0)