wrap try/finally around populateTransaction logic to ensure the lock is always released in the case of an error
This commit is contained in:
parent
2428b756d6
commit
16b28f4535
|
@ -103,6 +103,7 @@ method populateTransaction*(signer: Signer,
|
||||||
|
|
||||||
var populated = transaction
|
var populated = transaction
|
||||||
|
|
||||||
|
try:
|
||||||
if transaction.sender.isNone:
|
if transaction.sender.isNone:
|
||||||
populated.sender = some(await signer.getAddress())
|
populated.sender = some(await signer.getAddress())
|
||||||
if transaction.chainId.isNone:
|
if transaction.chainId.isNone:
|
||||||
|
@ -122,8 +123,6 @@ method populateTransaction*(signer: Signer,
|
||||||
let e = getCurrentException()
|
let e = getCurrentException()
|
||||||
signer.decreaseNonce()
|
signer.decreaseNonce()
|
||||||
raise e
|
raise e
|
||||||
finally:
|
|
||||||
signer.populateLock.release()
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if transaction.nonce.isNone:
|
if transaction.nonce.isNone:
|
||||||
|
@ -131,6 +130,9 @@ method populateTransaction*(signer: Signer,
|
||||||
if transaction.gasLimit.isNone:
|
if transaction.gasLimit.isNone:
|
||||||
populated.gasLimit = some(await signer.estimateGas(populated))
|
populated.gasLimit = some(await signer.estimateGas(populated))
|
||||||
|
|
||||||
|
finally:
|
||||||
|
signer.populateLock.release()
|
||||||
|
|
||||||
return populated
|
return populated
|
||||||
|
|
||||||
method cancelTransaction*(
|
method cancelTransaction*(
|
||||||
|
|
Loading…
Reference in New Issue