eth-monitor/eth_monitor/filters/gas/__init__.py

24 lines
680 B
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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.status.name, tx.outputs[0], tx.inputs[0], value)
result.set(s)
return False