github.com/pdaian/flashboys2@v0.0.0-20190718175736-b101c35361f0/receipts.py (about)

     1  from gastoken import is_using_gastoken
     2  import binascii
     3  
     4  def hex2str(hex):
     5      return "0x" + binascii.hexlify(hex).decode("utf-8")
     6  
     7  def write_receipt(receipt, tx, loghandle):
     8      addrs = "~".join([log['address'] for log in receipt['logs']])
     9      topics = "~".join(["|".join([hex2str(x) for x in log['topics']]) for log in receipt['logs']])
    10      data = "~".join([log['data'] for log in receipt['logs']])
    11      gas_used = receipt['gasUsed']
    12      txhash = hex2str(tx['hash'])
    13      gastoken = -1
    14      #if gas_used < (0.6 * tx['gas']):
    15      #    gastoken = is_using_gastoken(txhash)
    16      gastoken = -200 # TODO fix this check
    17      loghandle.write(str(receipt['blockNumber']) + ","  + str(receipt['transactionIndex']) + "," + str(tx['gas']) + "," + str(tx['gasPrice']) + "," + str(gas_used) + "," + str(tx['from']) + ","+ str(tx['to']) + ","+ str(tx['input']) + ","+ txhash + "," + addrs + "," + topics + "," + data + "," + str(gastoken) + "\n")
    18