Skip to content

Commit

Permalink
Add modifiable poll latency when waiting for transaction receipt, def…
Browse files Browse the repository at this point in the history
…ault to 5 seconds instead of 0.1
  • Loading branch information
rbval committed May 31, 2020
1 parent 11eba10 commit 6109b2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ COPY yarn.lock /work/
RUN yarn

COPY Pipfile Pipfile.lock /work/
RUN pip3 install pipenv

# Pin to specific version that's guaranteed to work
RUN pip3 install 'pipenv==2018.11.26'
RUN pipenv install --system --deploy

RUN python3 -m solc.install v0.4.24
Expand Down
7 changes: 6 additions & 1 deletion hmt_escrow/eth_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from web3 import Web3, HTTPProvider, EthereumTesterProvider
from web3.contract import Contract
from web3.middleware import geth_poa_middleware
from web3.utils.transactions import wait_for_transaction_receipt
from hmt_escrow.kvstore_abi import abi as kvstore_abi
from typing import Dict, List, Tuple, Optional, Any

Expand All @@ -31,6 +32,7 @@
KVSTORE_CONTRACT = Web3.toChecksumAddress(
os.getenv("KVSTORE_CONTRACT",
"0xbcF8274FAb0cbeD0099B2cAFe862035a6217Bf44"))
WEB3_POLL_LATENCY = os.getenv("WEB3_POLL_LATENCY", 5)


def get_w3() -> Web3:
Expand Down Expand Up @@ -110,7 +112,10 @@ def handle_transaction(txn_func, *args, **kwargs) -> AttributeDict:
txn_hash = w3.eth.sendRawTransaction(signed_txn.rawTransaction)

try:
txn_receipt = w3.eth.waitForTransactionReceipt(txn_hash, timeout=240)
txn_receipt = wait_for_transaction_receipt(w3,
txn_hash,
timeout=240,
poll_latency=5)
except TimeoutError as e:
raise e
return txn_receipt
Expand Down

0 comments on commit 6109b2f

Please sign in to comment.