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

     1  from web3 import Web3
     2  import csv, csv_hack, time
     3  from receipts import write_receipt
     4  
     5  my_provider = Web3.IPCProvider('/home/geth/parity_mainnet/jsonrpc.ipc', timeout=60)
     6  w3 = Web3(my_provider)
     7  
     8  bidder_txs = []
     9  
    10  print("Preprocessing phase 1 done!")
    11  
    12  bidsdict = csv.DictReader(open('data/all_success_arb_txs_bigquery.csv'))
    13  for bid in bidsdict:
    14      bidder_txs.append(bid['transaction_hash'])
    15  
    16  print("Preprocessing phase 2 done!")
    17  
    18  bidsdict = csv.DictReader(open('data/arb_receipts.csv'))
    19  for bid in bidsdict:
    20      bidder_txs.remove(bid['hash'])
    21  
    22  print("Preprocessing done!")
    23  
    24  f = open('data/arb_receipts.csv', 'a')
    25  #f.write("block_num,tx_position,gas_limit,gas_price,gas_used,from,to,input,hash,log_addrs,log_topics,log_data,gastoken\n")
    26  
    27  i = 0
    28  curr_time = time.time()
    29  
    30  for txhash in bidder_txs:
    31      print(txhash)
    32      receipt = w3.eth.getTransactionReceipt(txhash)
    33      tx = w3.eth.getTransaction(txhash)
    34      i += 1
    35      if (i % 10) == 0:
    36          print(i, "processed", time.time() - curr_time)
    37          curr_time = time.time()
    38      if receipt is None:
    39          continue
    40      write_receipt(receipt, tx, f)