eth-gas-sum

Sync a running total of gas usage across EVM blocks
git clone git://holbrook.no/ethd-gas-sum.git
Log | Files | Refs

commit 618471fcc56b1f0f4382452804b7245b9a02bd4e
parent 674b5b9ae0d97ef81575fc362d31ae548bd23d37
Author: lash <dev@holbrook.no>
Date:   Sat,  5 Mar 2022 07:37:28 +0000

Upgrade deps

Diffstat:
Meth_gas_sum/runnable/sum.py | 22++++++++++++----------
Mrequirements.txt | 4++--
2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/eth_gas_sum/runnable/sum.py b/eth_gas_sum/runnable/sum.py @@ -74,21 +74,23 @@ class GasAddFilter: self.recipients = recipients self.tx_gas = {} self.gas_sum = 0 + self.match_label = None + if len(senders) == 0 and len(recipients) == 0: + self.match_label = 'match' def filter(self, conn, block, tx, db_session): sender = hex_uniform(strip_0x(tx.outputs[0])) recipient = hex_uniform(strip_0x(tx.inputs[0])) - if sender in self.senders: - self.gas_sum += tx.gas_used - self.tx_gas[tx.hash] = tx.gas_used - logg.info('sender {} tx {} ({}/{}) gas {} new sum {}'.format(sender, tx.hash, tx.block.number, tx.index, tx.gas_used, self.gas_sum)) - elif recipient in self.recipients: - self.gas_sum += tx.gas_used - self.tx_gas[tx.hash] = tx.gas_used - logg.info('recipient {} tx {} ({}/{}) gas {} new sum {}'.format(recipient, tx.hash, tx.block.number, tx.index, tx.gas_used, self.gas_sum)) - - + match_label = self.match_label + if match_label == None: + if sender in self.senders: + match_label = 'sender ' + sender + elif recipient in self.recipients: + match_label = 'recipient ' + receipient + self.gas_sum += tx.gas_used + self.tx_gas[tx.hash] = tx.gas_used + logg.info('{} tx {} ({}/{}) gas {} new sum {}'.format(match_label, tx.hash, tx.block.number, tx.index, tx.gas_used, self.gas_sum)) def sum(self): return self.gas_sum diff --git a/requirements.txt b/requirements.txt @@ -1,2 +1,2 @@ -chainsyncer==0.0.7a3 -chainlib-eth==0.0.10a16 +chainsyncer~=0.1.0 +chainlib-eth>=0.1.0b1,<=0.1.0