Skip to content

Commit

Permalink
fix: Dynamic data sources hotfixes (#3851)
Browse files Browse the repository at this point in the history
  • Loading branch information
leoyvens authored Aug 16, 2022
1 parent 354f4ed commit ba86fd6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
16 changes: 6 additions & 10 deletions core/src/subgraph/instance_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::subgraph::loader::load_dynamic_data_sources;
use crate::subgraph::runner::SubgraphRunner;
use crate::subgraph::SubgraphInstance;
use graph::blockchain::block_stream::BlockStreamMetrics;
use graph::blockchain::DataSource;
use graph::blockchain::NodeCapabilities;
use graph::blockchain::{Blockchain, DataSourceTemplate};
use graph::blockchain::{BlockchainKind, TriggerFilter};
Expand Down Expand Up @@ -187,18 +186,15 @@ impl<S: SubgraphStore> SubgraphInstanceManager<S> {
.await
.context("Failed to resolve subgraph from IPFS")?;

// We cannot include static data sources in the map because a static data source and a
// template may have the same name in the manifest.
let ds_len = manifest.data_sources.len() as u32;
let manifest_idx_and_name: Vec<(u32, String)> = manifest
.data_sources
.templates
.iter()
.map(|ds: &C::DataSource| ds.name().to_owned())
.chain(
manifest
.templates
.iter()
.map(|t: &C::DataSourceTemplate| t.name().to_owned()),
)
.map(|t: &C::DataSourceTemplate| t.name().to_owned())
.enumerate()
.map(|(idx, name)| (idx as u32, name))
.map(|(idx, name)| (ds_len + idx as u32, name))
.collect();

let data_sources = load_dynamic_data_sources(
Expand Down
7 changes: 5 additions & 2 deletions store/postgres/src/dynds/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl DataSourcesTable {
))
.load::<Tuple>(conn)?;

Ok(tuples
let mut dses: Vec<_> = tuples
.into_iter()
.map(|(block_range, manifest_idx, param, context)| {
let creation_block = match block_range.0 {
Expand All @@ -112,7 +112,10 @@ impl DataSourcesTable {
creation_block,
}
})
.collect())
.collect();
dses.sort_by_key(|v| v.creation_block);

Ok(dses)
}

pub(crate) fn insert(
Expand Down

0 comments on commit ba86fd6

Please # to comment.