commit 290cbb3b2e1a32b05d54d359c0719f50948453fc
parent b206d70c4948c2b77d1b6708522f8ad0df4e9f15
Author: lash <dev@holbrook.no>
Date: Fri, 16 Dec 2022 08:31:59 +0000
Add hooks for custom formatting in tx, block parsing
Diffstat:
4 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
@@ -1,3 +1,7 @@
+- 0.4.4
+ * Add support for dialect differences in tx and block processing
+- 0.4.3
+ * Fix license classifier string
- 0.4.2
* Change license to AGPL3 and copyright waived to public domain
- 0.4.1
diff --git a/chainlib/block.py b/chainlib/block.py
@@ -19,7 +19,7 @@ class Block(Src):
tx_generator = Tx
- def __init__(self, src=None):
+ def __init__(self, src=None, dialect_filter=None):
self.number = None
self.txs = []
self.author = None
@@ -31,7 +31,15 @@ class Block(Src):
self.fee_cost = 0
self.parent_hash = None
- super(Block, self).__init__(src=src)
+ self.extra = {}
+
+ super(Block, self).__init__(src=src, dialect_filter=dialect_filter)
+
+ self.load_src(dialect_filter=dialect_filter)
+
+
+ def load_src(self, dialect_filter=None):
+ raise NotImplementedError()
def tx_by_index(self, idx):
diff --git a/chainlib/tx.py b/chainlib/tx.py
@@ -12,7 +12,7 @@ class Tx(Src):
:type block: chainlib.block.Block
"""
- def __init__(self, src=None, block=None, result=None, strict=False):
+ def __init__(self, src=None, block=None, result=None, strict=False, dialect_filter=None):
self.block = block
self.index = -1
@@ -28,20 +28,20 @@ class Tx(Src):
self.result = None
- super(Tx, self).__init__(src)
+ super(Tx, self).__init__(src, dialect_filter=dialect_filter)
if block != None:
- self.apply_block(block)
+ self.apply_block(block, dialect_filter=dialect_filter)
if result != None:
- self.apply_result(result)
+ self.apply_result(result, dialect_filter=dialect_filter)
- def apply_result(self, result):
+ def apply_result(self, result, dialect_filter=None):
self.result = result
- def apply_block(self, block):
+ def apply_block(self, block, dialect_filter=None):
self.block = block
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.3
+version=0.4.4
url=https://git.defalsify.org/chaintool.git
author=Louis Holbrook