Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Dynamic data sources hotfixes #3851

Merged
merged 1 commit into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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