commit cf59efa690f5417ca443e7c8a6ab886d3a8958b6
parent 5127561b1f6363d7b91dfb7c3d9adf9a4440543f
Author: lash <dev@holbrook.no>
Date:   Mon, 28 Feb 2022 22:22:20 +0000
Add vanilla gas transfer filter
Diffstat:
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/eth_monitor/filters/gas/__init__.py 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
@@ -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
@@ -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