Update monitor check-all script to generate stuckTransfers statistics for v1 bridges (#279)
This commit is contained in:
parent
c408d57716
commit
fe4a569e34
@ -1,19 +1,27 @@
|
|||||||
|
const Web3 = require('web3')
|
||||||
const logger = require('./logger')('checkWorker3')
|
const logger = require('./logger')('checkWorker3')
|
||||||
const stuckTransfers = require('./stuckTransfers')
|
const stuckTransfers = require('./stuckTransfers')
|
||||||
const { writeFile, createDir } = require('./utils/file')
|
const { writeFile, createDir } = require('./utils/file')
|
||||||
|
|
||||||
const { MONITOR_BRIDGE_NAME } = process.env
|
const { MONITOR_BRIDGE_NAME, COMMON_HOME_BRIDGE_ADDRESS, COMMON_HOME_RPC_URL } = process.env
|
||||||
|
const { getBridgeMode, HOME_NATIVE_TO_ERC_ABI, BRIDGE_MODES } = require('../commons')
|
||||||
|
|
||||||
|
const homeProvider = new Web3.providers.HttpProvider(COMMON_HOME_RPC_URL)
|
||||||
|
const web3Home = new Web3(homeProvider)
|
||||||
|
|
||||||
async function checkWorker3() {
|
async function checkWorker3() {
|
||||||
try {
|
try {
|
||||||
|
const homeBridge = new web3Home.eth.Contract(HOME_NATIVE_TO_ERC_ABI, COMMON_HOME_BRIDGE_ADDRESS)
|
||||||
|
const bridgeMode = await getBridgeMode(homeBridge)
|
||||||
|
if (bridgeMode === BRIDGE_MODES.NATIVE_TO_ERC_V1) {
|
||||||
createDir(`/responses/${MONITOR_BRIDGE_NAME}`)
|
createDir(`/responses/${MONITOR_BRIDGE_NAME}`)
|
||||||
logger.debug('calling stuckTransfers()')
|
logger.debug('calling stuckTransfers()')
|
||||||
const transfers = await stuckTransfers()
|
const transfers = await stuckTransfers()
|
||||||
// console.log(transfers)
|
|
||||||
if (!transfers) throw new Error('transfers is empty: ' + JSON.stringify(transfers))
|
if (!transfers) throw new Error('transfers is empty: ' + JSON.stringify(transfers))
|
||||||
transfers.ok = transfers.total.length === 0
|
transfers.ok = transfers.total.length === 0
|
||||||
writeFile(`/responses/${MONITOR_BRIDGE_NAME}/stuckTransfers.json`, transfers)
|
writeFile(`/responses/${MONITOR_BRIDGE_NAME}/stuckTransfers.json`, transfers)
|
||||||
logger.debug('Done')
|
logger.debug('Done')
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error('checkWorker3.js', e)
|
logger.error('checkWorker3.js', e)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"check-all": "timeout -s 9 5m node checkWorker.js && timeout -s 9 5m node checkWorker2.js",
|
"check-all": "timeout -s 9 5m node checkWorker.js && timeout -s 9 5m node checkWorker2.js && timeout -s 9 5m node checkWorker3.js",
|
||||||
"start": "node index.js",
|
"start": "node index.js",
|
||||||
"check-and-start": "yarn check-all && yarn start",
|
"check-and-start": "yarn check-all && yarn start",
|
||||||
"lint": "eslint . --ignore-path ../.eslintignore",
|
"lint": "eslint . --ignore-path ../.eslintignore",
|
||||||
|
Loading…
Reference in New Issue
Block a user