@@ -10,7 +10,7 @@ use graph::{
1010 blockchain:: ChainIdentifier ,
1111 components:: store:: { BlockStore as BlockStoreTrait , QueryPermit } ,
1212 derive:: CheapClone ,
13- prelude:: { error, info, BlockNumber , BlockPtr , Logger , ENV_VARS } ,
13+ prelude:: { error, info, warn , BlockNumber , BlockPtr , Logger , ENV_VARS } ,
1414 slog:: o,
1515} ;
1616use graph:: {
@@ -37,14 +37,6 @@ pub const FAKE_NETWORK_SHARED: &str = "fake_network_shared";
3737// To be incremented on each breaking change to the database.
3838const SUPPORTED_DB_VERSION : i64 = 3 ;
3939
40- /// The status of a chain: whether we can only read from the chain, or
41- /// whether it is ok to ingest from it, too
42- #[ derive( Copy , Clone ) ]
43- pub enum ChainStatus {
44- ReadOnly ,
45- Ingestible ,
46- }
47-
4840pub mod primary {
4941 use std:: convert:: TryFrom ;
5042
@@ -278,39 +270,22 @@ impl BlockStore {
278270 } ) ;
279271 let block_store = Self { inner } ;
280272
281- /// Check that the configuration for `chain` hasn't changed so that
282- /// it is ok to ingest from it
283- fn chain_ingestible (
284- logger : & Logger ,
285- chain : & primary:: Chain ,
286- shard : & Shard ,
287- // ident: &ChainIdentifier,
288- ) -> bool {
289- if & chain. shard != shard {
290- error ! (
291- logger,
292- "the chain {} is stored in shard {} but is configured for shard {}" ,
293- chain. name,
294- chain. shard,
295- shard
296- ) ;
297- return false ;
298- }
299- true
300- }
301-
302273 // For each configured chain, add a chain store
303274 for ( chain_name, shard) in chains {
304275 if let Some ( chain) = existing_chains
305276 . iter ( )
306277 . find ( |chain| chain. name == chain_name)
307278 {
308- let status = if chain_ingestible ( & block_store. logger , chain, & shard) {
309- ChainStatus :: Ingestible
310- } else {
311- ChainStatus :: ReadOnly
312- } ;
313- block_store. add_chain_store ( chain, status, false ) . await ?;
279+ if chain. shard != shard {
280+ warn ! (
281+ & block_store. logger,
282+ "The chain `{0}` is stored in shard `{1}` but is configured for shard `{2}`; ignoring config and using shard `{1}`" ,
283+ chain. name,
284+ chain. shard,
285+ shard,
286+ ) ;
287+ }
288+ block_store. add_chain_store ( chain, false ) . await ?;
314289 } ;
315290 }
316291
@@ -326,9 +301,7 @@ impl BlockStore {
326301 . iter ( )
327302 . filter ( |chain| !configured_chains. contains ( & chain. name ) )
328303 {
329- block_store
330- . add_chain_store ( chain, ChainStatus :: ReadOnly , false )
331- . await ?;
304+ block_store. add_chain_store ( chain, false ) . await ?;
332305 }
333306 Ok ( block_store)
334307 }
@@ -376,7 +349,6 @@ impl BlockStore {
376349 pub async fn add_chain_store (
377350 & self ,
378351 chain : & primary:: Chain ,
379- status : ChainStatus ,
380352 create : bool ,
381353 ) -> Result < Arc < ChainStore > , StoreError > {
382354 let pool = self
@@ -395,7 +367,6 @@ impl BlockStore {
395367 logger,
396368 chain. name . clone ( ) ,
397369 chain. storage . clone ( ) ,
398- status,
399370 sender,
400371 pool,
401372 ENV_VARS . store . recent_blocks_cache_capacity ,
@@ -457,9 +428,7 @@ impl BlockStore {
457428 async {
458429 match primary:: find_chain ( conn, & chain) . await ? {
459430 Some ( chain) => {
460- let chain_store = this
461- . add_chain_store ( & chain, ChainStatus :: ReadOnly , false )
462- . await ?;
431+ let chain_store = this. add_chain_store ( & chain, false ) . await ?;
463432 Ok ( Some ( chain_store) )
464433 }
465434 None => Ok ( None ) ,
@@ -605,7 +574,7 @@ impl BlockStore {
605574 } )
606575 . ok_or_else ( || anyhow ! ( "unable to find shard for network {}" , network) ) ?;
607576 let chain = primary:: add_chain ( & mut conn, network, shard, ident) . await ?;
608- self . add_chain_store ( & chain, ChainStatus :: Ingestible , true )
577+ self . add_chain_store ( & chain, true )
609578 . await
610579 . map_err ( anyhow:: Error :: from)
611580 }
0 commit comments