chainlib

Generic blockchain access library and tooling
Log | Files | Refs | README | LICENSE

commit 20c3904e721490d115308a9c0569729bfa49844a
parent 91228b093e255c4f11c641ab597b4ceeaa810c6f
Author: lash <dev@holbrook.no>
Date:   Sat,  3 Jun 2023 08:33:50 +0100

Add dialect filter in chain interface initialization

Diffstat:
Mchainlib/interface.py | 5+++--
Mchainlib/settings.py | 1+
Mchainlib/src.py | 4++--
Msetup.cfg | 2+-
4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/chainlib/interface.py b/chainlib/interface.py @@ -20,7 +20,7 @@ class ChainInterface: raise NotImplementedError() - def __init__(self): + def __init__(self, dialect_filter=None): self._block_latest = self.__unimplemented self._block_by_hash = self.__unimplemented self._block_by_number = self.__unimplemented @@ -37,6 +37,7 @@ class ChainInterface: self._address_safe = self.__unimplemented self._address_normal = self.__unimplemented self._src_normalize = self.__unimplemented + self._dialect_filter = dialect_filter def block_latest(self, *args, **kwargs): @@ -84,7 +85,7 @@ class ChainInterface: :rtype: chainlib.block.Block :returns: Block object """ - return self._block_from_src(src) + return self._block_from_src(src, dialect_filter=self._dialect_filter) def block_to_src(self, block): diff --git a/chainlib/settings.py b/chainlib/settings.py @@ -31,6 +31,7 @@ class ChainSettings: def process_settings_dialect(settings, config): + settings.set('RPC_DIALECT_FILTER', None) if config.get('RPC_DIALECT') != 'default': import importlib m = importlib.import_module(config.get('RPC_DIALECT')) diff --git a/chainlib/src.py b/chainlib/src.py @@ -75,7 +75,7 @@ class Src: @classmethod - def from_src(cls, src): + def from_src(cls, src, dialect_filter=None): """Instantiate an implementation specific block object from the given block representation. :param src: Block representation @@ -83,7 +83,7 @@ class Src: :rtype: chainlib.block.Block :returns: Block object """ - return cls(src) + return cls(src, dialect_filter=dialect_filter) def __repr__(self): diff --git a/setup.cfg b/setup.cfg @@ -3,7 +3,7 @@ name=chainlib license=AGPLv3+ author_email=dev@holbrook.no description=Generic blockchain access library and tooling -version=0.4.14 +version=0.4.15 url=https://git.defalsify.org/chainlib author=Louis Holbrook