restructured
This commit is contained in:
parent
e61650dc7f
commit
b7d0cbdcf3
3
rainbowadn/atomic/__init__.py
Normal file
3
rainbowadn/atomic/__init__.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from .atomic import Atomic
|
||||||
|
from .integer import Integer
|
||||||
|
from .plain import Plain
|
@ -1,9 +1,7 @@
|
|||||||
import abc
|
import abc
|
||||||
from typing import Type, TypeVar
|
from typing import Type, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.hashresolver import HashResolver
|
|
||||||
from rainbowadn.core.static import StaticMentionable
|
|
||||||
|
|
||||||
__all__ = ('Atomic',)
|
__all__ = ('Atomic',)
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
from rainbowadn.data.atomic.atomic import Atomic
|
from .atomic import Atomic
|
||||||
|
|
||||||
__all__ = ('Integer',)
|
__all__ = ('Integer',)
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
from rainbowadn.data.atomic.atomic import Atomic
|
from .atomic import Atomic
|
||||||
|
|
||||||
__all__ = ('Plain',)
|
__all__ = ('Plain',)
|
||||||
|
|
@ -0,0 +1,5 @@
|
|||||||
|
from .blockchain import *
|
||||||
|
from .blockchainprotocol import BlockChainProtocol
|
||||||
|
from .chaincollectionfactory import ChainCollectionFactory
|
||||||
|
from .chaincollectioninterface import ChainCollectionInterface
|
||||||
|
from .reductionchainmetafactory import ReductionChainMetaFactory
|
@ -1,12 +1,7 @@
|
|||||||
from typing import Generic, Iterable, TypeVar
|
from typing import Generic, Iterable, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hash_point_format import hash_point_format, tabulate
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.nullability import *
|
||||||
from rainbowadn.core.hashresolver import HashResolver
|
|
||||||
from rainbowadn.core.nullability.nullablereference import NullableReference, NullableReferenceFactory
|
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
|
||||||
from rainbowadn.core.recursivementionable import RecursiveMentionable
|
|
||||||
from rainbowadn.core.resolverorigin import ResolverOrigin
|
|
||||||
|
|
||||||
__all__ = ('Block', 'BlockFactory',)
|
__all__ = ('Block', 'BlockFactory',)
|
||||||
|
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.chain.block import Block, BlockFactory
|
from rainbowadn.core import *
|
||||||
from rainbowadn.chain.blockchainprotocol import BlockChainProtocol
|
from rainbowadn.nullability import *
|
||||||
from rainbowadn.chain.chaincollectionfactory import ChainCollectionFactory
|
from .block import *
|
||||||
from rainbowadn.chain.chaincollectioninterface import ChainCollectionInterface
|
from .blockchainprotocol import BlockChainProtocol
|
||||||
from rainbowadn.core.asserts import assert_eq, assert_true
|
from .chaincollectionfactory import ChainCollectionFactory
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from .chaincollectioninterface import ChainCollectionInterface
|
||||||
from rainbowadn.core.nullability.null import Null
|
|
||||||
from rainbowadn.core.nullability.nullablereference import NullableReference
|
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
|
||||||
|
|
||||||
__all__ = ('BlockChain', 'BlockChainFactory',)
|
__all__ = ('BlockChain', 'BlockChainFactory',)
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.chain.states.activestateprotocol import ActiveStateProtocol
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from .states import *
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
|
||||||
|
|
||||||
__all__ = ('BlockChainProtocol',)
|
__all__ = ('BlockChainProtocol',)
|
||||||
|
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.collection.collectioninterface import CollectionInterface
|
||||||
from rainbowadn.core.nullability.null import Null
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.nullability.nullablereference import NullableReference
|
from rainbowadn.nullability import *
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
|
||||||
from rainbowadn.data.collection.collection_interface.collectioninterface import CollectionInterface
|
|
||||||
|
|
||||||
__all__ = ('BlockCollectionInterface',)
|
__all__ = ('BlockCollectionInterface',)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.chain.chaincollectioninterface import ChainCollectionInterface
|
from rainbowadn.nullability import *
|
||||||
from rainbowadn.core.nullability.nullablereference import NullableReference
|
from .chaincollectioninterface import ChainCollectionInterface
|
||||||
|
|
||||||
__all__ = ('ChainCollectionFactory',)
|
__all__ = ('ChainCollectionFactory',)
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import abc
|
import abc
|
||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.chain.blockcollectioninterface import BlockCollectionInterface
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from .blockcollectioninterface import BlockCollectionInterface
|
||||||
|
|
||||||
__all__ = ('ChainCollectionInterface',)
|
__all__ = ('ChainCollectionInterface',)
|
||||||
|
|
||||||
|
5
rainbowadn/chain/derivation/__init__.py
Normal file
5
rainbowadn/chain/derivation/__init__.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from .activestageprotocol import ActiveStageProtocol
|
||||||
|
from .activestagestateprotocol import ActiveStageStateProtocol
|
||||||
|
from .derived import Derived
|
||||||
|
from .derivedstage import DerivedStage
|
||||||
|
from .derivedstate import DerivedState
|
@ -1,15 +1,11 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.chain.stages.derivation.derived import Derived
|
from rainbowadn.chain.stages import *
|
||||||
from rainbowadn.chain.stages.derivation.derivedstage import DerivedStage
|
from rainbowadn.core import *
|
||||||
from rainbowadn.chain.stages.derivation.derivedstate import DerivedState
|
from rainbowadn.nullability import *
|
||||||
from rainbowadn.chain.stages.stage import StageStage, StageStageFactory, StateStage
|
from .derived import Derived
|
||||||
from rainbowadn.chain.stages.stageprotocol import StageProtocol
|
from .derivedstage import DerivedStage
|
||||||
from rainbowadn.core.asserts import assert_eq
|
from .derivedstate import DerivedState
|
||||||
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__ = ('ActiveStageProtocol',)
|
__all__ = ('ActiveStageProtocol',)
|
||||||
|
|
@ -1,11 +1,10 @@
|
|||||||
from typing import TypeVar
|
from typing import TypeVar
|
||||||
|
|
||||||
from rainbowadn.chain.stages.derivation.activestageprotocol import ActiveStageProtocol
|
from rainbowadn.chain.stages import *
|
||||||
from rainbowadn.chain.stages.stage import StateStage
|
from rainbowadn.chain.states import *
|
||||||
from rainbowadn.chain.states.activestateprotocol import ActiveStateProtocol
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.nullability import *
|
||||||
from rainbowadn.core.nullability.nullablereference import NullableReference
|
from .activestageprotocol import ActiveStageProtocol
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
|
||||||
|
|
||||||
__all__ = ('ActiveStageStateProtocol',)
|
__all__ = ('ActiveStageStateProtocol',)
|
||||||
|
|
||||||
@ -62,3 +61,10 @@ class ActiveStageStateProtocol(
|
|||||||
self.base_state_factory,
|
self.base_state_factory,
|
||||||
self.stage_factory
|
self.stage_factory
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def stage_state_protocol(cls) -> StateProtocol[
|
||||||
|
HeaderType,
|
||||||
|
StateStage[HeaderType, BaseStateType, StageType]
|
||||||
|
]:
|
||||||
|
return StageStateProtocol()
|
@ -1,7 +1,7 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.chain.stages.derivation.derived import Derived
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from .derived import Derived
|
||||||
|
|
||||||
__all__ = ('DerivedStage',)
|
__all__ = ('DerivedStage',)
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.chain.stages.derivation.derived import Derived
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from .derived import Derived
|
||||||
|
|
||||||
__all__ = ('DerivedState',)
|
__all__ = ('DerivedState',)
|
||||||
|
|
@ -0,0 +1,6 @@
|
|||||||
|
from .abstractreductionchainmetafactory import AbstractReductionChainMetaFactory
|
||||||
|
from .reduced import Reduced
|
||||||
|
from .reducible import Reducible
|
||||||
|
from .reductionchainprotocol import ReductionChainProtocol
|
||||||
|
from .reductionprotocol import ReductionProtocol
|
||||||
|
from .reductionresult import ReductionResult
|
@ -1,8 +1,8 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.chain.chaincollectionfactory import ChainCollectionFactory
|
from rainbowadn.chain.chaincollectionfactory import ChainCollectionFactory
|
||||||
from rainbowadn.chain.reduction.reductionprotocol import ReductionProtocol
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
from .reductionprotocol import ReductionProtocol
|
||||||
|
|
||||||
__all__ = ('AbstractReductionChainMetaFactory',)
|
__all__ = ('AbstractReductionChainMetaFactory',)
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.chain.reduction.reductionresult import ReductionResult
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from .reductionresult import ReductionResult
|
||||||
|
|
||||||
__all__ = ('Reduced',)
|
__all__ = ('Reduced',)
|
||||||
|
|
||||||
|
@ -1,20 +1,15 @@
|
|||||||
from typing import Generic, Iterable, TypeVar
|
from typing import Generic, Iterable, TypeVar
|
||||||
|
|
||||||
from rainbowadn.chain.reduction.reductionresult import ReductionResult
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.hash_point_format import hash_point_format, tabulate
|
from .reductionresult import ReductionResult
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
|
||||||
from rainbowadn.core.hashresolver import HashResolver
|
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
|
||||||
from rainbowadn.core.recursivementionable import RecursiveMentionable
|
|
||||||
from rainbowadn.core.resolverorigin import ResolverOrigin
|
|
||||||
|
|
||||||
__all__ = ('Reduction', 'ReductionFactory',)
|
__all__ = ('Reducible', 'ReductionFactory',)
|
||||||
|
|
||||||
ReductorType = TypeVar('ReductorType')
|
ReductorType = TypeVar('ReductorType')
|
||||||
AccumulatorType = TypeVar('AccumulatorType')
|
AccumulatorType = TypeVar('AccumulatorType')
|
||||||
|
|
||||||
|
|
||||||
class Reduction(
|
class Reducible(
|
||||||
ReductionResult[ReductorType, AccumulatorType],
|
ReductionResult[ReductorType, AccumulatorType],
|
||||||
RecursiveMentionable,
|
RecursiveMentionable,
|
||||||
Generic[ReductorType, AccumulatorType]
|
Generic[ReductorType, AccumulatorType]
|
||||||
@ -31,7 +26,7 @@ class Reduction(
|
|||||||
def __bytes__(self):
|
def __bytes__(self):
|
||||||
return bytes(self.reductor) + bytes(self.accumulator)
|
return bytes(self.reductor) + bytes(self.accumulator)
|
||||||
|
|
||||||
def __factory__(self) -> RainbowFactory['Reduction[ReductorType, AccumulatorType]']:
|
def __factory__(self) -> RainbowFactory['Reducible[ReductorType, AccumulatorType]']:
|
||||||
return ReductionFactory(self.reductor.factory, self.accumulator.factory)
|
return ReductionFactory(self.reductor.factory, self.accumulator.factory)
|
||||||
|
|
||||||
async def str(self, tab: int) -> str:
|
async def str(self, tab: int) -> str:
|
||||||
@ -41,7 +36,7 @@ class Reduction(
|
|||||||
|
|
||||||
|
|
||||||
class ReductionFactory(
|
class ReductionFactory(
|
||||||
RainbowFactory[Reduction[ReductorType, AccumulatorType]],
|
RainbowFactory[Reducible[ReductorType, AccumulatorType]],
|
||||||
Generic[ReductorType, AccumulatorType]
|
Generic[ReductorType, AccumulatorType]
|
||||||
):
|
):
|
||||||
def __init__(
|
def __init__(
|
||||||
@ -54,10 +49,10 @@ class ReductionFactory(
|
|||||||
self.reductor_factory = reductor_factory
|
self.reductor_factory = reductor_factory
|
||||||
self.accumulator_factory = accumulator_factory
|
self.accumulator_factory = accumulator_factory
|
||||||
|
|
||||||
def from_bytes(self, source: bytes, resolver: HashResolver) -> Reduction[ReductorType, AccumulatorType]:
|
def from_bytes(self, source: bytes, resolver: HashResolver) -> Reducible[ReductorType, AccumulatorType]:
|
||||||
assert isinstance(source, bytes)
|
assert isinstance(source, bytes)
|
||||||
assert isinstance(resolver, HashResolver)
|
assert isinstance(resolver, HashResolver)
|
||||||
return Reduction(
|
return Reducible(
|
||||||
ResolverOrigin(self.reductor_factory, source[:HashPoint.HASH_LENGTH], resolver).hash_point(),
|
ResolverOrigin(self.reductor_factory, source[:HashPoint.HASH_LENGTH], resolver).hash_point(),
|
||||||
ResolverOrigin(self.accumulator_factory, source[HashPoint.HASH_LENGTH:], resolver).hash_point(),
|
ResolverOrigin(self.accumulator_factory, source[HashPoint.HASH_LENGTH:], resolver).hash_point(),
|
||||||
)
|
)
|
@ -1,14 +1,12 @@
|
|||||||
from typing import TypeVar
|
from typing import TypeVar
|
||||||
|
|
||||||
from rainbowadn.chain.blockchainprotocol import BlockChainProtocol
|
from rainbowadn.chain.blockchainprotocol import BlockChainProtocol
|
||||||
from rainbowadn.chain.reduction.reduction import Reduction, ReductionFactory
|
from rainbowadn.chain.derivation import *
|
||||||
from rainbowadn.chain.reduction.reductionprotocol import ReductionProtocol
|
from rainbowadn.chain.stages import *
|
||||||
from rainbowadn.chain.reduction.reductionstageprotocol import ReductionStageProtocol
|
from rainbowadn.core import *
|
||||||
from rainbowadn.chain.stages.derivation.activestageprotocol import ActiveStageProtocol
|
from .reducible import *
|
||||||
from rainbowadn.chain.stages.derivation.activestagestateprotocol import ActiveStageStateProtocol
|
from .reductionprotocol import ReductionProtocol
|
||||||
from rainbowadn.chain.stages.stage import StateStage, StateStageFactory
|
from .reductionstageprotocol import ReductionStageProtocol
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
|
||||||
|
|
||||||
__all__ = ('ReductionChainProtocol',)
|
__all__ = ('ReductionChainProtocol',)
|
||||||
|
|
||||||
@ -19,7 +17,7 @@ AccumulatorType = TypeVar('AccumulatorType')
|
|||||||
class ReductionChainProtocol(
|
class ReductionChainProtocol(
|
||||||
BlockChainProtocol[
|
BlockChainProtocol[
|
||||||
ReductorType,
|
ReductorType,
|
||||||
StateStage[ReductorType, AccumulatorType, Reduction[ReductorType, AccumulatorType]],
|
StateStage[ReductorType, AccumulatorType, Reducible[ReductorType, AccumulatorType]],
|
||||||
AccumulatorType
|
AccumulatorType
|
||||||
]
|
]
|
||||||
):
|
):
|
||||||
@ -34,7 +32,7 @@ class ReductionChainProtocol(
|
|||||||
assert isinstance(accumulator_factory, RainbowFactory)
|
assert isinstance(accumulator_factory, RainbowFactory)
|
||||||
|
|
||||||
reduction_factory: RainbowFactory[
|
reduction_factory: RainbowFactory[
|
||||||
Reduction[ReductorType, AccumulatorType]
|
Reducible[ReductorType, AccumulatorType]
|
||||||
] = ReductionFactory(
|
] = ReductionFactory(
|
||||||
reductor_factory, accumulator_factory
|
reductor_factory, accumulator_factory
|
||||||
)
|
)
|
||||||
@ -42,7 +40,7 @@ class ReductionChainProtocol(
|
|||||||
stage_protocol: ActiveStageProtocol[
|
stage_protocol: ActiveStageProtocol[
|
||||||
ReductorType,
|
ReductorType,
|
||||||
AccumulatorType,
|
AccumulatorType,
|
||||||
Reduction[ReductorType, AccumulatorType]
|
Reducible[ReductorType, AccumulatorType]
|
||||||
] = ReductionStageProtocol(protocol)
|
] = ReductionStageProtocol(protocol)
|
||||||
assert isinstance(stage_protocol, ActiveStageProtocol)
|
assert isinstance(stage_protocol, ActiveStageProtocol)
|
||||||
|
|
||||||
@ -71,7 +69,7 @@ class ReductionChainProtocol(
|
|||||||
state: StateStage[
|
state: StateStage[
|
||||||
ReductorType,
|
ReductorType,
|
||||||
AccumulatorType,
|
AccumulatorType,
|
||||||
Reduction[ReductorType, AccumulatorType]
|
Reducible[ReductorType, AccumulatorType]
|
||||||
]
|
]
|
||||||
) -> HashPoint[AccumulatorType]:
|
) -> HashPoint[AccumulatorType]:
|
||||||
assert isinstance(state, StateStage)
|
assert isinstance(state, StateStage)
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.chain.reduction.reduction import Reduction
|
from rainbowadn.core import *
|
||||||
from rainbowadn.chain.reduction.reductionresult import ReductionResult
|
from .reducible import Reducible
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from .reductionresult import ReductionResult
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
|
||||||
|
|
||||||
__all__ = ('ReductionProtocol',)
|
__all__ = ('ReductionProtocol',)
|
||||||
|
|
||||||
@ -14,7 +13,7 @@ AccumulatorType = TypeVar('AccumulatorType')
|
|||||||
class ReductionProtocol(Generic[ReductorType, AccumulatorType]):
|
class ReductionProtocol(Generic[ReductorType, AccumulatorType]):
|
||||||
async def reduce(
|
async def reduce(
|
||||||
self,
|
self,
|
||||||
reduction: Reduction[ReductorType, AccumulatorType]
|
reduce: Reducible[ReductorType, AccumulatorType]
|
||||||
) -> ReductionResult[ReductorType, AccumulatorType]:
|
) -> ReductionResult[ReductorType, AccumulatorType]:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.chain.reduction.reduced import Reduced
|
from rainbowadn.chain.derivation import *
|
||||||
from rainbowadn.chain.reduction.reduction import Reduction
|
from rainbowadn.core import *
|
||||||
from rainbowadn.chain.reduction.reductionprotocol import ReductionProtocol
|
from rainbowadn.nullability import *
|
||||||
from rainbowadn.chain.reduction.reductionresult import ReductionResult
|
from .reduced import Reduced
|
||||||
from rainbowadn.chain.stages.derivation.activestageprotocol import ActiveStageProtocol
|
from .reducible import Reducible
|
||||||
from rainbowadn.chain.stages.derivation.derived import Derived
|
from .reductionprotocol import ReductionProtocol
|
||||||
from rainbowadn.chain.stages.derivation.derivedstage import DerivedStage
|
from .reductionresult import ReductionResult
|
||||||
from rainbowadn.chain.stages.derivation.derivedstate import DerivedState
|
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
|
||||||
from rainbowadn.core.nullability.nullablereference import NullableReference
|
|
||||||
|
|
||||||
__all__ = ('ReductionStageProtocol',)
|
__all__ = ('ReductionStageProtocol',)
|
||||||
|
|
||||||
@ -18,7 +15,7 @@ AccumulatorType = TypeVar('AccumulatorType')
|
|||||||
|
|
||||||
|
|
||||||
class ReductionStageProtocol(
|
class ReductionStageProtocol(
|
||||||
ActiveStageProtocol[ReductorType, AccumulatorType, Reduction[ReductorType, AccumulatorType]],
|
ActiveStageProtocol[ReductorType, AccumulatorType, Reducible[ReductorType, AccumulatorType]],
|
||||||
Generic[ReductorType, AccumulatorType]
|
Generic[ReductorType, AccumulatorType]
|
||||||
):
|
):
|
||||||
def __init__(self, protocol: ReductionProtocol[ReductorType, AccumulatorType]):
|
def __init__(self, protocol: ReductionProtocol[ReductorType, AccumulatorType]):
|
||||||
@ -40,11 +37,11 @@ class ReductionStageProtocol(
|
|||||||
self,
|
self,
|
||||||
previous: NullableReference[AccumulatorType],
|
previous: NullableReference[AccumulatorType],
|
||||||
header: HashPoint[ReductorType]
|
header: HashPoint[ReductorType]
|
||||||
) -> HashPoint[Reduction[ReductorType, AccumulatorType]]:
|
) -> HashPoint[Reducible[ReductorType, AccumulatorType]]:
|
||||||
assert isinstance(previous, NullableReference)
|
assert isinstance(previous, NullableReference)
|
||||||
assert isinstance(header, HashPoint)
|
assert isinstance(header, HashPoint)
|
||||||
return HashPoint.of(
|
return HashPoint.of(
|
||||||
Reduction(
|
Reducible(
|
||||||
header,
|
header,
|
||||||
await self._derive_accumulator(previous)
|
await self._derive_accumulator(previous)
|
||||||
)
|
)
|
||||||
@ -54,9 +51,9 @@ class ReductionStageProtocol(
|
|||||||
def _derived_from_reduced(
|
def _derived_from_reduced(
|
||||||
cls,
|
cls,
|
||||||
reduced: ReductionResult[ReductorType, AccumulatorType]
|
reduced: ReductionResult[ReductorType, AccumulatorType]
|
||||||
) -> Derived[ReductorType, Reduction[ReductorType, AccumulatorType]]:
|
) -> Derived[ReductorType, Reducible[ReductorType, AccumulatorType]]:
|
||||||
assert isinstance(reduced, ReductionResult)
|
assert isinstance(reduced, ReductionResult)
|
||||||
if isinstance(reduced, Reduction):
|
if isinstance(reduced, Reducible):
|
||||||
return DerivedStage(HashPoint.of(reduced))
|
return DerivedStage(HashPoint.of(reduced))
|
||||||
elif isinstance(reduced, Reduced):
|
elif isinstance(reduced, Reduced):
|
||||||
return DerivedState(reduced.reduced)
|
return DerivedState(reduced.reduced)
|
||||||
@ -65,7 +62,7 @@ class ReductionStageProtocol(
|
|||||||
|
|
||||||
async def derive_stage_or_state(
|
async def derive_stage_or_state(
|
||||||
self,
|
self,
|
||||||
stage: HashPoint[Reduction[ReductorType, AccumulatorType]]
|
stage: HashPoint[Reducible[ReductorType, AccumulatorType]]
|
||||||
) -> Derived[ReductorType, Reduction[ReductorType, AccumulatorType]]:
|
) -> Derived[ReductorType, Reducible[ReductorType, AccumulatorType]]:
|
||||||
assert isinstance(stage, HashPoint)
|
assert isinstance(stage, HashPoint)
|
||||||
return self._derived_from_reduced(await self.protocol.reduce(await stage.resolve()))
|
return self._derived_from_reduced(await self.protocol.reduce(await stage.resolve()))
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.chain.abstractreductionchainmetafactory import AbstractReductionChainMetaFactory
|
from rainbowadn.core import *
|
||||||
from rainbowadn.chain.block import Block
|
from .block import Block
|
||||||
from rainbowadn.chain.blockchain import BlockChainFactory
|
from .blockchain import BlockChainFactory
|
||||||
from rainbowadn.chain.chaincollectionfactory import ChainCollectionFactory
|
from .chaincollectionfactory import ChainCollectionFactory
|
||||||
from rainbowadn.chain.reduction.reduction import Reduction
|
from .reduction import *
|
||||||
from rainbowadn.chain.reduction.reductionchainprotocol import ReductionChainProtocol
|
from .stages import *
|
||||||
from rainbowadn.chain.reduction.reductionprotocol import ReductionProtocol
|
|
||||||
from rainbowadn.chain.stages.stage import StateStage
|
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
|
||||||
|
|
||||||
__all__ = ('ReductionChainMetaFactory',)
|
__all__ = ('ReductionChainMetaFactory',)
|
||||||
|
|
||||||
@ -20,7 +17,7 @@ class ReductionChainMetaFactory(
|
|||||||
AbstractReductionChainMetaFactory[
|
AbstractReductionChainMetaFactory[
|
||||||
Block[
|
Block[
|
||||||
ReductorType,
|
ReductorType,
|
||||||
StateStage[ReductorType, AccumulatorType, Reduction[ReductorType, AccumulatorType]]
|
StateStage[ReductorType, AccumulatorType, Reducible[ReductorType, AccumulatorType]]
|
||||||
],
|
],
|
||||||
ReductorType,
|
ReductorType,
|
||||||
AccumulatorType
|
AccumulatorType
|
||||||
@ -35,7 +32,7 @@ class ReductionChainMetaFactory(
|
|||||||
) -> ChainCollectionFactory[
|
) -> ChainCollectionFactory[
|
||||||
Block[
|
Block[
|
||||||
ReductorType,
|
ReductorType,
|
||||||
StateStage[ReductorType, AccumulatorType, Reduction[ReductorType, AccumulatorType]]
|
StateStage[ReductorType, AccumulatorType, Reducible[ReductorType, AccumulatorType]]
|
||||||
],
|
],
|
||||||
ReductorType,
|
ReductorType,
|
||||||
AccumulatorType
|
AccumulatorType
|
||||||
@ -54,7 +51,7 @@ class ReductionChainMetaFactory(
|
|||||||
def loose(self) -> AbstractReductionChainMetaFactory[
|
def loose(self) -> AbstractReductionChainMetaFactory[
|
||||||
Block[
|
Block[
|
||||||
ReductorType,
|
ReductorType,
|
||||||
StateStage[ReductorType, AccumulatorType, Reduction[ReductorType, AccumulatorType]]
|
StateStage[ReductorType, AccumulatorType, Reducible[ReductorType, AccumulatorType]]
|
||||||
],
|
],
|
||||||
ReductorType,
|
ReductorType,
|
||||||
AccumulatorType
|
AccumulatorType
|
@ -0,0 +1,3 @@
|
|||||||
|
from .stageprotocol import StageProtocol
|
||||||
|
from .stagestate import *
|
||||||
|
from .stagestateprotocol import StageStateProtocol
|
@ -1,7 +1,7 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.nullability.nullablereference import NullableReference
|
from rainbowadn.nullability import *
|
||||||
|
|
||||||
__all__ = ('StageProtocol',)
|
__all__ = ('StageProtocol',)
|
||||||
|
|
||||||
|
@ -1,15 +1,8 @@
|
|||||||
from typing import Generic, Iterable, TypeVar
|
from typing import Generic, Iterable, TypeVar
|
||||||
|
|
||||||
from rainbowadn.chain.stages.stageprotocol import StageProtocol
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.asserts import assert_true
|
from rainbowadn.nullability import *
|
||||||
from rainbowadn.core.hash_point_format import hash_point_format, tabulate
|
from .stageprotocol import StageProtocol
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
|
||||||
from rainbowadn.core.hashresolver import HashResolver
|
|
||||||
from rainbowadn.core.nullability.null import Null
|
|
||||||
from rainbowadn.core.nullability.nullablereference import NullableReference, NullableReferenceFactory
|
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
|
||||||
from rainbowadn.core.recursivementionable import RecursiveMentionable
|
|
||||||
from rainbowadn.core.resolverorigin import ResolverOrigin
|
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'StageStage',
|
'StageStage',
|
@ -1,10 +1,9 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.chain.stages.stage import StateStage
|
from rainbowadn.chain.states import *
|
||||||
from rainbowadn.chain.states.stateprotocol import StateProtocol
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.asserts import assert_true
|
from rainbowadn.nullability import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from .stagestate import StateStage
|
||||||
from rainbowadn.core.nullability.nullablereference import NullableReference
|
|
||||||
|
|
||||||
__all__ = ('StageStateProtocol',)
|
__all__ = ('StageStateProtocol',)
|
||||||
|
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
from .activestateprotocol import ActiveStateProtocol
|
||||||
|
from .metareductionstateprotocol import MetaReductionStateProtocol
|
||||||
|
from .stateprotocol import StateProtocol
|
@ -1,9 +1,8 @@
|
|||||||
from typing import TypeVar
|
from typing import TypeVar
|
||||||
|
|
||||||
from rainbowadn.chain.states.stateprotocol import StateProtocol
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.asserts import assert_eq
|
from rainbowadn.nullability import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from .stateprotocol import StateProtocol
|
||||||
from rainbowadn.core.nullability.nullablereference import NullableReference
|
|
||||||
|
|
||||||
__all__ = ('ActiveStateProtocol',)
|
__all__ = ('ActiveStateProtocol',)
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
from typing import TypeVar
|
from typing import TypeVar
|
||||||
|
|
||||||
from rainbowadn.chain.states.activestateprotocol import ActiveStateProtocol
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.asserts import assert_eq
|
from rainbowadn.nullability import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from .activestateprotocol import ActiveStateProtocol
|
||||||
from rainbowadn.core.nullability.nullablereference import NullableReference
|
|
||||||
|
|
||||||
__all__ = ('MetaReductionStateProtocol',)
|
__all__ = ('MetaReductionStateProtocol',)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.nullability.nullablereference import NullableReference
|
from rainbowadn.nullability import *
|
||||||
|
|
||||||
__all__ = ('StateProtocol',)
|
__all__ = ('StateProtocol',)
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.nullability.nullablereference import NullableReference
|
from rainbowadn.nullability import *
|
||||||
|
|
||||||
__all__ = ('CollectionInterface',)
|
__all__ = ('CollectionInterface',)
|
||||||
|
|
4
rainbowadn/collection/comparison/__init__.py
Normal file
4
rainbowadn/collection/comparison/__init__.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
from .comparator import *
|
||||||
|
from .hashcomparator import HashComparator
|
||||||
|
from .keyedcomparator import KeyedComparator
|
||||||
|
from .plaincomparator import PlainComparator
|
@ -1,7 +1,7 @@
|
|||||||
import abc
|
import abc
|
||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.core import *
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'Comparison',
|
'Comparison',
|
@ -1,8 +1,8 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.core import *
|
||||||
from rainbowadn.data.collection.trees.comparison.comparator import Comparison, Left, Right
|
from .comparator import *
|
||||||
from rainbowadn.data.collection.trees.comparison.protocolcomparator import ProtocolComparator
|
from .protocolcomparator import ProtocolComparator
|
||||||
|
|
||||||
__all__ = ('HashComparator',)
|
__all__ = ('HashComparator',)
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.collection.keyed import Keyed
|
||||||
from rainbowadn.data.collection.keyed import Keyed
|
from rainbowadn.core import *
|
||||||
from rainbowadn.data.collection.trees.comparison.comparator import Comparator, Comparison
|
from .comparator import *
|
||||||
|
|
||||||
__all__ = ('KeyedComparator',)
|
__all__ = ('KeyedComparator',)
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.atomic.plain import Plain
|
||||||
from rainbowadn.data.atomic.plain import Plain
|
from rainbowadn.core import *
|
||||||
from rainbowadn.data.collection.trees.comparison.comparator import Comparison, Left, Right
|
from .comparator import *
|
||||||
from rainbowadn.data.collection.trees.comparison.protocolcomparator import ProtocolComparator
|
from .protocolcomparator import ProtocolComparator
|
||||||
|
|
||||||
__all__ = ('PlainComparator',)
|
__all__ = ('PlainComparator',)
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
import abc
|
import abc
|
||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.data.collection.trees.comparison.comparator import Comparator, Equal
|
from .comparator import *
|
||||||
|
|
||||||
__all__ = ('ProtocolComparator',)
|
__all__ = ('ProtocolComparator',)
|
||||||
|
|
@ -1,8 +1,7 @@
|
|||||||
import abc
|
import abc
|
||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.recursivementionable import RecursiveMentionable
|
|
||||||
|
|
||||||
__all__ = ('Keyed',)
|
__all__ = ('Keyed',)
|
||||||
|
|
@ -1,11 +1,7 @@
|
|||||||
from typing import Generic, Iterable, TypeVar
|
from typing import Generic, Iterable, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hash_point_format import hash_point_format, tabulate
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from .keyed import Keyed
|
||||||
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',)
|
__all__ = ('KeyMetadata', 'KeyMetadataFactory',)
|
||||||
|
|
@ -1,10 +1,7 @@
|
|||||||
from typing import Generic, Iterable, TypeVar
|
from typing import Generic, Iterable, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.hashresolver import HashResolver
|
from .keyed import Keyed
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
|
||||||
from rainbowadn.core.resolverorigin import ResolverOrigin
|
|
||||||
from rainbowadn.data.collection.keyed import Keyed
|
|
||||||
|
|
||||||
__all__ = ('KeyValue', 'KeyValueFactory',)
|
__all__ = ('KeyValue', 'KeyValueFactory',)
|
||||||
|
|
2
rainbowadn/collection/linear/__init__.py
Normal file
2
rainbowadn/collection/linear/__init__.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
from .array import *
|
||||||
|
from .stack import *
|
@ -1,11 +1,6 @@
|
|||||||
from typing import Generic, Iterable, TypeVar
|
from typing import Generic, Iterable, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hash_point_format import hash_point_format, tabulate
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
|
||||||
from rainbowadn.core.hashresolver import HashResolver
|
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
|
||||||
from rainbowadn.core.recursivementionable import RecursiveMentionable
|
|
||||||
from rainbowadn.core.resolverorigin import ResolverOrigin
|
|
||||||
|
|
||||||
__all__ = ('Array', 'ArrayFactory',)
|
__all__ = ('Array', 'ArrayFactory',)
|
||||||
|
|
@ -1,13 +1,7 @@
|
|||||||
from typing import AsyncIterable, Generic, Iterable, TypeVar
|
from typing import AsyncIterable, Generic, Iterable, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hash_point_format import hash_point_format, tabulate
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.nullability import *
|
||||||
from rainbowadn.core.hashresolver import HashResolver
|
|
||||||
from rainbowadn.core.nullability.null import Null
|
|
||||||
from rainbowadn.core.nullability.nullablereference import NullableReference, NullableReferenceFactory
|
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
|
||||||
from rainbowadn.core.recursivementionable import RecursiveMentionable
|
|
||||||
from rainbowadn.core.resolverorigin import ResolverOrigin
|
|
||||||
|
|
||||||
__all__ = ('Stack', 'StackFactory',)
|
__all__ = ('Stack', 'StackFactory',)
|
||||||
|
|
@ -1,11 +1,6 @@
|
|||||||
from typing import Generic, Iterable, TypeVar
|
from typing import Generic, Iterable, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hash_point_format import hash_point_format, tabulate
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
|
||||||
from rainbowadn.core.hashresolver import HashResolver
|
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
|
||||||
from rainbowadn.core.recursivementionable import RecursiveMentionable
|
|
||||||
from rainbowadn.core.resolverorigin import ResolverOrigin
|
|
||||||
|
|
||||||
__all__ = ('Pair', 'PairFactory',)
|
__all__ = ('Pair', 'PairFactory',)
|
||||||
|
|
3
rainbowadn/collection/trees/binary/__init__.py
Normal file
3
rainbowadn/collection/trees/binary/__init__.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from .activebinarytree import ActiveBinaryTree
|
||||||
|
from .avl import AVL
|
||||||
|
from .binarytree import *
|
3
rainbowadn/collection/trees/binary/actions/__init__.py
Normal file
3
rainbowadn/collection/trees/binary/actions/__init__.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from .binaryaction import BinaryAction
|
||||||
|
from .stdactions import *
|
||||||
|
from .symmetric import *
|
@ -1,11 +1,9 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.data.collection.trees.binary.binaryprotocolized import BinaryProtocolized
|
from rainbowadn.collection.trees.binary.core import *
|
||||||
|
|
||||||
__all__ = ('BinaryAction',)
|
__all__ = ('BinaryAction',)
|
||||||
|
|
||||||
from rainbowadn.data.collection.trees.binary.protocolizedbinarysplit import ProtocolizedBinarySplit
|
|
||||||
|
|
||||||
TreeType = TypeVar('TreeType')
|
TreeType = TypeVar('TreeType')
|
||||||
ActiveKeyType = TypeVar('ActiveKeyType')
|
ActiveKeyType = TypeVar('ActiveKeyType')
|
||||||
MetaDataType = TypeVar('MetaDataType')
|
MetaDataType = TypeVar('MetaDataType')
|
@ -1,10 +1,10 @@
|
|||||||
import abc
|
import abc
|
||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.collection.comparison import *
|
||||||
from rainbowadn.data.collection.trees.binary.actions.binaryaction import BinaryAction
|
from rainbowadn.collection.trees.binary.core import *
|
||||||
from rainbowadn.data.collection.trees.binary.protocolizedbinarysplit import ProtocolizedBinarySplit
|
from rainbowadn.core import *
|
||||||
from rainbowadn.data.collection.trees.comparison.comparator import Comparison, Equal, Left, Right
|
from .binaryaction import BinaryAction
|
||||||
|
|
||||||
__all__ = ('CompareAction',)
|
__all__ = ('CompareAction',)
|
||||||
|
|
@ -1,10 +1,9 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.data.collection.trees.binary.actions.binaryaction import BinaryAction
|
from rainbowadn.collection.comparison import *
|
||||||
from rainbowadn.data.collection.trees.binary.actions.compareaction import CompareAction
|
from rainbowadn.collection.trees.binary.core import *
|
||||||
from rainbowadn.data.collection.trees.binary.binaryprotocolized import BinaryProtocolized
|
from .binaryaction import BinaryAction
|
||||||
from rainbowadn.data.collection.trees.binary.protocolizedbinarysplit import ProtocolizedBinarySplit
|
from .compareaction import CompareAction
|
||||||
from rainbowadn.data.collection.trees.comparison.comparator import Equal, Replace
|
|
||||||
|
|
||||||
__all__ = ('AddAction', 'RemoveAction', 'ContainsAction',)
|
__all__ = ('AddAction', 'RemoveAction', 'ContainsAction',)
|
||||||
|
|
||||||
@ -57,7 +56,7 @@ class AddAction(
|
|||||||
protocolized: BinaryProtocolized[ActiveKeyType, MetaDataType, TreeType],
|
protocolized: BinaryProtocolized[ActiveKeyType, MetaDataType, TreeType],
|
||||||
) -> TreeType:
|
) -> TreeType:
|
||||||
assert isinstance(protocolized, BinaryProtocolized)
|
assert isinstance(protocolized, BinaryProtocolized)
|
||||||
return await protocolized.protocol.tree(protocolized.tree, protocolized.tree, self.key)
|
return await protocolized.creation.tree(protocolized.tree, protocolized.tree, self.key)
|
||||||
|
|
||||||
|
|
||||||
class MergeAction(
|
class MergeAction(
|
@ -1,9 +1,7 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.collection.trees.binary.core import *
|
||||||
from rainbowadn.data.collection.trees.binary.binarycreation import BinaryCreation
|
from rainbowadn.core import *
|
||||||
from rainbowadn.data.collection.trees.binary.binaryprotocolized import BinaryProtocolized
|
|
||||||
from rainbowadn.data.collection.trees.binary.binarysplit import BinarySplit
|
|
||||||
|
|
||||||
__all__ = ('Symmetric', 'InnerOuter', 'OuterInner',)
|
__all__ = ('Symmetric', 'InnerOuter', 'OuterInner',)
|
||||||
|
|
@ -1,18 +1,12 @@
|
|||||||
from typing import Generic, Optional, TypeVar
|
from typing import Generic, Optional, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.collection.collectioninterface import CollectionInterface
|
||||||
from rainbowadn.core.nullability.null import Null
|
from rainbowadn.collection.keymetadata import *
|
||||||
from rainbowadn.core.nullability.nullablereference import NullableReference
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
from rainbowadn.nullability import *
|
||||||
from rainbowadn.data.collection.collection_interface.collectioninterface import CollectionInterface
|
from .actions import *
|
||||||
from rainbowadn.data.collection.keymetadata import KeyMetadata, KeyMetadataFactory
|
from .binarytree import *
|
||||||
from rainbowadn.data.collection.trees.binary.actions.stdactions import AddAction, ContainsAction, RemoveAction
|
from .core import *
|
||||||
from rainbowadn.data.collection.trees.binary.balancedcreation import BalancedCreation
|
|
||||||
from rainbowadn.data.collection.trees.binary.binarybalancing import BinaryBalancing
|
|
||||||
from rainbowadn.data.collection.trees.binary.binarycreation import BinaryCreation
|
|
||||||
from rainbowadn.data.collection.trees.binary.binaryprotocolized import BinaryProtocolized
|
|
||||||
from rainbowadn.data.collection.trees.binary.binarysplit import BinarySplit
|
|
||||||
from rainbowadn.data.collection.trees.binary.binarytree import BinaryTree, BinaryTreeFactory
|
|
||||||
|
|
||||||
__all__ = ('ActiveBinaryTree',)
|
__all__ = ('ActiveBinaryTree',)
|
||||||
|
|
@ -1,14 +1,9 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.atomic import *
|
||||||
from rainbowadn.data.atomic.integer import Integer
|
from rainbowadn.core import *
|
||||||
from rainbowadn.data.collection.trees.binary.actions.binaryaction import BinaryAction
|
from .actions import *
|
||||||
from rainbowadn.data.collection.trees.binary.actions.symmetric import InnerOuter, OuterInner, Symmetric
|
from .core import *
|
||||||
from rainbowadn.data.collection.trees.binary.binarybalancing import BinaryBalancing
|
|
||||||
from rainbowadn.data.collection.trees.binary.binarycreation import BinaryCreation
|
|
||||||
from rainbowadn.data.collection.trees.binary.binaryprotocolized import BinaryProtocolized
|
|
||||||
from rainbowadn.data.collection.trees.binary.binarysplit import BinarySplit
|
|
||||||
from rainbowadn.data.collection.trees.binary.protocolizedbinarysplit import ProtocolizedBinarySplit
|
|
||||||
|
|
||||||
__all__ = ('AVL',)
|
__all__ = ('AVL',)
|
||||||
|
|
||||||
@ -25,16 +20,16 @@ class AVL(BinaryBalancing[ActiveKeyType, Integer, TreeType]):
|
|||||||
treel: TreeType,
|
treel: TreeType,
|
||||||
treer: TreeType,
|
treer: TreeType,
|
||||||
key: HashPoint[ActiveKeyType],
|
key: HashPoint[ActiveKeyType],
|
||||||
protocol: BinaryCreation[ActiveKeyType, Integer, TreeType]
|
creation: BinaryCreation[ActiveKeyType, Integer, TreeType]
|
||||||
) -> HashPoint[Integer]:
|
) -> HashPoint[Integer]:
|
||||||
assert isinstance(protocol, BinaryCreation)
|
assert isinstance(creation, BinaryCreation)
|
||||||
return HashPoint.of(
|
return HashPoint.of(
|
||||||
Integer(
|
Integer(
|
||||||
1
|
1
|
||||||
+
|
+
|
||||||
max(
|
max(
|
||||||
await self.height(BinaryProtocolized(protocol, treel)),
|
await self.height(BinaryProtocolized(creation, treel)),
|
||||||
await self.height(BinaryProtocolized(protocol, treer))
|
await self.height(BinaryProtocolized(creation, treer))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -97,26 +92,26 @@ class BalanceAction(
|
|||||||
@classmethod
|
@classmethod
|
||||||
async def on_symmetric(
|
async def on_symmetric(
|
||||||
cls,
|
cls,
|
||||||
symmetric: Symmetric[ActiveKeyType, Integer, TreeType],
|
symmetry: Symmetric[ActiveKeyType, Integer, TreeType],
|
||||||
split: BinarySplit[ActiveKeyType, Integer, TreeType]
|
split: BinarySplit[ActiveKeyType, Integer, TreeType]
|
||||||
) -> TreeType:
|
) -> TreeType:
|
||||||
assert isinstance(symmetric, Symmetric)
|
assert isinstance(symmetry, Symmetric)
|
||||||
assert isinstance(split, BinarySplit)
|
assert isinstance(split, BinarySplit)
|
||||||
splito = await symmetric.protocol.fsplit(symmetric.outer(split))
|
splito = await symmetry.protocol.fsplit(symmetry.outer(split))
|
||||||
if (
|
if (
|
||||||
(await AVL.height(symmetric.protocolizedi(splito)))
|
(await AVL.height(symmetry.protocolizedi(splito)))
|
||||||
>
|
>
|
||||||
(await AVL.height(symmetric.protocolizedo(splito)))
|
(await AVL.height(symmetry.protocolizedo(splito)))
|
||||||
):
|
):
|
||||||
splitoi = await symmetric.protocol.fsplit(symmetric.inner(splito))
|
splitoi = await symmetry.protocol.fsplit(symmetry.inner(splito))
|
||||||
return await symmetric.tree(
|
return await symmetry.tree(
|
||||||
await symmetric.tree(symmetric.inner(split), symmetric.inner(splitoi), split.key),
|
await symmetry.tree(symmetry.inner(split), symmetry.inner(splitoi), split.key),
|
||||||
await symmetric.tree(symmetric.outer(splitoi), symmetric.outer(splito), splito.key),
|
await symmetry.tree(symmetry.outer(splitoi), symmetry.outer(splito), splito.key),
|
||||||
splitoi.key
|
splitoi.key
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return await symmetric.tree(
|
return await symmetry.tree(
|
||||||
await symmetric.tree(symmetric.inner(split), symmetric.inner(splito), split.key),
|
await symmetry.tree(symmetry.inner(split), symmetry.inner(splito), split.key),
|
||||||
symmetric.outer(splito),
|
symmetry.outer(splito),
|
||||||
splito.key
|
splito.key
|
||||||
)
|
)
|
@ -1,12 +1,7 @@
|
|||||||
from typing import Generic, Iterable, TypeVar
|
from typing import Generic, Iterable, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hash_point_format import hash_point_format, tabulate
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.nullability import *
|
||||||
from rainbowadn.core.hashresolver import HashResolver
|
|
||||||
from rainbowadn.core.nullability.nullablereference import NullableReference, NullableReferenceFactory
|
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
|
||||||
from rainbowadn.core.recursivementionable import RecursiveMentionable
|
|
||||||
from rainbowadn.core.resolverorigin import ResolverOrigin
|
|
||||||
|
|
||||||
__all__ = ('BinaryTree', 'BinaryTreeFactory',)
|
__all__ = ('BinaryTree', 'BinaryTreeFactory',)
|
||||||
|
|
6
rainbowadn/collection/trees/binary/core/__init__.py
Normal file
6
rainbowadn/collection/trees/binary/core/__init__.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
from .balancedcreation import BalancedCreation
|
||||||
|
from .binarybalancing import BinaryBalancing
|
||||||
|
from .binarycreation import BinaryCreation
|
||||||
|
from .binaryprotocolized import BinaryProtocolized
|
||||||
|
from .binarysplit import BinarySplit
|
||||||
|
from .protocolizedbinarysplit import ProtocolizedBinarySplit
|
@ -1,14 +1,13 @@
|
|||||||
import abc
|
import abc
|
||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.core import *
|
||||||
from rainbowadn.data.collection.trees.binary.binarybalancing import BinaryBalancing
|
from .binarybalancing import BinaryBalancing
|
||||||
from rainbowadn.data.collection.trees.binary.binarycreation import BinaryCreation
|
from .binarycreation import BinaryCreation
|
||||||
|
from .binaryprotocolized import BinaryProtocolized
|
||||||
|
|
||||||
__all__ = ('BalancedCreation',)
|
__all__ = ('BalancedCreation',)
|
||||||
|
|
||||||
from rainbowadn.data.collection.trees.binary.binaryprotocolized import BinaryProtocolized
|
|
||||||
|
|
||||||
TreeType = TypeVar('TreeType')
|
TreeType = TypeVar('TreeType')
|
||||||
ActiveKeyType = TypeVar('ActiveKeyType')
|
ActiveKeyType = TypeVar('ActiveKeyType')
|
||||||
MetaDataType = TypeVar('MetaDataType')
|
MetaDataType = TypeVar('MetaDataType')
|
@ -1,9 +1,9 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.collection.comparison import *
|
||||||
from rainbowadn.data.collection.trees.binary.binarycreation import BinaryCreation
|
from rainbowadn.core import *
|
||||||
from rainbowadn.data.collection.trees.binary.binaryprotocolized import BinaryProtocolized
|
from .binarycreation import BinaryCreation
|
||||||
from rainbowadn.data.collection.trees.comparison.comparator import Comparator
|
from .binaryprotocolized import BinaryProtocolized
|
||||||
|
|
||||||
__all__ = ('BinaryBalancing',)
|
__all__ = ('BinaryBalancing',)
|
||||||
|
|
||||||
@ -13,12 +13,9 @@ MetaDataType = TypeVar('MetaDataType')
|
|||||||
|
|
||||||
|
|
||||||
class BinaryBalancing(Generic[ActiveKeyType, MetaDataType, TreeType]):
|
class BinaryBalancing(Generic[ActiveKeyType, MetaDataType, TreeType]):
|
||||||
def __init__(
|
def __init__(self, comparator_: Comparator[ActiveKeyType]):
|
||||||
self,
|
assert isinstance(comparator_, Comparator)
|
||||||
comparator: Comparator[ActiveKeyType]
|
self.comparator = comparator_
|
||||||
):
|
|
||||||
assert isinstance(comparator, Comparator)
|
|
||||||
self.comparator = comparator
|
|
||||||
|
|
||||||
def empty_metadata(self) -> HashPoint[MetaDataType]:
|
def empty_metadata(self) -> HashPoint[MetaDataType]:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
@ -28,7 +25,7 @@ class BinaryBalancing(Generic[ActiveKeyType, MetaDataType, TreeType]):
|
|||||||
treel: TreeType,
|
treel: TreeType,
|
||||||
treer: TreeType,
|
treer: TreeType,
|
||||||
key: HashPoint[ActiveKeyType],
|
key: HashPoint[ActiveKeyType],
|
||||||
protocol: BinaryCreation[ActiveKeyType, MetaDataType, TreeType]
|
creation: BinaryCreation[ActiveKeyType, MetaDataType, TreeType]
|
||||||
) -> HashPoint[MetaDataType]:
|
) -> HashPoint[MetaDataType]:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
from typing import Generic, Optional, TypeVar
|
from typing import Generic, Optional, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.collection.comparison import *
|
||||||
from rainbowadn.data.collection.trees.binary.binarysplit import BinarySplit
|
from rainbowadn.core import *
|
||||||
from rainbowadn.data.collection.trees.comparison.comparator import Comparator
|
from .binarysplit import BinarySplit
|
||||||
|
|
||||||
__all__ = ('BinaryCreation',)
|
__all__ = ('BinaryCreation',)
|
||||||
|
|
||||||
@ -12,8 +12,9 @@ MetaDataType = TypeVar('MetaDataType')
|
|||||||
|
|
||||||
|
|
||||||
class BinaryCreation(Generic[ActiveKeyType, MetaDataType, TreeType]):
|
class BinaryCreation(Generic[ActiveKeyType, MetaDataType, TreeType]):
|
||||||
def __init__(self, comparator: Comparator[ActiveKeyType]):
|
def __init__(self, comparator_: Comparator[ActiveKeyType]):
|
||||||
self.comparator = comparator
|
assert isinstance(comparator_, Comparator)
|
||||||
|
self.comparator = comparator_
|
||||||
|
|
||||||
async def split(self, tree: TreeType) -> Optional[
|
async def split(self, tree: TreeType) -> Optional[
|
||||||
BinarySplit[ActiveKeyType, MetaDataType, TreeType]
|
BinarySplit[ActiveKeyType, MetaDataType, TreeType]
|
@ -1,7 +1,7 @@
|
|||||||
from typing import Generic, Optional, TypeVar
|
from typing import Generic, Optional, TypeVar
|
||||||
|
|
||||||
from rainbowadn.data.collection.trees.binary.binarycreation import BinaryCreation
|
from .binarycreation import BinaryCreation
|
||||||
from rainbowadn.data.collection.trees.binary.binarysplit import BinarySplit
|
from .binarysplit import BinarySplit
|
||||||
|
|
||||||
__all__ = ('BinaryProtocolized',)
|
__all__ = ('BinaryProtocolized',)
|
||||||
|
|
||||||
@ -15,12 +15,12 @@ class BinaryProtocolized(
|
|||||||
):
|
):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
protocol: BinaryCreation[ActiveKeyType, MetaDataType, TreeType],
|
creation: BinaryCreation[ActiveKeyType, MetaDataType, TreeType],
|
||||||
tree: TreeType
|
tree: TreeType
|
||||||
):
|
):
|
||||||
assert isinstance(protocol, BinaryCreation)
|
assert isinstance(creation, BinaryCreation)
|
||||||
self.protocol = protocol
|
self.creation = creation
|
||||||
self.tree = tree
|
self.tree = tree
|
||||||
|
|
||||||
async def split(self) -> Optional[BinarySplit[ActiveKeyType, MetaDataType, TreeType]]:
|
async def split(self) -> Optional[BinarySplit[ActiveKeyType, MetaDataType, TreeType]]:
|
||||||
return await self.protocol.split(self.tree)
|
return await self.creation.split(self.tree)
|
@ -1,6 +1,6 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from rainbowadn.core import *
|
||||||
|
|
||||||
__all__ = ('BinarySplit',)
|
__all__ = ('BinarySplit',)
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
from typing import Generic, Optional, TypeVar
|
from typing import Generic, Optional, TypeVar
|
||||||
|
|
||||||
from rainbowadn.data.collection.trees.binary.binarycreation import BinaryCreation
|
from .binarycreation import BinaryCreation
|
||||||
from rainbowadn.data.collection.trees.binary.binaryprotocolized import BinaryProtocolized
|
from .binaryprotocolized import BinaryProtocolized
|
||||||
from rainbowadn.data.collection.trees.binary.binarysplit import BinarySplit
|
from .binarysplit import BinarySplit
|
||||||
|
|
||||||
__all__ = ('ProtocolizedBinarySplit',)
|
__all__ = ('ProtocolizedBinarySplit',)
|
||||||
|
|
||||||
@ -45,4 +45,4 @@ class ProtocolizedBinarySplit(
|
|||||||
if (split := await protocolized.split()) is None:
|
if (split := await protocolized.split()) is None:
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
return ProtocolizedBinarySplit(protocolized.protocol, split, protocolized.tree)
|
return ProtocolizedBinarySplit(protocolized.creation, split, protocolized.tree)
|
@ -0,0 +1,15 @@
|
|||||||
|
from .asserts import *
|
||||||
|
from .extendableresolver import ExtendableResolver
|
||||||
|
from .hash_point_format import *
|
||||||
|
from .hashpoint import HashPoint
|
||||||
|
from .hashresolver import HashResolver
|
||||||
|
from .localmetaorigin import LocalMetaOrigin
|
||||||
|
from .localorigin import LocalOrigin
|
||||||
|
from .mentionable import Mentionable
|
||||||
|
from .metaorigin import MetaOrigin
|
||||||
|
from .origin import Origin
|
||||||
|
from .rainbow_factory import RainbowFactory
|
||||||
|
from .recursivementionable import RecursiveMentionable
|
||||||
|
from .resolvermetaorigin import ResolverMetaOrigin
|
||||||
|
from .resolverorigin import ResolverOrigin
|
||||||
|
from .static import *
|
@ -1,5 +1,7 @@
|
|||||||
from typing import Optional, TypeVar
|
from typing import Optional, TypeVar
|
||||||
|
|
||||||
|
__all__ = ('assert_true', 'assert_false', 'assert_none', 'assert_eq',)
|
||||||
|
|
||||||
|
|
||||||
def assert_true(value: bool) -> bool:
|
def assert_true(value: bool) -> bool:
|
||||||
assert value is True
|
assert value is True
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
import abc
|
import abc
|
||||||
from typing import TypeVar
|
from typing import TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from .hashpoint import HashPoint
|
||||||
from rainbowadn.core.hashresolver import HashResolver
|
from .hashresolver import HashResolver
|
||||||
from rainbowadn.core.resolvermetaorigin import ResolverMetaOrigin
|
from .resolvermetaorigin import ResolverMetaOrigin
|
||||||
|
|
||||||
|
__all__ = ('ExtendableResolver',)
|
||||||
|
|
||||||
Mentioned = TypeVar('Mentioned')
|
Mentioned = TypeVar('Mentioned')
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from rainbowadn.core.hashpoint import HashPoint
|
from .hashpoint import HashPoint
|
||||||
from rainbowadn.core.mentionable import Mentionable
|
from .mentionable import Mentionable
|
||||||
from rainbowadn.core.recursivementionable import RecursiveMentionable
|
from .recursivementionable import RecursiveMentionable
|
||||||
|
|
||||||
__all__ = ('hash_point_format', 'tabulate',)
|
__all__ = ('hash_point_format', 'tabulate',)
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.asserts import assert_eq
|
from .asserts import *
|
||||||
from rainbowadn.core.localorigin import LocalOrigin
|
from .localorigin import LocalOrigin
|
||||||
from rainbowadn.core.mentionable import Mentionable
|
from .mentionable import Mentionable
|
||||||
from rainbowadn.core.origin import Origin
|
from .origin import Origin
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
from .rainbow_factory import RainbowFactory
|
||||||
|
|
||||||
__all__ = ('HashPoint',)
|
__all__ = ('HashPoint',)
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.asserts import assert_eq
|
from .asserts import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from .hashpoint import HashPoint
|
||||||
from rainbowadn.core.metaorigin import MetaOrigin
|
from .metaorigin import MetaOrigin
|
||||||
from rainbowadn.core.origin import Origin
|
from .origin import Origin
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
from .rainbow_factory import RainbowFactory
|
||||||
|
|
||||||
__all__ = ('LocalMetaOrigin',)
|
__all__ = ('LocalMetaOrigin',)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.mentionable import Mentionable
|
from .mentionable import Mentionable
|
||||||
from rainbowadn.core.origin import Origin
|
from .origin import Origin
|
||||||
|
|
||||||
__all__ = ('LocalOrigin',)
|
__all__ = ('LocalOrigin',)
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from typing import TypeVar
|
from typing import TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
from .rainbow_factory import RainbowFactory
|
||||||
|
|
||||||
__all__ = ('Mentionable',)
|
__all__ = ('Mentionable',)
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.asserts import assert_eq
|
from .asserts import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from .hashpoint import HashPoint
|
||||||
from rainbowadn.core.origin import Origin
|
from .origin import Origin
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
from .rainbow_factory import RainbowFactory
|
||||||
|
|
||||||
__all__ = ('MetaOrigin',)
|
__all__ = ('MetaOrigin',)
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
from .rainbow_factory import RainbowFactory
|
||||||
|
|
||||||
__all__ = ('Origin',)
|
__all__ = ('Origin',)
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hashresolver import HashResolver
|
from .hashresolver import HashResolver
|
||||||
|
|
||||||
__all__ = ('RainbowFactory',)
|
__all__ = ('RainbowFactory',)
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import abc
|
import abc
|
||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
|
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from .hashpoint import HashPoint
|
||||||
from rainbowadn.core.mentionable import Mentionable
|
from .mentionable import Mentionable
|
||||||
|
|
||||||
__all__ = ('RecursiveMentionable',)
|
__all__ = ('RecursiveMentionable',)
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.asserts import assert_eq
|
from .asserts import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from .hashpoint import HashPoint
|
||||||
from rainbowadn.core.hashresolver import HashResolver
|
from .hashresolver import HashResolver
|
||||||
from rainbowadn.core.metaorigin import MetaOrigin
|
from .metaorigin import MetaOrigin
|
||||||
from rainbowadn.core.origin import Origin
|
from .origin import Origin
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
from .rainbow_factory import RainbowFactory
|
||||||
from rainbowadn.core.resolverorigin import ResolverOrigin
|
from .resolverorigin import ResolverOrigin
|
||||||
|
|
||||||
__all__ = ('ResolverMetaOrigin',)
|
__all__ = ('ResolverMetaOrigin',)
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.asserts import assert_eq
|
from .asserts import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from .hashpoint import HashPoint
|
||||||
from rainbowadn.core.hashresolver import HashResolver
|
from .hashresolver import HashResolver
|
||||||
from rainbowadn.core.mentionable import Mentionable
|
from .mentionable import Mentionable
|
||||||
from rainbowadn.core.origin import Origin
|
from .origin import Origin
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
from .rainbow_factory import RainbowFactory
|
||||||
|
|
||||||
__all__ = ('ResolverOrigin',)
|
__all__ = ('ResolverOrigin',)
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import abc
|
import abc
|
||||||
from typing import Generic, Type, TypeVar
|
from typing import Generic, Type, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hashresolver import HashResolver
|
from .hashresolver import HashResolver
|
||||||
from rainbowadn.core.mentionable import Mentionable
|
from .mentionable import Mentionable
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
from .rainbow_factory import RainbowFactory
|
||||||
|
|
||||||
__all__ = ('StaticMentionable', 'StaticFactory',)
|
__all__ = ('StaticMentionable', 'StaticFactory',)
|
||||||
|
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
from .encrypted import *
|
@ -3,14 +3,7 @@ from typing import Generic, Iterable, TypeVar
|
|||||||
from nacl.bindings import crypto_hash_sha256
|
from nacl.bindings import crypto_hash_sha256
|
||||||
from nacl.secret import SecretBox
|
from nacl.secret import SecretBox
|
||||||
|
|
||||||
from rainbowadn.core.asserts import assert_eq
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
|
||||||
from rainbowadn.core.hashresolver import HashResolver
|
|
||||||
from rainbowadn.core.mentionable import Mentionable
|
|
||||||
from rainbowadn.core.origin import Origin
|
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
|
||||||
from rainbowadn.core.recursivementionable import RecursiveMentionable
|
|
||||||
from rainbowadn.core.resolverorigin import ResolverOrigin
|
|
||||||
|
|
||||||
__all__ = ('Encrypted', 'EncryptedFactory')
|
__all__ = ('Encrypted', 'EncryptedFactory')
|
||||||
|
|
||||||
@ -49,9 +42,9 @@ class Encrypted(RecursiveMentionable, Generic[EncryptedType]):
|
|||||||
hashpoints = tuple(decrypted.points()) if isinstance(decrypted, RecursiveMentionable) else ()
|
hashpoints = tuple(decrypted.points()) if isinstance(decrypted, RecursiveMentionable) else ()
|
||||||
resolution: tuple[HashPoint[Encrypted[EncryptedType]], ...] = tuple(
|
resolution: tuple[HashPoint[Encrypted[EncryptedType]], ...] = tuple(
|
||||||
[
|
[
|
||||||
await cls.encrypt_hashpoint(hashpoint, key)
|
await cls.encrypt_hashpoint(hash_point, key)
|
||||||
for
|
for
|
||||||
hashpoint
|
hash_point
|
||||||
in
|
in
|
||||||
hashpoints
|
hashpoints
|
||||||
]
|
]
|
||||||
@ -65,20 +58,20 @@ class Encrypted(RecursiveMentionable, Generic[EncryptedType]):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def encrypt_hashpoint(
|
async def encrypt_hashpoint(
|
||||||
cls, hashpoint: HashPoint[EncryptedType], key: bytes
|
cls, hash_point: HashPoint[EncryptedType], key: bytes
|
||||||
) -> HashPoint['Encrypted[EncryptedType]']:
|
) -> HashPoint['Encrypted[EncryptedType]']:
|
||||||
assert isinstance(hashpoint, HashPoint)
|
assert isinstance(hash_point, HashPoint)
|
||||||
assert isinstance(key, bytes)
|
assert isinstance(key, bytes)
|
||||||
if isinstance(hashpoint.origin, ResolverOrigin):
|
if isinstance(hash_point.origin, ResolverOrigin):
|
||||||
resolver: HashResolver = hashpoint.origin.resolver
|
resolver: HashResolver = hash_point.origin.resolver
|
||||||
assert isinstance(resolver, HashResolver)
|
assert isinstance(resolver, HashResolver)
|
||||||
if isinstance(resolver, EncryptedResolver) and resolver.key == key:
|
if isinstance(resolver, EncryptedResolver) and resolver.key == key:
|
||||||
return ShortcutOrigin(
|
return ShortcutOrigin(
|
||||||
hashpoint.factory,
|
hash_point.factory,
|
||||||
resolver.mapping[hashpoint.point],
|
resolver.mapping[hash_point.point],
|
||||||
key
|
key
|
||||||
).hash_point()
|
).hash_point()
|
||||||
return HashPoint.of(await cls.encrypt(await hashpoint.resolve(), key))
|
return HashPoint.of(await cls.encrypt(await hash_point.resolve(), key))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def construct(
|
def construct(
|
||||||
@ -89,7 +82,7 @@ class Encrypted(RecursiveMentionable, Generic[EncryptedType]):
|
|||||||
decrypted: EncryptedType
|
decrypted: EncryptedType
|
||||||
) -> 'Encrypted[EncryptedType]':
|
) -> 'Encrypted[EncryptedType]':
|
||||||
mapping: dict[bytes, HashPoint[Encrypted]] = {
|
mapping: dict[bytes, HashPoint[Encrypted]] = {
|
||||||
hashpoint.point: encrypted for hashpoint, encrypted in zip(hashpoints, resolution)
|
hash_point.point: encrypted for hash_point, encrypted in zip(hashpoints, resolution)
|
||||||
}
|
}
|
||||||
return Encrypted(
|
return Encrypted(
|
||||||
key,
|
key,
|
||||||
@ -136,12 +129,12 @@ class EncryptedFactory(RainbowFactory[Encrypted[EncryptedType]], Generic[Encrypt
|
|||||||
resolution: tuple[HashPoint[Encrypted], ...] = tuple(
|
resolution: tuple[HashPoint[Encrypted], ...] = tuple(
|
||||||
ResolverOrigin(
|
ResolverOrigin(
|
||||||
EncryptedFactory(
|
EncryptedFactory(
|
||||||
hashpoint.factory,
|
hash_point.factory,
|
||||||
self.key
|
self.key
|
||||||
),
|
),
|
||||||
plain[8 + i * HashPoint.HASH_LENGTH: 8 + (i + 1) * HashPoint.HASH_LENGTH],
|
plain[8 + i * HashPoint.HASH_LENGTH: 8 + (i + 1) * HashPoint.HASH_LENGTH],
|
||||||
resolver
|
resolver
|
||||||
).hash_point() for i, hashpoint in enumerate(hashpoints)
|
).hash_point() for i, hash_point in enumerate(hashpoints)
|
||||||
)
|
)
|
||||||
return Encrypted.construct(
|
return Encrypted.construct(
|
||||||
self.key,
|
self.key,
|
||||||
@ -165,13 +158,13 @@ class EncryptedResolver(HashResolver):
|
|||||||
|
|
||||||
|
|
||||||
class ShortcutOrigin(Origin[Encrypted[EncryptedType]], Generic[EncryptedType]):
|
class ShortcutOrigin(Origin[Encrypted[EncryptedType]], Generic[EncryptedType]):
|
||||||
def __init__(self, factory: RainbowFactory[EncryptedType], hashpoint: HashPoint[Encrypted], key: bytes):
|
def __init__(self, factory: RainbowFactory[EncryptedType], hash_point: HashPoint[Encrypted], key: bytes):
|
||||||
assert isinstance(factory, RainbowFactory)
|
assert isinstance(factory, RainbowFactory)
|
||||||
assert isinstance(hashpoint, HashPoint)
|
assert isinstance(hash_point, HashPoint)
|
||||||
assert isinstance(key, bytes)
|
assert isinstance(key, bytes)
|
||||||
self.factory: RainbowFactory[Encrypted[EncryptedType]] = EncryptedFactory(factory, key)
|
self.factory: RainbowFactory[Encrypted[EncryptedType]] = EncryptedFactory(factory, key)
|
||||||
assert isinstance(self.factory, RainbowFactory)
|
assert isinstance(self.factory, RainbowFactory)
|
||||||
self.hashpoint = hashpoint
|
self.hashpoint = hash_point
|
||||||
super().__init__(self.factory)
|
super().__init__(self.factory)
|
||||||
|
|
||||||
async def resolve(self) -> Encrypted[EncryptedType]:
|
async def resolve(self) -> Encrypted[EncryptedType]:
|
||||||
@ -191,7 +184,7 @@ class ShortcutResolver(HashResolver):
|
|||||||
def __init__(self, encrypted: Encrypted):
|
def __init__(self, encrypted: Encrypted):
|
||||||
assert isinstance(encrypted, Encrypted)
|
assert isinstance(encrypted, Encrypted)
|
||||||
self.mapping: dict[bytes, HashPoint[Encrypted]] = {
|
self.mapping: dict[bytes, HashPoint[Encrypted]] = {
|
||||||
hashpoint.point: hashpoint for hashpoint in encrypted.resolution
|
hash_point.point: hash_point for hash_point in encrypted.resolution
|
||||||
}
|
}
|
||||||
|
|
||||||
async def resolve(self, point: bytes) -> tuple[bytes, 'HashResolver']:
|
async def resolve(self, point: bytes) -> tuple[bytes, 'HashResolver']:
|
||||||
|
4
rainbowadn/nullability/__init__.py
Normal file
4
rainbowadn/nullability/__init__.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
from .notnull import NotNull
|
||||||
|
from .null import Null
|
||||||
|
from .nullable import Nullable
|
||||||
|
from .nullablereference import *
|
@ -1,6 +1,6 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.nullability.nullable import Nullable
|
from .nullable import Nullable
|
||||||
|
|
||||||
__all__ = ('NotNull',)
|
__all__ = ('NotNull',)
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
from typing import Generic, TypeVar
|
from typing import Generic, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.nullability.nullable import Nullable
|
from .nullable import Nullable
|
||||||
|
|
||||||
__all__ = ('Null',)
|
__all__ = ('Null',)
|
||||||
|
|
@ -1,14 +1,9 @@
|
|||||||
from typing import Generic, Iterable, TypeVar
|
from typing import Generic, Iterable, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.hash_point_format import hash_point_format
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
from .notnull import NotNull
|
||||||
from rainbowadn.core.hashresolver import HashResolver
|
from .null import Null
|
||||||
from rainbowadn.core.nullability.notnull import NotNull
|
from .nullable import Nullable
|
||||||
from rainbowadn.core.nullability.null import Null
|
|
||||||
from rainbowadn.core.nullability.nullable import Nullable
|
|
||||||
from rainbowadn.core.rainbow_factory import RainbowFactory
|
|
||||||
from rainbowadn.core.recursivementionable import RecursiveMentionable
|
|
||||||
from rainbowadn.core.resolverorigin import ResolverOrigin
|
|
||||||
|
|
||||||
__all__ = ('NullableReference', 'NullableReferenceFactory',)
|
__all__ = ('NullableReference', 'NullableReferenceFactory',)
|
||||||
|
|
@ -1,11 +1,11 @@
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from typing import MutableMapping
|
from typing import MutableMapping, TypeVar
|
||||||
|
|
||||||
from rainbowadn.core.extendableresolver import ExtendableResolver, Mentioned
|
from rainbowadn.core import *
|
||||||
from rainbowadn.core.hashpoint import HashPoint
|
|
||||||
from rainbowadn.core.hashresolver import HashResolver
|
__all__ = ('DictResolver',)
|
||||||
from rainbowadn.core.mentionable import Mentionable
|
|
||||||
from rainbowadn.core.recursivementionable import RecursiveMentionable
|
Mentioned = TypeVar('Mentioned')
|
||||||
|
|
||||||
|
|
||||||
class DictResolver(ExtendableResolver):
|
class DictResolver(ExtendableResolver):
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user