Skip to content

Commit 2301bfa

Browse files
committed
graph, core: Add a new SubgraphFilter struct
1 parent 2d5ff51 commit 2301bfa

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

core/src/subgraph/runner.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use graph::blockchain::block_stream::{
88
BlockStreamError, BlockStreamEvent, BlockWithTriggers, FirehoseCursor,
99
};
1010
use graph::blockchain::{
11-
Block, BlockTime, Blockchain, DataSource as _, Trigger, TriggerFilter as _,
11+
Block, BlockTime, Blockchain, DataSource as _, SubgraphFilter, Trigger, TriggerFilter as _,
1212
TriggerFilterWrapper,
1313
};
1414
use graph::components::store::{EmptyStore, GetScope, ReadStore, StoredDynamicDataSource};
@@ -136,7 +136,16 @@ where
136136
let subgraph_filter = data_sources
137137
.iter()
138138
.filter_map(|ds| ds.as_subgraph())
139-
.map(|ds| (ds.source.address(), ds.source.start_block))
139+
.map(|ds| SubgraphFilter {
140+
subgraph: ds.source.address(),
141+
start_block: ds.source.start_block,
142+
entities: ds
143+
.mapping
144+
.handlers
145+
.iter()
146+
.map(|handler| handler.entity.clone())
147+
.collect(),
148+
})
140149
.collect::<Vec<_>>();
141150

142151
// if static_filters is not enabled we just stick to the filter based on all the data sources.

graph/src/blockchain/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,21 @@ impl From<web3::Error> for IngestorError {
253253
#[derive(Debug)]
254254
pub struct TriggerFilterWrapper<C: Blockchain> {
255255
pub filter: Arc<C::TriggerFilter>,
256-
pub subgraph_filter: Vec<(DeploymentHash, BlockNumber)>, // TODO(krishna): Make this a struct
256+
pub subgraph_filter: Vec<SubgraphFilter>,
257+
}
258+
259+
260+
#[derive(Clone, Debug)]
261+
pub struct SubgraphFilter {
262+
pub subgraph: DeploymentHash,
263+
pub start_block: BlockNumber,
264+
pub entities: Vec<String>,
257265
}
258266

259267
impl<C: Blockchain> TriggerFilterWrapper<C> {
260268
pub fn new(
261269
filter: C::TriggerFilter,
262-
subgraph_filter: Vec<(DeploymentHash, BlockNumber)>,
270+
subgraph_filter: Vec<SubgraphFilter>,
263271
) -> Self {
264272
Self {
265273
filter: Arc::new(filter),

0 commit comments

Comments
 (0)