chainlib

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

commit 37d012c1ca21e702eb631b6fd171fa1106d501da
parent 7c73288dbfdbf5bc64b5bdfa303fb6406d86ae61
Author: lash <dev@holbrook.no>
Date:   Sun, 13 Aug 2023 17:50:49 +0100

Expose dialect filter in chain interface structure

Diffstat:
MCHANGELOG | 4++++
Mchainlib/block.py | 8++++++--
Mchainlib/interface.py | 6+++---
Mchainlib/src.py | 2--
Mchainlib/tx.py | 6+++++-
Msetup.cfg | 2+-
6 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG @@ -1,3 +1,7 @@ +- 0.5.2 + * Expose dialect filter property in chain interface + * Pass dialect filter to from_src methods in chain interface + * Add aiee arg flag generation script - 0.5.1 * Add man page entry for batch requests. - 0.5.0 diff --git a/chainlib/block.py b/chainlib/block.py @@ -38,7 +38,7 @@ class Block(Src): self.load_src(dialect_filter=dialect_filter) - def tx_by_index(self, idx): + def tx_by_index(self, idx, dialect_filter=None): """Return transaction object for transaction data at given index. :param idx: Transaction index @@ -46,7 +46,11 @@ class Block(Src): :rtype: chainlib.tx.Tx :returns: Transaction object """ - return self.tx_generator(self.txs[idx], self) + return self.tx_generator(self.txs[idx], self, dialect_filter=dialect_filter) + + + def tx_src_by_index(self, idx): + return self.txs[idx] def tx_index_by_hash(self, hsh): diff --git a/chainlib/interface.py b/chainlib/interface.py @@ -22,6 +22,7 @@ class ChainInterface: def __init__(self, dialect_filter=None, batch_limit=1): self.batch_limit = batch_limit + self.dialect_filter = dialect_filter self._block_latest = self.__unimplemented self._block_by_hash = self.__unimplemented self._block_by_number = self.__unimplemented @@ -38,7 +39,6 @@ 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): @@ -86,7 +86,7 @@ class ChainInterface: :rtype: chainlib.block.Block :returns: Block object """ - return self._block_from_src(src, dialect_filter=self._dialect_filter) + return self._block_from_src(src, dialect_filter=self.dialect_filter) def block_to_src(self, block): @@ -194,7 +194,7 @@ class ChainInterface: :rtype: chainlib.tx.Tx :returns: Transaction object """ - return self._tx_from_src(src, block) + return self._tx_from_src(src, block, dialect_filter=self.dialect_filter) def tx_to_src(self, tx): diff --git a/chainlib/src.py b/chainlib/src.py @@ -92,5 +92,3 @@ class Src: def load_src(self, dialect_filter=None): raise NotImplementedError() - - diff --git a/chainlib/tx.py b/chainlib/tx.py @@ -27,7 +27,7 @@ class Tx(Src): self.payload = None self.result = None - + super(Tx, self).__init__(src, dialect_filter=dialect_filter) self.load_src(dialect_filter=dialect_filter) @@ -69,6 +69,10 @@ class Tx(Src): raise NotImplementedError() + def load_src(self, dialect_filter=None): + raise NotImplementedError() + + def __str__(self): if self.block != None: return 'tx {} status {} block {} index {}'.format(self.display_hash(), self.status_name(), self.block.number, self.index) 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.5.1 +version=0.5.2 url=https://git.defalsify.org/chainlib author=Louis Holbrook