tools/setup/geth_checker.js
function(chain) {
    const retryAttempts = 100
      , timerInterval = 5000
      , chainTimer = {timer: undefined, blockNumber: 0, retryCounter: 0}
      , provider = (chain == 'utility' ? web3UtilityProvider : web3ValueProvider)
    ;
    return new Promise(function (onResolve, onReject) {
      chainTimer['timer'] = setInterval(function () {
        if (chainTimer['retryCounter'] <= retryAttempts) {
          provider.eth.getBlockNumber(function (err, blocknumber) {
            if (err) {
            } else {
              if (chainTimer['blockNumber']!=0 && chainTimer['blockNumber']!=blocknumber) {
                logger.info("* Geth Checker - " + chain + " chain has new blocks.");
                clearInterval(chainTimer['timer']);
                onResolve();
              }
              chainTimer['blockNumber'] = blocknumber;
            }
          });
        } else {
          logger.error("Geth Checker - " + chain + " chain has no new blocks.");
          onReject();
          process.exit(1);
        }
        chainTimer['retryCounter']++;
      }, timerInterval);
    });
  }
function(chain) {
    const retryAttempts = 100
      , timerInterval = 5000
      , chainTimer = {timer: undefined, blockNumber: 0, retryCounter: 0}
      , provider = (chain == 'utility' ? web3UtilityProvider : web3ValueProvider)
    ;
    return new Promise(function (onResolve, onReject) {
      chainTimer['timer'] = setInterval(function () {
        if (chainTimer['retryCounter'] <= retryAttempts) {
          provider.eth.getBlockNumber(function (err, blocknumber) {
            if (err) {
            } else {
              if (chainTimer['blockNumber']!=0 && chainTimer['blockNumber']!=blocknumber) {
                logger.info("* Geth Checker - " + chain + " chain has new blocks.");
                clearInterval(chainTimer['timer']);
                onResolve();
              }
              chainTimer['blockNumber'] = blocknumber;
            }
          });
        } else {
          logger.error("Geth Checker - " + chain + " chain has no new blocks.");
          onReject();
          process.exit(1);
        }
        chainTimer['retryCounter']++;
      }, timerInterval);
    });
  }
function ( chain ) { const retryAttempts = 100 , timerInterval = 5000 , chainTimer = { timer : undefined , blockNumber : 0 , retryCounter : 0 } , provider = ( chain == 'utility' ? web3UtilityProvider : web3ValueProvider ) ; return new Promise ( function ( onResolve , onReject ) { chainTimer [ 'timer' ] = setInterval ( function ( ) { if ( chainTimer [ 'retryCounter' ] <= retryAttempts ) { provider . eth . getBlockNumber ( function ( err , blocknumber ) { if ( err ) { } else { if ( chainTimer [ 'blockNumber' ] != 0 && chainTimer [ 'blockNumber' ] != blocknumber ) { logger . info ( "* Geth Checker - " + chain + " chain has new blocks." ) ; clearInterval ( chainTimer [ 'timer' ] ) ; onResolve ( ) ; } chainTimer [ 'blockNumber' ] = blocknumber ; } } ) ; } else { logger . error ( "Geth Checker - " + chain + " chain has no new blocks." ) ; onReject ( ) ; process . exit ( 1 ) ; } chainTimer [ 'retryCounter' ] ++ ; } , timerInterval ) ; } ) ; }
Check if mentioned chain started mining and are ready

@param {string} chain - name of the chain

@return {promise}
Check if mentioned chain started mining and are ready