Skip to content

Commit eda46fd

Browse files
core: Fix max_end_block being None when data sources share the same endBlock
1 parent d0aa152 commit eda46fd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

core/src/subgraph/instance_manager.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,15 @@ impl<S: SubgraphStore, AC: amp::Client> SubgraphInstanceManager<S, AC> {
399399
// when to stop processing them.
400400
// - Offchain data sources might require processing beyond the end block of
401401
// onchain data sources, so the subgraph needs to continue.
402-
let max_end_block: Option<BlockNumber> = if data_sources.len() == end_blocks.len() {
402+
//
403+
// Note: we explicitly check each data source rather than comparing lengths, because
404+
// `end_blocks` is a BTreeSet and deduplicates equal values, which would cause the
405+
// length comparison to fail when multiple data sources share the same `end_block`.
406+
let max_end_block: Option<BlockNumber> = if data_sources.iter().all(|d| {
407+
d.as_onchain()
408+
.and_then(|d: &C::DataSource| d.end_block())
409+
.is_some()
410+
}) {
403411
end_blocks.iter().max().cloned()
404412
} else {
405413
None

0 commit comments

Comments
 (0)