symmetric
This commit is contained in:
parent
dcad23c818
commit
69297cdac1
@ -1,10 +1,10 @@
|
||||
from typing import Generic, TypeVar
|
||||
|
||||
from rainbowadn.data.collection.collection_interface.collectioninterface import CollectionInterface
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
from rainbowadn.core.nullability.null import Null
|
||||
from rainbowadn.core.nullability.nullablereference import NullableReference
|
||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
||||
from rainbowadn.data.collection.collection_interface.collectioninterface import CollectionInterface
|
||||
|
||||
__all__ = ('BlockCollectionInterface',)
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
from typing import Generic, Iterable, TypeVar
|
||||
|
||||
from rainbowadn.data.collection.keyed import Keyed
|
||||
from rainbowadn.core.hash_point_format import hash_point_format, tabulate
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
from rainbowadn.core.hashresolver import HashResolver
|
||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
||||
from rainbowadn.core.resolverorigin import ResolverOrigin
|
||||
from rainbowadn.data.collection.keyed import Keyed
|
||||
|
||||
__all__ = ('KeyMetadata', 'KeyMetadataFactory',)
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
from typing import Generic, Iterable, TypeVar
|
||||
|
||||
from rainbowadn.data.collection.keyed import Keyed
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
from rainbowadn.core.hashresolver import HashResolver
|
||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
||||
from rainbowadn.core.resolverorigin import ResolverOrigin
|
||||
from rainbowadn.data.collection.keyed import Keyed
|
||||
|
||||
__all__ = ('KeyValue', 'KeyValueFactory',)
|
||||
|
||||
|
@ -20,7 +20,7 @@ class BinaryTreeAction(Generic[ActiveKeyType, MetaDataType, TreeType, ActionType
|
||||
if (split := protocol.split(tree)) is None:
|
||||
return self.on_null(protocol, tree)
|
||||
else:
|
||||
return self.on_split(BinaryTreeCase(protocol, split))
|
||||
return self.on_split(BinaryTreeCase(protocol, split, tree))
|
||||
|
||||
def on_null(
|
||||
self,
|
||||
|
@ -1,10 +1,10 @@
|
||||
import abc
|
||||
from typing import Generic, TypeVar
|
||||
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
from rainbowadn.data.collection.trees.binary.actions.binarytreeaction import BinaryTreeAction
|
||||
from rainbowadn.data.collection.trees.binary.binarytreecase import BinaryTreeCase
|
||||
from rainbowadn.data.collection.trees.comparison.comparator import Comparison, Equal, Left, Right
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
|
||||
__all__ = ('CompareAction',)
|
||||
|
||||
|
87
rainbowadn/data/collection/trees/binary/actions/symmetric.py
Normal file
87
rainbowadn/data/collection/trees/binary/actions/symmetric.py
Normal file
@ -0,0 +1,87 @@
|
||||
from typing import Generic, TypeVar
|
||||
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
from rainbowadn.data.collection.trees.binary.binarytreecase import BinaryTreeCase
|
||||
from rainbowadn.data.collection.trees.binary.binarytreesplit import BinaryTreeSplit
|
||||
|
||||
__all__ = ('Symmetric', 'InnerOuter', 'OuterInner',)
|
||||
|
||||
TreeType = TypeVar('TreeType')
|
||||
ActiveKeyType = TypeVar('ActiveKeyType')
|
||||
MetaDataType = TypeVar('MetaDataType')
|
||||
|
||||
|
||||
class Symmetric(
|
||||
Generic[ActiveKeyType, MetaDataType, TreeType]
|
||||
):
|
||||
def __init__(
|
||||
self,
|
||||
case: BinaryTreeCase[
|
||||
ActiveKeyType, MetaDataType, TreeType
|
||||
]
|
||||
):
|
||||
self.case = case
|
||||
|
||||
def inner(
|
||||
self,
|
||||
split: BinaryTreeSplit[ActiveKeyType, MetaDataType, TreeType]
|
||||
) -> TreeType:
|
||||
raise NotImplementedError
|
||||
|
||||
def outer(
|
||||
self,
|
||||
split: BinaryTreeSplit[ActiveKeyType, MetaDataType, TreeType]
|
||||
) -> TreeType:
|
||||
raise NotImplementedError
|
||||
|
||||
def tree(
|
||||
self,
|
||||
inner: TreeType,
|
||||
outer: TreeType,
|
||||
key: HashPoint[ActiveKeyType]
|
||||
) -> TreeType:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class InnerOuter(Symmetric):
|
||||
def inner(
|
||||
self,
|
||||
split: BinaryTreeSplit[ActiveKeyType, MetaDataType, TreeType]
|
||||
) -> TreeType:
|
||||
return split.treel
|
||||
|
||||
def outer(
|
||||
self,
|
||||
split: BinaryTreeSplit[ActiveKeyType, MetaDataType, TreeType]
|
||||
) -> TreeType:
|
||||
return split.treer
|
||||
|
||||
def tree(
|
||||
self,
|
||||
inner: TreeType,
|
||||
outer: TreeType,
|
||||
key: HashPoint[ActiveKeyType]
|
||||
) -> TreeType:
|
||||
return self.case.protocol.tree(inner, outer, key)
|
||||
|
||||
|
||||
class OuterInner(Symmetric):
|
||||
def inner(
|
||||
self,
|
||||
split: BinaryTreeSplit[ActiveKeyType, MetaDataType, TreeType]
|
||||
) -> TreeType:
|
||||
return split.treer
|
||||
|
||||
def outer(
|
||||
self,
|
||||
split: BinaryTreeSplit[ActiveKeyType, MetaDataType, TreeType]
|
||||
) -> TreeType:
|
||||
return split.treel
|
||||
|
||||
def tree(
|
||||
self,
|
||||
inner: TreeType,
|
||||
outer: TreeType,
|
||||
key: HashPoint[ActiveKeyType]
|
||||
) -> TreeType:
|
||||
return self.case.protocol.tree(outer, inner, key)
|
@ -1,5 +1,9 @@
|
||||
from typing import Generic, Optional, TypeVar
|
||||
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
from rainbowadn.core.nullability.null import Null
|
||||
from rainbowadn.core.nullability.nullablereference import NullableReference
|
||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
||||
from rainbowadn.data.collection.collection_interface.collectioninterface import CollectionInterface
|
||||
from rainbowadn.data.collection.keymetadata import KeyMetadata, KeyMetadataFactory
|
||||
from rainbowadn.data.collection.trees.binary.actions.stdactions import AddAction, ContainsAction, RemoveAction
|
||||
@ -8,10 +12,6 @@ from rainbowadn.data.collection.trees.binary.binarytree import BinaryTree, Binar
|
||||
from rainbowadn.data.collection.trees.binary.binarytreebalancingprotocol import BinaryTreeBalancingProtocol
|
||||
from rainbowadn.data.collection.trees.binary.binarytreecreationprotocol import BinaryTreeCreationProtocol
|
||||
from rainbowadn.data.collection.trees.binary.binarytreesplit import BinaryTreeSplit
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
from rainbowadn.core.nullability.null import Null
|
||||
from rainbowadn.core.nullability.nullablereference import NullableReference
|
||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
||||
|
||||
__all__ = ('ActiveBinaryTree',)
|
||||
|
||||
|
@ -1,17 +1,20 @@
|
||||
from typing import TypeVar
|
||||
from typing import Generic, TypeVar
|
||||
|
||||
from rainbowadn.data.atomic.integer import Integer
|
||||
from rainbowadn.data.collection.trees.binary.binarytreebalancingprotocol import BinaryTreeBalancingProtocol
|
||||
from rainbowadn.data.collection.trees.binary.binarytreecreationprotocol import BinaryTreeCreationProtocol
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
from rainbowadn.data.atomic.integer import Integer
|
||||
from rainbowadn.data.collection.trees.binary.actions.binarytreeaction import BinaryTreeAction
|
||||
from rainbowadn.data.collection.trees.binary.actions.symmetric import InnerOuter, OuterInner, Symmetric
|
||||
from rainbowadn.data.collection.trees.binary.binarytreebalancingprotocol import BinaryTreeBalancingProtocol
|
||||
from rainbowadn.data.collection.trees.binary.binarytreecase import BinaryTreeCase
|
||||
from rainbowadn.data.collection.trees.binary.binarytreecreationprotocol import BinaryTreeCreationProtocol
|
||||
|
||||
__all__ = ('AVLBTBP',)
|
||||
__all__ = ('AVL',)
|
||||
|
||||
ActiveKeyType = TypeVar('ActiveKeyType')
|
||||
TreeType = TypeVar('TreeType')
|
||||
|
||||
|
||||
class AVLBTBP(BinaryTreeBalancingProtocol[ActiveKeyType, Integer, TreeType]):
|
||||
class AVL(BinaryTreeBalancingProtocol[ActiveKeyType, Integer, TreeType]):
|
||||
def empty_metadata(self) -> HashPoint[Integer]:
|
||||
return HashPoint.of(Integer(0))
|
||||
|
||||
@ -32,50 +35,76 @@ class AVLBTBP(BinaryTreeBalancingProtocol[ActiveKeyType, Integer, TreeType]):
|
||||
tree: TreeType,
|
||||
protocol: BinaryTreeCreationProtocol[ActiveKeyType, Integer, TreeType]
|
||||
) -> int:
|
||||
if (split := protocol.split(tree)) is None:
|
||||
return 0
|
||||
else:
|
||||
return split.metadata.resolve().integer
|
||||
return HeightAction().on(protocol, tree)
|
||||
|
||||
def balance(
|
||||
self,
|
||||
tree: TreeType,
|
||||
protocol: BinaryTreeCreationProtocol[ActiveKeyType, Integer, TreeType]
|
||||
) -> TreeType:
|
||||
if (split := protocol.split(tree)) is None:
|
||||
return tree
|
||||
return BalanceAction().on(protocol, tree)
|
||||
|
||||
|
||||
class HeightAction(
|
||||
BinaryTreeAction[ActiveKeyType, Integer, TreeType, int],
|
||||
Generic[ActiveKeyType, TreeType]
|
||||
):
|
||||
def on_null(
|
||||
self,
|
||||
protocol: BinaryTreeCreationProtocol[ActiveKeyType, Integer, TreeType],
|
||||
tree: TreeType
|
||||
) -> int:
|
||||
return 0
|
||||
|
||||
def on_split(
|
||||
self,
|
||||
case: BinaryTreeCase[ActiveKeyType, Integer, TreeType]
|
||||
) -> int:
|
||||
return case.split.metadata.resolve().integer
|
||||
|
||||
|
||||
class BalanceAction(
|
||||
BinaryTreeAction[ActiveKeyType, Integer, TreeType, TreeType],
|
||||
Generic[ActiveKeyType, TreeType]
|
||||
):
|
||||
def on_null(
|
||||
self,
|
||||
protocol: BinaryTreeCreationProtocol[ActiveKeyType, Integer, TreeType],
|
||||
tree: TreeType
|
||||
) -> TreeType:
|
||||
return tree
|
||||
|
||||
def on_split(
|
||||
self,
|
||||
case: BinaryTreeCase[ActiveKeyType, Integer, TreeType]
|
||||
) -> TreeType:
|
||||
split, protocol = case.split, case.protocol
|
||||
delta = AVL.height(split.treel, protocol) - AVL.height(split.treer, protocol)
|
||||
assert isinstance(delta, int)
|
||||
if delta < -1:
|
||||
return self.on_symmetric(InnerOuter(case))
|
||||
elif delta > 1:
|
||||
return self.on_symmetric(OuterInner(case))
|
||||
else:
|
||||
delta = self.height(split.treel, protocol) - self.height(split.treer, protocol)
|
||||
assert isinstance(delta, int)
|
||||
if delta < -1:
|
||||
assert (splitr := protocol.split(split.treer)) is not None
|
||||
if self.height(splitr.treel, protocol) > self.height(splitr.treer, protocol):
|
||||
assert (splitrl := protocol.split(splitr.treel)) is not None
|
||||
return protocol.tree(
|
||||
protocol.tree(split.treel, splitrl.treel, split.key),
|
||||
protocol.tree(splitrl.treer, splitr.treer, splitr.key),
|
||||
splitrl.key
|
||||
)
|
||||
else:
|
||||
return protocol.tree(
|
||||
protocol.tree(split.treel, splitr.treel, split.key),
|
||||
splitr.treer,
|
||||
splitr.key
|
||||
)
|
||||
elif delta > 1:
|
||||
assert (splitl := protocol.split(split.treel)) is not None
|
||||
if self.height(splitl.treer, protocol) > self.height(splitl.treel, protocol):
|
||||
assert (splitlr := protocol.split(splitl.treer)) is not None
|
||||
return protocol.tree(
|
||||
protocol.tree(splitl.treel, splitlr.treel, splitl.key),
|
||||
protocol.tree(splitlr.treer, split.treer, split.key),
|
||||
splitlr.key
|
||||
)
|
||||
else:
|
||||
return protocol.tree(
|
||||
splitl.treel,
|
||||
protocol.tree(splitl.treer, split.treer, split.key),
|
||||
splitl.key
|
||||
)
|
||||
else:
|
||||
return tree
|
||||
return case.tree
|
||||
|
||||
@classmethod
|
||||
def on_symmetric(
|
||||
cls,
|
||||
symmetric: Symmetric[ActiveKeyType, Integer, TreeType]
|
||||
) -> TreeType:
|
||||
protocol, split = symmetric.case.protocol, symmetric.case.split
|
||||
splito = protocol.fsplit(symmetric.outer(split))
|
||||
if AVL.height(symmetric.inner(splito), protocol) > AVL.height(symmetric.outer(splito), protocol):
|
||||
splitoi = protocol.fsplit(symmetric.inner(splito))
|
||||
return symmetric.tree(
|
||||
symmetric.tree(symmetric.inner(split), symmetric.inner(splitoi), split.key),
|
||||
symmetric.tree(symmetric.outer(splitoi), symmetric.outer(splito), splito.key),
|
||||
splitoi.key
|
||||
)
|
||||
else:
|
||||
return symmetric.tree(
|
||||
symmetric.tree(symmetric.inner(split), symmetric.inner(splito), split.key),
|
||||
symmetric.outer(splito),
|
||||
splito.key
|
||||
)
|
||||
|
@ -1,9 +1,9 @@
|
||||
import abc
|
||||
from typing import Generic, TypeVar
|
||||
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
from rainbowadn.data.collection.trees.binary.binarytreebalancingprotocol import BinaryTreeBalancingProtocol
|
||||
from rainbowadn.data.collection.trees.binary.binarytreecreationprotocol import BinaryTreeCreationProtocol
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
|
||||
__all__ = ('BalancedTreeCreationProtocol',)
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
from typing import Generic, TypeVar
|
||||
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
from rainbowadn.data.collection.trees.binary.binarytreecreationprotocol import BinaryTreeCreationProtocol
|
||||
from rainbowadn.data.collection.trees.comparison.comparator import Comparator
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
|
||||
__all__ = ('BinaryTreeBalancingProtocol',)
|
||||
|
||||
|
@ -16,7 +16,9 @@ class BinaryTreeCase(
|
||||
def __init__(
|
||||
self,
|
||||
protocol: BinaryTreeCreationProtocol[ActiveKeyType, MetaDataType, TreeType],
|
||||
split: BinaryTreeSplit[ActiveKeyType, MetaDataType, TreeType]
|
||||
split: BinaryTreeSplit[ActiveKeyType, MetaDataType, TreeType],
|
||||
tree: TreeType
|
||||
):
|
||||
self.protocol = protocol
|
||||
self.split = split
|
||||
self.tree = tree
|
||||
|
@ -1,8 +1,8 @@
|
||||
from typing import Generic, Optional, TypeVar
|
||||
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
from rainbowadn.data.collection.trees.binary.binarytreesplit import BinaryTreeSplit
|
||||
from rainbowadn.data.collection.trees.comparison.comparator import Comparator
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
|
||||
__all__ = ('BinaryTreeCreationProtocol',)
|
||||
|
||||
@ -21,5 +21,12 @@ class BinaryTreeCreationProtocol(Generic[ActiveKeyType, MetaDataType, TreeType])
|
||||
"""result of this method is supposed to be used right after the call, therefore all values are resolved"""
|
||||
raise NotImplementedError
|
||||
|
||||
def fsplit(self, tree: TreeType) -> BinaryTreeSplit[
|
||||
ActiveKeyType, MetaDataType, TreeType
|
||||
]:
|
||||
split = self.split(tree)
|
||||
assert split is not None
|
||||
return split
|
||||
|
||||
def tree(self, treel: TreeType, treer: TreeType, key: HashPoint[ActiveKeyType]) -> TreeType:
|
||||
raise NotImplementedError
|
||||
|
@ -1,8 +1,8 @@
|
||||
from typing import Generic, TypeVar
|
||||
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
from rainbowadn.data.collection.trees.comparison.comparator import Comparison, Left, Right
|
||||
from rainbowadn.data.collection.trees.comparison.protocolcomparator import ProtocolComparator
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
|
||||
__all__ = ('HashComparator',)
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
from typing import Generic, TypeVar
|
||||
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
from rainbowadn.data.collection.keyed import Keyed
|
||||
from rainbowadn.data.collection.trees.comparison.comparator import Comparator, Comparison
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
|
||||
__all__ = ('KeyedComparator',)
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
from rainbowadn.data.atomic.plain import Plain
|
||||
from rainbowadn.data.collection.trees.comparison.comparator import Comparison, Left, Right
|
||||
from rainbowadn.data.collection.trees.comparison.protocolcomparator import ProtocolComparator
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
|
||||
__all__ = ('PlainComparator',)
|
||||
|
||||
|
@ -9,18 +9,18 @@ import nacl.signing
|
||||
from rainbowadn.chain.blockchain import BlockChainFactory
|
||||
from rainbowadn.chain.chaincollectioninterface import ChainCollectionInterface
|
||||
from rainbowadn.chain.reduction.reductionchainmetafactory import ReductionChainMetaFactory
|
||||
from rainbowadn.data.atomic.integer import Integer
|
||||
from rainbowadn.data.atomic.plain import Plain
|
||||
from rainbowadn.data.collection.pair import Pair, PairFactory
|
||||
from rainbowadn.data.collection.trees.binary.activebinarytree import ActiveBinaryTree
|
||||
from rainbowadn.data.collection.trees.binary.avl import AVLBTBP
|
||||
from rainbowadn.data.collection.trees.comparison.comparator import Replace
|
||||
from rainbowadn.data.collection.trees.comparison.plaincomparator import PlainComparator
|
||||
from rainbowadn.encryption.encrypted import Encrypted
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
from rainbowadn.core.nullability.notnull import NotNull
|
||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
||||
from rainbowadn.core.resolvermetaorigin import ResolverMetaOrigin
|
||||
from rainbowadn.data.atomic.integer import Integer
|
||||
from rainbowadn.data.atomic.plain import Plain
|
||||
from rainbowadn.data.collection.pair import Pair, PairFactory
|
||||
from rainbowadn.data.collection.trees.binary.activebinarytree import ActiveBinaryTree
|
||||
from rainbowadn.data.collection.trees.binary.avl import AVL
|
||||
from rainbowadn.data.collection.trees.comparison.comparator import Replace
|
||||
from rainbowadn.data.collection.trees.comparison.plaincomparator import PlainComparator
|
||||
from rainbowadn.encryption.encrypted import Encrypted
|
||||
from rainbowadn.testing.dictresolver import DictResolver
|
||||
from rainbowadn.testing.instrumentation import Counter
|
||||
from rainbowadn.v13.algo import MINT_CONST
|
||||
@ -142,7 +142,7 @@ class TestAll(unittest.TestCase):
|
||||
|
||||
def test_avl(self):
|
||||
tree: ActiveBinaryTree[Plain, Integer] = ActiveBinaryTree.empty(
|
||||
AVLBTBP(PlainComparator(Replace())), Plain.factory()
|
||||
AVL(PlainComparator(Replace())), Plain.factory()
|
||||
)
|
||||
for i in range(26):
|
||||
tree = tree.add(HashPoint.of(Plain(bytes([ord('A') + i]))))
|
||||
@ -150,7 +150,7 @@ class TestAll(unittest.TestCase):
|
||||
|
||||
def test_avl_stress(self):
|
||||
tree: ActiveBinaryTree[Plain, Integer] = ActiveBinaryTree.empty(
|
||||
AVLBTBP(PlainComparator(Replace())), Plain.factory()
|
||||
AVL(PlainComparator(Replace())), Plain.factory()
|
||||
)
|
||||
for i in range(250):
|
||||
tree = tree.add(HashPoint.of(Plain(os.urandom(16))))
|
||||
@ -163,7 +163,7 @@ class TestAll(unittest.TestCase):
|
||||
dr = DictResolver()
|
||||
with self.subTest('create empty'):
|
||||
tree: ActiveBinaryTree[Plain, Integer] = ActiveBinaryTree.empty(
|
||||
AVLBTBP(PlainComparator(Replace())), Plain.factory()
|
||||
AVL(PlainComparator(Replace())), Plain.factory()
|
||||
)
|
||||
with self.subTest('fill'):
|
||||
for char in string.ascii_uppercase:
|
||||
|
@ -9,7 +9,6 @@ from rainbowadn.toplevel.thresholdprotocol import ThresholdProtocol
|
||||
|
||||
__all__ = ('ValidReference', 'ValidReferenceFactory')
|
||||
|
||||
|
||||
Referenced = TypeVar('Referenced')
|
||||
|
||||
|
||||
|
@ -2,9 +2,9 @@ from typing import Generic, TypeVar
|
||||
|
||||
from rainbowadn.chain.abstractreductionchainmetafactory import AbstractReductionChainMetaFactory
|
||||
from rainbowadn.chain.chaincollectioninterface import ChainCollectionInterface
|
||||
from rainbowadn.data.collection.stack.stack import Stack, StackFactory
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
from rainbowadn.core.nullability.nullablereference import NullableReference, NullableReferenceFactory
|
||||
from rainbowadn.data.collection.stack.stack import Stack, StackFactory
|
||||
from rainbowadn.v13.bankprotocol import BankProtocol
|
||||
from rainbowadn.v13.bankstate import BankState
|
||||
from rainbowadn.v13.transaction import Transaction
|
||||
|
@ -2,15 +2,15 @@ from rainbowadn.chain.reduction.reduced import Reduced
|
||||
from rainbowadn.chain.reduction.reduction import Reduction
|
||||
from rainbowadn.chain.reduction.reductionprotocol import ReductionProtocol
|
||||
from rainbowadn.chain.reduction.reductionresult import ReductionResult
|
||||
from rainbowadn.data.atomic.integer import Integer
|
||||
from rainbowadn.data.collection.keymetadata import KeyMetadataFactory
|
||||
from rainbowadn.data.collection.stack.stack import Stack
|
||||
from rainbowadn.data.collection.trees.binary.binarytree import BinaryTreeFactory
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
from rainbowadn.core.nullability.null import Null
|
||||
from rainbowadn.core.nullability.nullablereference import NullableReference
|
||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
||||
from rainbowadn.core.static import StaticFactory
|
||||
from rainbowadn.data.atomic.integer import Integer
|
||||
from rainbowadn.data.collection.keymetadata import KeyMetadataFactory
|
||||
from rainbowadn.data.collection.stack.stack import Stack
|
||||
from rainbowadn.data.collection.trees.binary.binarytree import BinaryTreeFactory
|
||||
from rainbowadn.v13.bankstate import BankState
|
||||
from rainbowadn.v13.subject import Subject
|
||||
from rainbowadn.v13.transaction import Coin, Transaction
|
||||
|
@ -1,12 +1,5 @@
|
||||
from typing import Iterable
|
||||
|
||||
from rainbowadn.data.atomic.integer import Integer
|
||||
from rainbowadn.data.collection.keymetadata import KeyMetadata, KeyMetadataFactory
|
||||
from rainbowadn.data.collection.trees.binary.activebinarytree import ActiveBinaryTree
|
||||
from rainbowadn.data.collection.trees.binary.avl import AVLBTBP
|
||||
from rainbowadn.data.collection.trees.binary.binarytree import BinaryTree, BinaryTreeFactory
|
||||
from rainbowadn.data.collection.trees.comparison.comparator import Fail
|
||||
from rainbowadn.data.collection.trees.comparison.hashcomparator import HashComparator
|
||||
from rainbowadn.core.hash_point_format import hash_point_format, tabulate
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
from rainbowadn.core.hashresolver import HashResolver
|
||||
@ -17,6 +10,13 @@ from rainbowadn.core.rainbow_factory import RainbowFactory
|
||||
from rainbowadn.core.recursivementionable import RecursiveMentionable
|
||||
from rainbowadn.core.resolverorigin import ResolverOrigin
|
||||
from rainbowadn.core.static import StaticFactory, StaticMentionable
|
||||
from rainbowadn.data.atomic.integer import Integer
|
||||
from rainbowadn.data.collection.keymetadata import KeyMetadata, KeyMetadataFactory
|
||||
from rainbowadn.data.collection.trees.binary.activebinarytree import ActiveBinaryTree
|
||||
from rainbowadn.data.collection.trees.binary.avl import AVL
|
||||
from rainbowadn.data.collection.trees.binary.binarytree import BinaryTree, BinaryTreeFactory
|
||||
from rainbowadn.data.collection.trees.comparison.comparator import Fail
|
||||
from rainbowadn.data.collection.trees.comparison.hashcomparator import HashComparator
|
||||
from rainbowadn.v13.algo import MINT_CONST
|
||||
from rainbowadn.v13.subject import Subject
|
||||
from rainbowadn.v13.transaction import Coin, Transaction
|
||||
@ -89,12 +89,12 @@ class BankState(RecursiveMentionable, StaticMentionable):
|
||||
|
||||
def minted_tree(self) -> ActiveBinaryTree[Coin, Integer]:
|
||||
return ActiveBinaryTree(
|
||||
AVLBTBP(HashComparator(Fail())), self.minted
|
||||
AVL(HashComparator(Fail())), self.minted
|
||||
)
|
||||
|
||||
def used_tree(self) -> ActiveBinaryTree[Coin, Integer]:
|
||||
return ActiveBinaryTree(
|
||||
AVLBTBP(HashComparator(Fail())), self.used
|
||||
AVL(HashComparator(Fail())), self.used
|
||||
)
|
||||
|
||||
def use_coins(self, coins: Iterable[HashPoint[Coin]]) -> 'BankState':
|
||||
|
@ -2,8 +2,8 @@ import nacl.bindings
|
||||
import nacl.exceptions
|
||||
import nacl.signing
|
||||
|
||||
from rainbowadn.data.atomic.atomic import Atomic
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
from rainbowadn.data.atomic.atomic import Atomic
|
||||
from rainbowadn.v13.subject import Subject
|
||||
|
||||
__all__ = ('BadSignature', 'Signature',)
|
||||
|
@ -2,8 +2,6 @@ from typing import Iterable
|
||||
|
||||
import nacl.signing
|
||||
|
||||
from rainbowadn.data.atomic.integer import Integer
|
||||
from rainbowadn.data.collection.stack.stack import Stack, StackFactory
|
||||
from rainbowadn.core.hash_point_format import hash_point_format, tabulate
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
from rainbowadn.core.hashresolver import HashResolver
|
||||
@ -14,6 +12,8 @@ from rainbowadn.core.rainbow_factory import RainbowFactory
|
||||
from rainbowadn.core.recursivementionable import RecursiveMentionable
|
||||
from rainbowadn.core.resolverorigin import ResolverOrigin
|
||||
from rainbowadn.core.static import StaticMentionable
|
||||
from rainbowadn.data.atomic.integer import Integer
|
||||
from rainbowadn.data.collection.stack.stack import Stack, StackFactory
|
||||
from rainbowadn.v13.signature import Signature
|
||||
from rainbowadn.v13.subject import Subject
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
from typing import Iterable
|
||||
|
||||
from rainbowadn.data.atomic.integer import Integer
|
||||
from rainbowadn.core.hash_point_format import hash_point_format, tabulate
|
||||
from rainbowadn.core.hashpoint import HashPoint
|
||||
from rainbowadn.core.hashresolver import HashResolver
|
||||
@ -10,6 +9,7 @@ from rainbowadn.core.mentionable import Mentionable
|
||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
||||
from rainbowadn.core.recursivementionable import RecursiveMentionable
|
||||
from rainbowadn.core.resolverorigin import ResolverOrigin
|
||||
from rainbowadn.data.atomic.integer import Integer
|
||||
from rainbowadn.wrisbt.weakreferenceindexsetbtree import WeakReferenceIndexSetBTree, WrisbtFactory
|
||||
from rainbowadn.wrisbt.wrisbtparametres import WrisbtParametres
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user