tokenbridge/monitor/getShortEventStats.js

42 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-05-08 16:12:02 +03:00
require('dotenv').config()
const eventsInfo = require('./utils/events')
2019-10-21 15:57:28 +03:00
const { BRIDGE_MODES } = require('../commons')
2019-05-08 16:12:02 +03:00
async function main(bridgeMode) {
2019-10-21 15:57:28 +03:00
const {
homeToForeignConfirmations,
homeToForeignRequests,
foreignToHomeConfirmations,
foreignToHomeRequests
} = await eventsInfo(bridgeMode)
2019-05-08 16:12:02 +03:00
2019-10-21 15:57:28 +03:00
if (bridgeMode === BRIDGE_MODES.ARBITRARY_MESSAGE) {
return {
fromHomeToForeignDiff: homeToForeignRequests.length - homeToForeignConfirmations.length,
fromForeignToHomeDiff: foreignToHomeConfirmations.length - foreignToHomeRequests.length,
home: {
toForeign: homeToForeignRequests.length,
fromForeign: foreignToHomeConfirmations.length
},
foreign: {
fromHome: homeToForeignConfirmations.length,
toHome: foreignToHomeRequests.length
}
}
} else {
return {
depositsDiff: homeToForeignRequests.length - homeToForeignConfirmations.length,
withdrawalDiff: foreignToHomeConfirmations.length - foreignToHomeRequests.length,
home: {
deposits: homeToForeignRequests.length,
withdrawals: foreignToHomeConfirmations.length
},
foreign: {
deposits: homeToForeignConfirmations.length,
withdrawals: foreignToHomeRequests.length
}
2019-05-08 16:12:02 +03:00
}
}
}
module.exports = main