datasource/ethereum: Log loading message when block ingestor is far behind
@@ -75,6 +75,29 @@ where
fn do_poll<'a>(&'a self) -> impl Future<Item = (), Error = Error> + 'a {
// Ask for latest block from Ethereum node
self.get_latest_block()
+ .and_then(move |latest_block: Block<Transaction>| {
+ // Check how far behind we are and (possibly) tell the user
+ self.store
+ .chain_head_ptr()
+ .map(move |head_block_ptr_opt| {
+ match head_block_ptr_opt {
+ None => {
+ info!(self.logger, "Downloading latest blocks from Ethereum. This may take a few minutes...");
+ }
+ Some(head_block_ptr) => {
+ let latest_number = latest_block.number.unwrap().as_u64() as i64;
+ let head_number = head_block_ptr.number as i64;
+ let distance = latest_number - head_number;
+ if distance > 10 && distance <= 50 {
+ info!(self.logger, "Downloading latest blocks from Ethereum. This may take a few seconds...");
+ } else if distance > 50 {
+ info!(self.logger, "Downloading latest blocks from Ethereum. This may take a few minutes...");
+ }
+ }
+ }
+ latest_block
+ })
+ })
.and_then(move |latest_block: Block<Transaction>| {
// Store latest block in block store.
// Might be a no-op if latest block is one that we have seen.
