feat: add infura web3 call logging
This commit is contained in:
parent
c94d767f0b
commit
404b87a64b
1 changed files with 15 additions and 1 deletions
|
|
@ -7,9 +7,10 @@ const hdkey = require('ethereumjs-wallet/hdkey')
|
|||
const Tx = require('ethereumjs-tx')
|
||||
const util = require('ethereumjs-util')
|
||||
const coins = require('@lamassu/coins')
|
||||
const pify = require('pify')
|
||||
const _pify = require('pify')
|
||||
const BN = require('../../../bn')
|
||||
const ABI = require('../../tokens')
|
||||
const logger = require('../../../logger')
|
||||
|
||||
const NAME = 'geth'
|
||||
exports.SUPPORTED_MODULES = ['wallet']
|
||||
|
|
@ -34,6 +35,19 @@ module.exports = {
|
|||
checkBlockchainStatus
|
||||
}
|
||||
|
||||
const infuraCalls = {}
|
||||
|
||||
const pify = _function => {
|
||||
if (_.isString(_function.call)) logInfuraCall(_function.call)
|
||||
return _pify(_function)
|
||||
}
|
||||
|
||||
const logInfuraCall = call => {
|
||||
if (!_.includes('infura', web3.currentProvider.host)) return
|
||||
_.isNil(infuraCalls[call]) ? infuraCalls[call] = 1 : infuraCalls[call]++
|
||||
logger.info(`Calling web3 method ${call} via Infura. Current count for this session: ${JSON.stringify(infuraCalls)}`)
|
||||
}
|
||||
|
||||
function connect (url) {
|
||||
if (!web3.isConnected()) {
|
||||
web3.setProvider(new web3.providers.HttpProvider(url))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue