Add tx normalizer docstring
This commit is contained in:
parent
7e3d9630ce
commit
3b990a9a87
@ -8,30 +8,30 @@ from hexathon import (
|
|||||||
uniform as hex_uniform,
|
uniform as hex_uniform,
|
||||||
)
|
)
|
||||||
|
|
||||||
logg = logging.getLogger(__name__)
|
logg = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
class TxHexNormalize:
|
class TxHexNormalizer:
|
||||||
|
|
||||||
def tx_hash(self, tx_hash):
|
def tx_hash(self, tx_hash):
|
||||||
return self.__hex_normalize(tx_hash)
|
return self.__hex_normalize(tx_hash, 'tx hash')
|
||||||
|
|
||||||
|
|
||||||
def tx_wire(self, tx_wire):
|
def tx_wire(self, tx_wire):
|
||||||
return self.__hex_normalize(tx_wire)
|
return self.__hex_normalize(tx_wire, 'tx wire')
|
||||||
|
|
||||||
|
|
||||||
def wallet_address(self, address):
|
def wallet_address(self, address):
|
||||||
return self.__hex_normalize(address)
|
return self.__hex_normalize(address, 'wallet address')
|
||||||
|
|
||||||
|
|
||||||
def executable_address(self, address):
|
def executable_address(self, address):
|
||||||
return self.__hex_normalize(address)
|
return self.__hex_normalize(address, 'executable address')
|
||||||
|
|
||||||
|
|
||||||
def __hex_normalize(self, data):
|
def __hex_normalize(self, data, context):
|
||||||
r = add_0x(hex_uniform(strip_0x(data)))
|
r = add_0x(hex_uniform(strip_0x(data)))
|
||||||
logg.debug('tx hex normalize {} -> {}'.format(data, r))
|
logg.debug('normalize {} {} -> {}'.format(context, data, r))
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ from chainqueue.sql.state import (
|
|||||||
set_rejected,
|
set_rejected,
|
||||||
)
|
)
|
||||||
from chainqueue.sql.tx import cache_tx_dict
|
from chainqueue.sql.tx import cache_tx_dict
|
||||||
from chainqueue.encode import TxHexNormalize
|
from chainqueue.encode import TxHexNormalizer
|
||||||
|
|
||||||
logg = logging.getLogger(__name__)
|
logg = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -39,6 +39,8 @@ class SQLBackend:
|
|||||||
|
|
||||||
:param conn_spec: Backend-dependent connection specification string. See chainqueue.db.models.base.SessionBase.connect
|
:param conn_spec: Backend-dependent connection specification string. See chainqueue.db.models.base.SessionBase.connect
|
||||||
:type conn_spec: str
|
:type conn_spec: str
|
||||||
|
:param tx_normalizer: Transaction data normalizer
|
||||||
|
:type tx_normalizer: Object implementing chainqueue.encode.TxHexNormalizer interface
|
||||||
:param error_parser: Error parser to use for RPC calls within the backend component
|
:param error_parser: Error parser to use for RPC calls within the backend component
|
||||||
:type error_parser: Object implementing chainlib.error.DefaultErrorParser
|
:type error_parser: Object implementing chainlib.error.DefaultErrorParser
|
||||||
:param pool_size: Connection pool size for pool-capable sql engines. See chainqueue.db.models.base.SessionBase.connect
|
:param pool_size: Connection pool size for pool-capable sql engines. See chainqueue.db.models.base.SessionBase.connect
|
||||||
@ -47,16 +49,13 @@ class SQLBackend:
|
|||||||
:type debug: bool
|
:type debug: bool
|
||||||
:todo: define a backend abstract interface class
|
:todo: define a backend abstract interface class
|
||||||
"""
|
"""
|
||||||
|
|
||||||
#def __init__(self, conn_spec, error_parser=None, *args, **kwargs):
|
|
||||||
def __init__(self, conn_spec, tx_normalizer=None, error_parser=None, pool_size=0, debug=False, *args, **kwargs):
|
def __init__(self, conn_spec, tx_normalizer=None, error_parser=None, pool_size=0, debug=False, *args, **kwargs):
|
||||||
#SessionBase.connect(conn_spec, pool_size=kwargs.get('poolsize', 0), debug=kwargs.get('debug', False))
|
|
||||||
SessionBase.connect(conn_spec, pool_size=pool_size, debug=debug)
|
SessionBase.connect(conn_spec, pool_size=pool_size, debug=debug)
|
||||||
if error_parser == None:
|
if error_parser == None:
|
||||||
error_parser = DefaultErrorParser()
|
error_parser = DefaultErrorParser()
|
||||||
self.error_parser = error_parser
|
self.error_parser = error_parser
|
||||||
if tx_normalizer == None:
|
if tx_normalizer == None:
|
||||||
tx_normalizer = TxHexNormalize()
|
tx_normalizer = TxHexNormalizer()
|
||||||
self.tx_normalizer = tx_normalizer
|
self.tx_normalizer = tx_normalizer
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user