Advance nonce on gas token txs only

This commit is contained in:
lash 2022-04-29 06:30:12 +00:00
parent 8d0a1f589b
commit 097a6f4b53
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
4 changed files with 9 additions and 5 deletions

View File

@ -9,7 +9,7 @@ logg = logging.getLogger(__name__)
class BaseTokenResolver: class BaseTokenResolver:
def __init__(self, chain_spec, sender, signer, gas_oracle, nonce_oracle): def __init__(self, chain_spec, sender, signer, gas_oracle, nonce_oracle, advance_nonce=False):
self.chain_spec = chain_spec self.chain_spec = chain_spec
self.chain_id = chain_spec.chain_id() self.chain_id = chain_spec.chain_id()
self.signer = signer self.signer = signer
@ -19,6 +19,10 @@ class BaseTokenResolver:
self.factory = None self.factory = None
self.gas_limit_start = None self.gas_limit_start = None
self.gas_price_start = None self.gas_price_start = None
if advance_nonce:
self.nonce_getter = self.nonce_oracle.next_nonce
else:
self.nonce_getter = self.nonce_oracle.get_nonce
def reset(self): def reset(self):
@ -28,7 +32,7 @@ class BaseTokenResolver:
def get_values(self, gas_value, value, executable_address=None): def get_values(self, gas_value, value, executable_address=None):
nonce = self.nonce_oracle.get_nonce() nonce = self.nonce_getter()
if executable_address == None: if executable_address == None:
return (value, 0, nonce) return (value, 0, nonce)

View File

@ -9,7 +9,7 @@ from chaind.eth.token import BaseTokenResolver
class GasTokenResolver(BaseTokenResolver): class GasTokenResolver(BaseTokenResolver):
def __init__(self, chain_spec, sender, signer, gas_oracle, nonce_oracle): def __init__(self, chain_spec, sender, signer, gas_oracle, nonce_oracle):
super(GasTokenResolver, self).__init__(chain_spec, sender, signer, gas_oracle, nonce_oracle) super(GasTokenResolver, self).__init__(chain_spec, sender, signer, gas_oracle, nonce_oracle, advance_nonce=True)
self.factory = Gas(self.chain_spec, signer=self.signer, gas_oracle=self.gas_oracle, nonce_oracle=self.nonce_oracle) self.factory = Gas(self.chain_spec, signer=self.signer, gas_oracle=self.gas_oracle, nonce_oracle=self.nonce_oracle)

View File

@ -1,4 +1,4 @@
chaind~=0.1.1 chaind~=0.1.3
hexathon~=0.1.5 hexathon~=0.1.5
chainlib-eth~=0.1.1 chainlib-eth~=0.1.1
pyxdg~=0.27 pyxdg~=0.27

View File

@ -1,6 +1,6 @@
[metadata] [metadata]
name = chaind-eth name = chaind-eth
version = 0.1.4 version = 0.1.5
description = Queue server for ethereum description = Queue server for ethereum
author = Louis Holbrook author = Louis Holbrook
author_email = dev@holbrook.no author_email = dev@holbrook.no