remerkleable package

Submodules

remerkleable.basic module

exception remerkleable.basic.OperationNotSupported[source]

Bases: Exception

class remerkleable.basic.bit(*args, **kwargs)[source]

Bases: remerkleable.basic.boolean

class remerkleable.basic.boolean(*args, **kwargs)[source]

Bases: int, remerkleable.core.BasicView

classmethod coerce_view(v)[source]
Return type

~V

classmethod decode_bytes(bytez)[source]
Return type

~V

encode_bytes()[source]
Return type

bytes

classmethod from_obj(obj)[source]
Return type

~V

to_obj()[source]
Return type

Union[dict, list, tuple, str, int, bool, None, Union[dict, list, tuple, str, int, bool, None, ForwardRef]]

classmethod type_byte_length()[source]
Return type

int

classmethod type_repr()[source]
Return type

str

class remerkleable.basic.byte(*args, **kwargs)[source]

Bases: remerkleable.basic.uint8

class remerkleable.basic.uint(*args, **kwargs)[source]

Bases: int, remerkleable.core.BasicView

classmethod coerce_view(v)[source]
Return type

~V

classmethod decode_bytes(bytez)[source]
Return type

~V

encode_bytes()[source]
Return type

bytes

classmethod from_obj(obj)[source]
Return type

~V

to_obj()[source]
Return type

Union[dict, list, tuple, str, int, bool, None, Union[dict, list, tuple, str, int, bool, None, ForwardRef]]

classmethod type_repr()[source]
Return type

str

class remerkleable.basic.uint128(*args, **kwargs)[source]

Bases: remerkleable.basic.uint

to_obj()[source]
Return type

Union[dict, list, tuple, str, int, bool, None, Union[dict, list, tuple, str, int, bool, None, ForwardRef]]

classmethod type_byte_length()[source]
Return type

int

class remerkleable.basic.uint16(*args, **kwargs)[source]

Bases: remerkleable.basic.uint

classmethod type_byte_length()[source]
Return type

int

class remerkleable.basic.uint256(*args, **kwargs)[source]

Bases: remerkleable.basic.uint

to_obj()[source]
Return type

Union[dict, list, tuple, str, int, bool, None, Union[dict, list, tuple, str, int, bool, None, ForwardRef]]

classmethod type_byte_length()[source]
Return type

int

class remerkleable.basic.uint32(*args, **kwargs)[source]

Bases: remerkleable.basic.uint

classmethod type_byte_length()[source]
Return type

int

class remerkleable.basic.uint64(*args, **kwargs)[source]

Bases: remerkleable.basic.uint

classmethod type_byte_length()[source]
Return type

int

class remerkleable.basic.uint8(*args, **kwargs)[source]

Bases: remerkleable.basic.uint

classmethod type_byte_length()[source]
Return type

int

remerkleable.bitfields module

class remerkleable.bitfields.Bitlist(*args, **kwargs)[source]

Bases: remerkleable.bitfields.BitsView

append(v)[source]
classmethod contents_depth()[source]
Return type

int

classmethod decode_bytes(bytez)[source]
Return type

~V

classmethod default_node()[source]
Return type

Node

classmethod deserialize(stream, scope)[source]
Return type

~V

get(i)[source]
Return type

boolean

classmethod is_fixed_byte_length()[source]
Return type

bool

classmethod key_to_static_gindex(key)[source]
Return type

NewType()(Gindex, int)

length()[source]
Return type

int

classmethod limit()[source]
Return type

int

classmethod max_byte_length()[source]
Return type

int

classmethod min_byte_length()[source]
Return type

int

classmethod navigate_type(key)[source]
Return type

Type[View]

pop()[source]
serialize(stream)[source]
Return type

int

set(i, v)[source]
Return type

None

classmethod tree_depth()[source]
Return type

int

classmethod type_repr()[source]
Return type

str

value_byte_length()[source]
Return type

int

class remerkleable.bitfields.BitsView(*args, **kwargs)[source]

Bases: remerkleable.core.BackedView, collections.abc.Sequence

classmethod coerce_view(v)[source]
Return type

~V

classmethod decode_bytes(bytez)[source]
Return type

~V

encode_bytes()[source]
Return type

bytes

classmethod from_obj(obj)[source]
Return type

~V

get(i)[source]
Return type

boolean

length()[source]
Return type

int

navigate_view(key)[source]
Return type

View

set(i, v)[source]
Return type

None

to_obj()[source]
Return type

Union[dict, list, tuple, str, int, bool, None, Union[dict, list, tuple, str, int, bool, None, ForwardRef]]

classmethod tree_depth()[source]
Return type

int

class remerkleable.bitfields.Bitvector(*args, **kwargs)[source]

Bases: remerkleable.bitfields.BitsView, remerkleable.core.FixedByteLengthViewHelper

classmethod default_node()[source]
Return type

Node

classmethod deserialize(stream, scope)[source]
Return type

~V

get(i)[source]
Return type

boolean

classmethod key_to_static_gindex(key)[source]
Return type

NewType()(Gindex, int)

length()[source]
Return type

int

classmethod navigate_type(key)[source]
Return type

Type[View]

serialize(stream)[source]
Return type

int

set(i, v)[source]
Return type

None

classmethod tree_depth()[source]
Return type

int

classmethod type_byte_length()[source]
Return type

int

classmethod type_repr()[source]
Return type

str

classmethod vector_length()[source]
Return type

int

remerkleable.byte_vector module

remerkleable.complex module

class remerkleable.complex.ComplexView(*args, **kwargs)[source]

Bases: remerkleable.subtree.SubtreeView

classmethod decode_bytes(bytez)[source]
Return type

~V

encode_bytes()[source]
Return type

bytes

class remerkleable.complex.Container(*args, **kwargs)[source]

Bases: remerkleable.complex.ComplexView

classmethod coerce_view(v)[source]
Return type

~V

classmethod decode_bytes(bytez)[source]
Return type

~V

classmethod default_node()[source]
Return type

Node

classmethod deserialize(stream, scope)[source]
Return type

~V

classmethod fields()[source]
Return type

Dict[str, Type[View]]

classmethod from_obj(obj)[source]
Return type

~V

classmethod is_fixed_byte_length()[source]
Return type

bool

classmethod is_packed()[source]
Return type

bool

classmethod item_elem_cls(i)[source]
Return type

Type[View]

classmethod key_to_static_gindex(key)[source]
Return type

NewType()(Gindex, int)

classmethod max_byte_length()[source]
Return type

int

classmethod min_byte_length()[source]
Return type

int

classmethod navigate_type(key)[source]
Return type

Type[View]

navigate_view(key)[source]
Return type

View

serialize(stream)[source]
Return type

int

to_obj()[source]
Return type

Union[dict, list, tuple, str, int, bool, None, Union[dict, list, tuple, str, int, bool, None, ForwardRef]]

classmethod tree_depth()[source]
Return type

int

classmethod type_byte_length()[source]
Return type

int

classmethod type_repr()[source]
Return type

str

value_byte_length()[source]
Return type

int

class remerkleable.complex.FieldOffset(key, typ, offset)[source]

Bases: tuple

key

Alias for field number 0

offset

Alias for field number 2

typ

Alias for field number 1

class remerkleable.complex.List(*args, **kwargs)[source]

Bases: remerkleable.complex.MonoSubtreeView

append(v)[source]
classmethod contents_depth()[source]
Return type

int

classmethod default_node()[source]
Return type

Node

get(i)[source]
Return type

View

classmethod is_fixed_byte_length()[source]
Return type

bool

classmethod is_packed()[source]
Return type

bool

classmethod is_valid_count(count)[source]
Return type

bool

classmethod item_elem_cls(i)[source]
Return type

Type[~V]

classmethod key_to_static_gindex(key)[source]
Return type

NewType()(Gindex, int)

length()[source]
Return type

int

classmethod limit()[source]
Return type

int

classmethod max_byte_length()[source]
Return type

int

classmethod min_byte_length()[source]
Return type

int

classmethod navigate_type(key)[source]
Return type

Type[View]

pop()[source]
set(i, v)[source]
Return type

None

to_obj()[source]
Return type

Union[dict, list, tuple, str, int, bool, None, Union[dict, list, tuple, str, int, bool, None, ForwardRef]]

classmethod tree_depth()[source]
Return type

int

classmethod type_repr()[source]
Return type

str

value_byte_length()[source]
Return type

int

class remerkleable.complex.MonoSubtreeView(*args, **kwargs)[source]

Bases: collections.abc.Sequence, remerkleable.complex.ComplexView

classmethod coerce_view(v)[source]
Return type

~V

classmethod deserialize(stream, scope)[source]
Return type

~V

classmethod element_cls()[source]
Return type

Type[View]

classmethod from_obj(obj)[source]
Return type

~V

classmethod is_valid_count(count)[source]
Return type

bool

classmethod item_elem_cls(i)[source]
Return type

Type[View]

classmethod key_to_static_gindex(key)[source]
Return type

NewType()(Gindex, int)

length()[source]
Return type

int

classmethod navigate_type(key)[source]
Return type

Type[View]

navigate_view(key)[source]
Return type

View

readonly_iter()[source]
serialize(stream)[source]
Return type

int

classmethod to_chunk_length(elems_length)[source]
Return type

int

classmethod views_into_chunks(views)[source]
Return type

List[Node]

class remerkleable.complex.Vector(*args, **kwargs)[source]

Bases: remerkleable.complex.MonoSubtreeView

classmethod default_node()[source]
Return type

Node

get(i)[source]
Return type

View

classmethod is_fixed_byte_length()[source]
Return type

bool

classmethod is_valid_count(count)[source]
Return type

bool

classmethod key_to_static_gindex(key)[source]
Return type

NewType()(Gindex, int)

length()[source]
Return type

int

classmethod max_byte_length()[source]
Return type

int

classmethod min_byte_length()[source]
Return type

int

classmethod navigate_type(key)[source]
Return type

Type[View]

set(i, v)[source]
Return type

None

to_obj()[source]
Return type

Union[dict, list, tuple, str, int, bool, None, Union[dict, list, tuple, str, int, bool, None, ForwardRef]]

classmethod type_repr()[source]
Return type

str

value_byte_length()[source]
Return type

int

classmethod vector_length()[source]
Return type

int

remerkleable.complex.decode_offset(stream)[source]
Return type

uint32

remerkleable.complex.encode_offset(stream, offset)[source]

remerkleable.core module

class remerkleable.core.BackedView(*args, **kwargs)[source]

Bases: remerkleable.core.View, remerkleable.core.TypeDef

get_backing()[source]
Return type

Node

set_backing(value)[source]
classmethod view_from_backing(node, hook=None)[source]
Return type

~V

class remerkleable.core.BasicTypeDef(*args, **kwargs)[source]

Bases: remerkleable.core.TypeDef, typing.Protocol

classmethod basic_view_from_backing(node, i)[source]
Return type

~BV

classmethod pack_views(views)[source]
Return type

List[Node]

class remerkleable.core.BasicView(*args, **kwargs)[source]

Bases: remerkleable.core.FixedByteLengthViewHelper, remerkleable.core.BasicTypeDef

backing_from_base(base, i)[source]
Return type

Node

classmethod basic_view_from_backing(node, i)[source]
Return type

~BV

copy()[source]
Return type

~V

classmethod default_node()[source]
Return type

Node

get_backing()[source]
Return type

Node

classmethod pack_views(views)[source]
Return type

List[Node]

set_backing(value)[source]
classmethod view_from_backing(node, hook=None)[source]
Return type

~V

class remerkleable.core.FixedByteLengthViewHelper(*args, **kwargs)[source]

Bases: remerkleable.core.View

classmethod deserialize(stream, scope)[source]
Return type

~V

classmethod is_fixed_byte_length()[source]
Return type

bool

classmethod max_byte_length()[source]
Return type

int

classmethod min_byte_length()[source]
Return type

int

value_byte_length()[source]
Return type

int

exception remerkleable.core.ObjParseException[source]

Bases: Exception

class remerkleable.core.Path(anchor, path=None)[source]

Bases: object

anchor: Type['View'] = None
static from_raw_path(anchor, path)[source]
Return type

Path

gindex(view=None)[source]
Return type

NewType()(Gindex, int)

navigate_type()[source]
Return type

Type[View]

navigate_view(v)[source]
Return type

View

path: PyList[Tuple[Any, Type['View']]] = None
class remerkleable.core.TypeDef(*args, **kwargs)[source]

Bases: typing.Protocol

classmethod coerce_view(v)[source]
Return type

~V

classmethod decode_bytes(bytez)[source]
Return type

~V

classmethod default(hook)[source]
Return type

~V

classmethod default_node()[source]
Return type

Node

classmethod deserialize(stream, scope)[source]
Return type

~V

classmethod from_obj(obj)[source]
Return type

~V

classmethod is_fixed_byte_length()[source]
Return type

bool

classmethod key_to_static_gindex(key)[source]
Return type

NewType()(Gindex, int)

classmethod max_byte_length()[source]
Return type

int

classmethod min_byte_length()[source]
Return type

int

classmethod navigate_type(key)[source]
Return type

Type[View]

classmethod type_byte_length()[source]
Return type

int

classmethod type_repr()[source]
Return type

str

classmethod view_from_backing(node, hook=None)[source]
Return type

~V

class remerkleable.core.TypeDefMeta[source]

Bases: typing._ProtocolMeta

class remerkleable.core.View(*args, **kwargs)[source]

Bases: remerkleable.core.TypeDef

copy()[source]
Return type

~V

classmethod default(hook)[source]
Return type

~V

encode_bytes()[source]
Return type

bytes

get_backing()[source]
Return type

Node

hash_tree_root()[source]
Return type

NewType()(Root, bytes)

key_to_dynamic_gindex(key)[source]
Return type

NewType()(Gindex, int)

navigate_view(key)[source]
Return type

View

serialize(stream)[source]
Return type

int

set_backing(value)[source]
to_obj()[source]
Return type

Union[dict, list, tuple, str, int, bool, None, Union[dict, list, tuple, str, int, bool, None, ForwardRef]]

classmethod type_byte_length()[source]
Return type

int

value_byte_length()[source]
Return type

int

remerkleable.core.bits_to_byte_int(byte)[source]
Return type

int

remerkleable.core.byte_int_to_byte(b)[source]
Return type

bytes

remerkleable.core.grouper(items, n, fillvalue=None)[source]

Collect data into fixed-length chunks or blocks grouper(‘ABCDEFG’, 3, ‘x’) –> ABC DEF Gxx

Return type

Iterable[Tuple]

remerkleable.core.pack_bits_to_chunks(items)[source]
Return type

List[Node]

remerkleable.core.pack_byte_ints_to_chunks(items)[source]
Return type

List[Node]

remerkleable.core.pack_bytes_to_chunks(bytez)[source]
Return type

List[Node]

remerkleable.core.pack_ints_to_chunks(items, items_per_chunk)[source]
Return type

List[Node]

remerkleable.history module

remerkleable.history.get_target_history(history, target)[source]

Fetch an ordered, keyed, history of nodes at the given target. The sequential equal values are reduced into a single value, and keyed by the first occurrence. This is done efficiently by first comparing the top of the tree,

de-duplicating, and then recursively going deeper into the tree.

Parameters
  • history (List[Tuple[~K, Node]]) – An ordered keyed series of nodes, the root nodes to get the target from

  • target (NewType()(Gindex, int)) – The target node to look up, pointing to the values to return.

Return type

List[Tuple[~K, Node]]

Returns

the target values, keyed by the keys of the top nodes the target values first occurred in.

remerkleable.subtree module

class remerkleable.subtree.SubtreeView(*args, **kwargs)[source]

Bases: remerkleable.core.BackedView, remerkleable.core.TypeDef

get(i)[source]
Return type

View

classmethod is_packed()[source]
Return type

bool

classmethod item_elem_cls(i)[source]
Return type

Type[View]

set(i, v)[source]
Return type

None

classmethod tree_depth()[source]
Return type

int

remerkleable.test_impl module

remerkleable.test_typing module

remerkleable.tree module

exception remerkleable.tree.NavigationError[source]

Bases: RuntimeError

class remerkleable.tree.Node(*args, **kwargs)[source]

Bases: typing.Protocol

get_left()[source]
Return type

Node

get_right()[source]
Return type

Node

getter(target)[source]
Return type

Node

is_leaf()[source]
Return type

bool

merkle_root()[source]
Return type

NewType()(Root, bytes)

rebind_left(v)[source]
Return type

Node

rebind_right(v)[source]
Return type

Node

property root
Return type

NewType()(Root, bytes)

setter(target, expand=False)[source]
Return type

Callable[[Node], Node]

summarize_into(target)[source]
Return type

Callable[[], Node]

class remerkleable.tree.PairNode(left, right)[source]

Bases: remerkleable.tree.RebindableNode, remerkleable.tree.Node

An optimized, with lazily-computed root, a node that references two child nodes.

get_left()[source]
Return type

Node

get_right()[source]
Return type

Node

is_leaf()[source]
Return type

bool

left
merkle_root()[source]
Return type

NewType()(Root, bytes)

right
class remerkleable.tree.RebindableNode(*args, **kwargs)[source]

Bases: remerkleable.tree.Node

combine(left, right)[source]
Return type

Node

rebind_left(v)[source]
Return type

Node

rebind_right(v)[source]
Return type

Node

setter(target, expand=False)[source]
Return type

Callable[[Node], Node]

class remerkleable.tree.RootNode(root)[source]

Bases: remerkleable.tree.Node

An optimized root-holding node. To check if a Node functions as node without children, use node.is_leaf(), since there may be more classes implementing non-child node behavior.

getter(target)[source]
Return type

Node

is_leaf()[source]
Return type

bool

merkle_root()[source]
Return type

NewType()(Root, bytes)

o
r
property root
Return type

NewType()(Root, bytes)

setter(target, expand=False)[source]
Return type

Callable[[Node], Node]

t
remerkleable.tree.compose(inner, outer)[source]
Return type

Callable[[Node], Node]

remerkleable.tree.concat_gindices(steps)[source]
Return type

NewType()(Gindex, int)

remerkleable.tree.get_anchor_gindex(gindex)[source]
Return type

NewType()(Gindex, int)

remerkleable.tree.get_depth(elem_count)[source]
Return type

int

remerkleable.tree.get_diff(a, b)[source]

Iterate over the changes of b, not common with a. Left-to-right order. Returns (a,b) tuples that can’t be diffed deeper.

Return type

Iterator[Tuple[Node, Node]]

remerkleable.tree.gindex_bit_iter(gindex)[source]
Return type

Tuple[Iterator[bool], int]

remerkleable.tree.identity(v)[source]
Return type

Node

remerkleable.tree.leaf_iter(node)[source]

Iterate ove the leaf nodes of the given node. Left-to-right order.

Return type

Iterator[Node]

remerkleable.tree.merkle_hash(left, right)[source]
Return type

NewType()(Root, bytes)

remerkleable.tree.subtree_fill_to_contents(nodes, depth)[source]
Return type

Node

remerkleable.tree.subtree_fill_to_depth(bottom, depth)[source]
Return type

Node

remerkleable.tree.subtree_fill_to_length(bottom, depth, length)[source]
Return type

Node

remerkleable.tree.to_gindex(index, depth)[source]
remerkleable.tree.zero_node(depth)[source]
Return type

RootNode

Module contents