From cf59efa690f5417ca443e7c8a6ab886d3a8958b6 Mon Sep 17 00:00:00 2001 From: lash Date: Mon, 28 Feb 2022 22:22:20 +0000 Subject: [PATCH] Add vanilla gas transfer filter --- eth_monitor/filters/gas/__init__.py | 22 ++++++++++++++++++++++ eth_monitor/index.py | 1 + eth_monitor/runnable/list.py | 1 - 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 eth_monitor/filters/gas/__init__.py diff --git a/eth_monitor/filters/gas/__init__.py b/eth_monitor/filters/gas/__init__.py new file mode 100644 index 0000000..1ac7f8b --- /dev/null +++ b/eth_monitor/filters/gas/__init__.py @@ -0,0 +1,22 @@ +# standard imports +import datetime +import logging + +logg = logging.getLogger(__name__) + + +def apply(c, result, chain_spec, conn, block, tx, db_session=None): + timestamp = datetime.datetime.fromtimestamp(block.timestamp) + value = str(tx.value) + if len(value) < 19: + value = '{:018d}'.format(tx.value) + value = '0.' + value + else: + ridx = len(value) - 18 + value = '{}.{}'.format(value[:ridx], value[ridx:]) + value = value.rstrip('0') + if value[len(value)-1] == '.': + value += '0' + s = '{} {}\t{} -> {} = {}'.format(timestamp, tx.hash, tx.outputs[0], tx.inputs[0], value) + result.set(s) + return False diff --git a/eth_monitor/index.py b/eth_monitor/index.py index 255a252..2146554 100644 --- a/eth_monitor/index.py +++ b/eth_monitor/index.py @@ -47,6 +47,7 @@ class AddressIndex: ks = list(txs.keys()) ks.sort() + ks.reverse() for k in ks: self.addresses[address].append(txs[k]) diff --git a/eth_monitor/runnable/list.py b/eth_monitor/runnable/list.py index 74abe90..0b25348 100644 --- a/eth_monitor/runnable/list.py +++ b/eth_monitor/runnable/list.py @@ -82,7 +82,6 @@ if os.environ.get('RPC_AUTHENTICATION') == 'basic': rpc = EthHTTPConnection(args.p) - def main(): store = FileStore(chain_spec, config.get('_CACHE_DIR')) use_rpc = rpc