eth-gas-proxy

Middleware to selectively override EVM gas heuristics
git clone git://holbrook.no/eth-gas-proxy.git
Info | Log | Files | Refs

test.py (541B)


      1 import logging
      2 import time
      3 
      4 import web3
      5 import websocket
      6 
      7 from gas_proxy.web3 import GasMiddleware
      8 
      9 logging.basicConfig(level=logging.DEBUG)
     10 logg = logging.getLogger()
     11 
     12 re_websocket = r'wss?://'
     13 
     14 def socket_constructor():
     15     return websocket.create_connection('ws://localhost:8545')
     16 
     17 GasMiddleware.socket_constructor = socket_constructor
     18 GasMiddleware.last_gas = "0x1000"
     19 
     20 w3 = web3.Web3(web3.Web3.WebsocketProvider('ws://localhost:8545'))
     21 w3.middleware_onion.add(GasMiddleware)
     22 
     23 while True:
     24     print(w3.eth.gas_price())
     25     time.sleep(1)