@@ -13,7 +13,7 @@ use graph::firehose::{FirehoseEndpoint, ForkStep};
1313use graph:: futures03:: TryStreamExt ;
1414use graph:: prelude:: {
1515 retry, BlockHash , ComponentLoggerConfig , ElasticComponentLoggerConfig , EthereumBlock ,
16- EthereumCallCache , LightEthereumBlock , LightEthereumBlockExt , MetricsRegistry ,
16+ EthereumCallCache , LightEthereumBlock , LightEthereumBlockExt , MetricsRegistry , StoreError ,
1717} ;
1818use graph:: schema:: InputSchema ;
1919use graph:: slog:: { debug, error, trace, warn} ;
@@ -175,7 +175,7 @@ impl BlockStreamBuilder<Chain> for EthereumStreamBuilder {
175175 . logger_factory
176176 . subgraph_logger ( & deployment)
177177 . new ( o ! ( "component" => "BlockStream" ) ) ;
178- let chain_store = chain. chain_store ( ) ;
178+ let chain_store = chain. chain_store . cheap_clone ( ) ;
179179 let chain_head_update_stream = chain
180180 . chain_head_update_listener
181181 . subscribe ( chain. name . to_string ( ) , logger. clone ( ) ) ;
@@ -403,6 +403,13 @@ impl Chain {
403403 self . call_cache . clone ( )
404404 }
405405
406+ pub async fn block_number (
407+ & self ,
408+ hash : & BlockHash ,
409+ ) -> Result < Option < ( String , BlockNumber , Option < u64 > , Option < BlockHash > ) > , StoreError > {
410+ self . chain_store . block_number ( hash) . await
411+ }
412+
406413 // TODO: This is only used to build the block stream which could prolly
407414 // be moved to the chain itself and return a block stream future that the
408415 // caller can spawn.
@@ -507,8 +514,8 @@ impl Blockchain for Chain {
507514 }
508515 }
509516
510- fn chain_store ( & self ) -> Arc < dyn ChainStore > {
511- self . chain_store . clone ( )
517+ async fn chain_head_ptr ( & self ) -> Result < Option < BlockPtr > , Error > {
518+ self . chain_store . cheap_clone ( ) . chain_head_ptr ( ) . await
512519 }
513520
514521 async fn block_pointer_from_number (
@@ -615,7 +622,7 @@ impl Blockchain for Chain {
615622 logger,
616623 graph:: env:: ENV_VARS . reorg_threshold ( ) ,
617624 self . chain_client ( ) ,
618- self . chain_store ( ) . cheap_clone ( ) ,
625+ self . chain_store . cheap_clone ( ) ,
619626 self . polling_ingestor_interval ,
620627 self . name . clone ( ) ,
621628 ) ?)
0 commit comments