From 2b2a7797160f7bba6afa700053a778e3230e4ecf Mon Sep 17 00:00:00 2001 From: Kosta Korenkov Date: Mon, 4 Dec 2017 18:02:02 +0300 Subject: [PATCH] add rinkeby network support --- README.md | 5 +++++ index.js | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 800cc1b..b335d21 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,11 @@ wget https://raw.githubusercontent.com/acebusters/geth-healthcheck/master/index. ETHERSCAN_API_KEY= PORT=50336 node index.js ``` +for rinkeby network: +``` +ETHERSCAN_API_KEY= PORT=50336 NETWORK=rinkeby node index.js +``` + Make sure it is detached from the terminal. Make sure the port is open for incoming connections. ## License diff --git a/index.js b/index.js index 2f495ce..7ba1094 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,9 @@ const http = require('http'); const https = require('https'); const { exec } = require('child_process'); -const ETHERSCAN_URL = `https://api.etherscan.io/api?module=proxy&action=eth_blockNumber&apikey=${process.env.ETHERSCAN_API_KEY}`; +const etherscanPrefix = process.env.NETWORK == 'rinkeby' ? 'rinkeby' : 'api'; + +const ETHERSCAN_URL = `https://${etherscanPrefix}.etherscan.io/api?module=proxy&action=eth_blockNumber&apikey=${process.env.ETHERSCAN_API_KEY}`; const MAX_BLOCK_DIFFERENCE = 3; const getLocalBlockNum = () => {