restructured

This commit is contained in:
AF 2022-06-21 21:17:28 +03:00
parent e61650dc7f
commit b7d0cbdcf3
118 changed files with 454 additions and 531 deletions

View File

@ -0,0 +1,3 @@
from .atomic import Atomic
from .integer import Integer
from .plain import Plain

View File

@ -1,9 +1,7 @@
import abc
from typing import Type, TypeVar
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core.hashresolver import HashResolver
from rainbowadn.core.static import StaticMentionable
from rainbowadn.core import *
__all__ = ('Atomic',)

View File

@ -1,4 +1,4 @@
from rainbowadn.data.atomic.atomic import Atomic
from .atomic import Atomic
__all__ = ('Integer',)

View File

@ -1,4 +1,4 @@
from rainbowadn.data.atomic.atomic import Atomic
from .atomic import Atomic
__all__ = ('Plain',)

View File

@ -0,0 +1,5 @@
from .blockchain import *
from .blockchainprotocol import BlockChainProtocol
from .chaincollectionfactory import ChainCollectionFactory
from .chaincollectioninterface import ChainCollectionInterface
from .reductionchainmetafactory import ReductionChainMetaFactory

View File

@ -1,12 +1,7 @@
from typing import Generic, Iterable, TypeVar
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.nullability.nullablereference import NullableReference, NullableReferenceFactory
from rainbowadn.core.rainbow_factory import RainbowFactory
from rainbowadn.core.recursivementionable import RecursiveMentionable
from rainbowadn.core.resolverorigin import ResolverOrigin
from rainbowadn.core import *
from rainbowadn.nullability import *
__all__ = ('Block', 'BlockFactory',)

View File

@ -1,15 +1,12 @@
import asyncio
from typing import Generic, TypeVar
from rainbowadn.chain.block import Block, BlockFactory
from rainbowadn.chain.blockchainprotocol import BlockChainProtocol
from rainbowadn.chain.chaincollectionfactory import ChainCollectionFactory
from rainbowadn.chain.chaincollectioninterface import ChainCollectionInterface
from rainbowadn.core.asserts import assert_eq, assert_true
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 import *
from rainbowadn.nullability import *
from .block import *
from .blockchainprotocol import BlockChainProtocol
from .chaincollectionfactory import ChainCollectionFactory
from .chaincollectioninterface import ChainCollectionInterface
__all__ = ('BlockChain', 'BlockChainFactory',)

View File

@ -1,8 +1,7 @@
from typing import Generic, TypeVar
from rainbowadn.chain.states.activestateprotocol import ActiveStateProtocol
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core.rainbow_factory import RainbowFactory
from rainbowadn.core import *
from .states import *
__all__ = ('BlockChainProtocol',)

View File

@ -1,10 +1,8 @@
from typing import Generic, 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.collection.collectioninterface import CollectionInterface
from rainbowadn.core import *
from rainbowadn.nullability import *
__all__ = ('BlockCollectionInterface',)

View File

@ -1,7 +1,7 @@
from typing import Generic, TypeVar
from rainbowadn.chain.chaincollectioninterface import ChainCollectionInterface
from rainbowadn.core.nullability.nullablereference import NullableReference
from rainbowadn.nullability import *
from .chaincollectioninterface import ChainCollectionInterface
__all__ = ('ChainCollectionFactory',)

View File

@ -1,8 +1,8 @@
import abc
from typing import Generic, TypeVar
from rainbowadn.chain.blockcollectioninterface import BlockCollectionInterface
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core import *
from .blockcollectioninterface import BlockCollectionInterface
__all__ = ('ChainCollectionInterface',)

View 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

View File

@ -1,15 +1,11 @@
from typing import Generic, TypeVar
from rainbowadn.chain.stages.derivation.derived import Derived
from rainbowadn.chain.stages.derivation.derivedstage import DerivedStage
from rainbowadn.chain.stages.derivation.derivedstate import DerivedState
from rainbowadn.chain.stages.stage import StageStage, StageStageFactory, StateStage
from rainbowadn.chain.stages.stageprotocol import StageProtocol
from rainbowadn.core.asserts import assert_eq
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.chain.stages import *
from rainbowadn.core import *
from rainbowadn.nullability import *
from .derived import Derived
from .derivedstage import DerivedStage
from .derivedstate import DerivedState
__all__ = ('ActiveStageProtocol',)

View File

@ -1,11 +1,10 @@
from typing import TypeVar
from rainbowadn.chain.stages.derivation.activestageprotocol import ActiveStageProtocol
from rainbowadn.chain.stages.stage import StateStage
from rainbowadn.chain.states.activestateprotocol import ActiveStateProtocol
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core.nullability.nullablereference import NullableReference
from rainbowadn.core.rainbow_factory import RainbowFactory
from rainbowadn.chain.stages import *
from rainbowadn.chain.states import *
from rainbowadn.core import *
from rainbowadn.nullability import *
from .activestageprotocol import ActiveStageProtocol
__all__ = ('ActiveStageStateProtocol',)
@ -62,3 +61,10 @@ class ActiveStageStateProtocol(
self.base_state_factory,
self.stage_factory
)
@classmethod
def stage_state_protocol(cls) -> StateProtocol[
HeaderType,
StateStage[HeaderType, BaseStateType, StageType]
]:
return StageStateProtocol()

View File

@ -1,7 +1,7 @@
from typing import Generic, TypeVar
from rainbowadn.chain.stages.derivation.derived import Derived
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core import *
from .derived import Derived
__all__ = ('DerivedStage',)

View File

@ -1,7 +1,7 @@
from typing import Generic, TypeVar
from rainbowadn.chain.stages.derivation.derived import Derived
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core import *
from .derived import Derived
__all__ = ('DerivedState',)

View File

@ -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

View File

@ -1,8 +1,8 @@
from typing import Generic, TypeVar
from rainbowadn.chain.chaincollectionfactory import ChainCollectionFactory
from rainbowadn.chain.reduction.reductionprotocol import ReductionProtocol
from rainbowadn.core.rainbow_factory import RainbowFactory
from rainbowadn.core import *
from .reductionprotocol import ReductionProtocol
__all__ = ('AbstractReductionChainMetaFactory',)

View File

@ -1,7 +1,7 @@
from typing import Generic, TypeVar
from rainbowadn.chain.reduction.reductionresult import ReductionResult
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core import *
from .reductionresult import ReductionResult
__all__ = ('Reduced',)

View File

@ -1,20 +1,15 @@
from typing import Generic, Iterable, TypeVar
from rainbowadn.chain.reduction.reductionresult import ReductionResult
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.recursivementionable import RecursiveMentionable
from rainbowadn.core.resolverorigin import ResolverOrigin
from rainbowadn.core import *
from .reductionresult import ReductionResult
__all__ = ('Reduction', 'ReductionFactory',)
__all__ = ('Reducible', 'ReductionFactory',)
ReductorType = TypeVar('ReductorType')
AccumulatorType = TypeVar('AccumulatorType')
class Reduction(
class Reducible(
ReductionResult[ReductorType, AccumulatorType],
RecursiveMentionable,
Generic[ReductorType, AccumulatorType]
@ -31,7 +26,7 @@ class Reduction(
def __bytes__(self):
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)
async def str(self, tab: int) -> str:
@ -41,7 +36,7 @@ class Reduction(
class ReductionFactory(
RainbowFactory[Reduction[ReductorType, AccumulatorType]],
RainbowFactory[Reducible[ReductorType, AccumulatorType]],
Generic[ReductorType, AccumulatorType]
):
def __init__(
@ -54,10 +49,10 @@ class ReductionFactory(
self.reductor_factory = reductor_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(resolver, HashResolver)
return Reduction(
return Reducible(
ResolverOrigin(self.reductor_factory, source[:HashPoint.HASH_LENGTH], resolver).hash_point(),
ResolverOrigin(self.accumulator_factory, source[HashPoint.HASH_LENGTH:], resolver).hash_point(),
)

View File

@ -1,14 +1,12 @@
from typing import TypeVar
from rainbowadn.chain.blockchainprotocol import BlockChainProtocol
from rainbowadn.chain.reduction.reduction import Reduction, ReductionFactory
from rainbowadn.chain.reduction.reductionprotocol import ReductionProtocol
from rainbowadn.chain.reduction.reductionstageprotocol import ReductionStageProtocol
from rainbowadn.chain.stages.derivation.activestageprotocol import ActiveStageProtocol
from rainbowadn.chain.stages.derivation.activestagestateprotocol import ActiveStageStateProtocol
from rainbowadn.chain.stages.stage import StateStage, StateStageFactory
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core.rainbow_factory import RainbowFactory
from rainbowadn.chain.derivation import *
from rainbowadn.chain.stages import *
from rainbowadn.core import *
from .reducible import *
from .reductionprotocol import ReductionProtocol
from .reductionstageprotocol import ReductionStageProtocol
__all__ = ('ReductionChainProtocol',)
@ -19,7 +17,7 @@ AccumulatorType = TypeVar('AccumulatorType')
class ReductionChainProtocol(
BlockChainProtocol[
ReductorType,
StateStage[ReductorType, AccumulatorType, Reduction[ReductorType, AccumulatorType]],
StateStage[ReductorType, AccumulatorType, Reducible[ReductorType, AccumulatorType]],
AccumulatorType
]
):
@ -34,7 +32,7 @@ class ReductionChainProtocol(
assert isinstance(accumulator_factory, RainbowFactory)
reduction_factory: RainbowFactory[
Reduction[ReductorType, AccumulatorType]
Reducible[ReductorType, AccumulatorType]
] = ReductionFactory(
reductor_factory, accumulator_factory
)
@ -42,7 +40,7 @@ class ReductionChainProtocol(
stage_protocol: ActiveStageProtocol[
ReductorType,
AccumulatorType,
Reduction[ReductorType, AccumulatorType]
Reducible[ReductorType, AccumulatorType]
] = ReductionStageProtocol(protocol)
assert isinstance(stage_protocol, ActiveStageProtocol)
@ -71,7 +69,7 @@ class ReductionChainProtocol(
state: StateStage[
ReductorType,
AccumulatorType,
Reduction[ReductorType, AccumulatorType]
Reducible[ReductorType, AccumulatorType]
]
) -> HashPoint[AccumulatorType]:
assert isinstance(state, StateStage)

View File

@ -1,9 +1,8 @@
from typing import Generic, TypeVar
from rainbowadn.chain.reduction.reduction import Reduction
from rainbowadn.chain.reduction.reductionresult import ReductionResult
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core.rainbow_factory import RainbowFactory
from rainbowadn.core import *
from .reducible import Reducible
from .reductionresult import ReductionResult
__all__ = ('ReductionProtocol',)
@ -14,7 +13,7 @@ AccumulatorType = TypeVar('AccumulatorType')
class ReductionProtocol(Generic[ReductorType, AccumulatorType]):
async def reduce(
self,
reduction: Reduction[ReductorType, AccumulatorType]
reduce: Reducible[ReductorType, AccumulatorType]
) -> ReductionResult[ReductorType, AccumulatorType]:
raise NotImplementedError

View File

@ -1,15 +1,12 @@
from typing import Generic, TypeVar
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.chain.stages.derivation.activestageprotocol import ActiveStageProtocol
from rainbowadn.chain.stages.derivation.derived import Derived
from rainbowadn.chain.stages.derivation.derivedstage import DerivedStage
from rainbowadn.chain.stages.derivation.derivedstate import DerivedState
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core.nullability.nullablereference import NullableReference
from rainbowadn.chain.derivation import *
from rainbowadn.core import *
from rainbowadn.nullability import *
from .reduced import Reduced
from .reducible import Reducible
from .reductionprotocol import ReductionProtocol
from .reductionresult import ReductionResult
__all__ = ('ReductionStageProtocol',)
@ -18,7 +15,7 @@ AccumulatorType = TypeVar('AccumulatorType')
class ReductionStageProtocol(
ActiveStageProtocol[ReductorType, AccumulatorType, Reduction[ReductorType, AccumulatorType]],
ActiveStageProtocol[ReductorType, AccumulatorType, Reducible[ReductorType, AccumulatorType]],
Generic[ReductorType, AccumulatorType]
):
def __init__(self, protocol: ReductionProtocol[ReductorType, AccumulatorType]):
@ -40,11 +37,11 @@ class ReductionStageProtocol(
self,
previous: NullableReference[AccumulatorType],
header: HashPoint[ReductorType]
) -> HashPoint[Reduction[ReductorType, AccumulatorType]]:
) -> HashPoint[Reducible[ReductorType, AccumulatorType]]:
assert isinstance(previous, NullableReference)
assert isinstance(header, HashPoint)
return HashPoint.of(
Reduction(
Reducible(
header,
await self._derive_accumulator(previous)
)
@ -54,9 +51,9 @@ class ReductionStageProtocol(
def _derived_from_reduced(
cls,
reduced: ReductionResult[ReductorType, AccumulatorType]
) -> Derived[ReductorType, Reduction[ReductorType, AccumulatorType]]:
) -> Derived[ReductorType, Reducible[ReductorType, AccumulatorType]]:
assert isinstance(reduced, ReductionResult)
if isinstance(reduced, Reduction):
if isinstance(reduced, Reducible):
return DerivedStage(HashPoint.of(reduced))
elif isinstance(reduced, Reduced):
return DerivedState(reduced.reduced)
@ -65,7 +62,7 @@ class ReductionStageProtocol(
async def derive_stage_or_state(
self,
stage: HashPoint[Reduction[ReductorType, AccumulatorType]]
) -> Derived[ReductorType, Reduction[ReductorType, AccumulatorType]]:
stage: HashPoint[Reducible[ReductorType, AccumulatorType]]
) -> Derived[ReductorType, Reducible[ReductorType, AccumulatorType]]:
assert isinstance(stage, HashPoint)
return self._derived_from_reduced(await self.protocol.reduce(await stage.resolve()))

View File

@ -1,14 +1,11 @@
from typing import Generic, TypeVar
from rainbowadn.chain.abstractreductionchainmetafactory import AbstractReductionChainMetaFactory
from rainbowadn.chain.block import Block
from rainbowadn.chain.blockchain import BlockChainFactory
from rainbowadn.chain.chaincollectionfactory import ChainCollectionFactory
from rainbowadn.chain.reduction.reduction import Reduction
from rainbowadn.chain.reduction.reductionchainprotocol import ReductionChainProtocol
from rainbowadn.chain.reduction.reductionprotocol import ReductionProtocol
from rainbowadn.chain.stages.stage import StateStage
from rainbowadn.core.rainbow_factory import RainbowFactory
from rainbowadn.core import *
from .block import Block
from .blockchain import BlockChainFactory
from .chaincollectionfactory import ChainCollectionFactory
from .reduction import *
from .stages import *
__all__ = ('ReductionChainMetaFactory',)
@ -20,7 +17,7 @@ class ReductionChainMetaFactory(
AbstractReductionChainMetaFactory[
Block[
ReductorType,
StateStage[ReductorType, AccumulatorType, Reduction[ReductorType, AccumulatorType]]
StateStage[ReductorType, AccumulatorType, Reducible[ReductorType, AccumulatorType]]
],
ReductorType,
AccumulatorType
@ -35,7 +32,7 @@ class ReductionChainMetaFactory(
) -> ChainCollectionFactory[
Block[
ReductorType,
StateStage[ReductorType, AccumulatorType, Reduction[ReductorType, AccumulatorType]]
StateStage[ReductorType, AccumulatorType, Reducible[ReductorType, AccumulatorType]]
],
ReductorType,
AccumulatorType
@ -54,7 +51,7 @@ class ReductionChainMetaFactory(
def loose(self) -> AbstractReductionChainMetaFactory[
Block[
ReductorType,
StateStage[ReductorType, AccumulatorType, Reduction[ReductorType, AccumulatorType]]
StateStage[ReductorType, AccumulatorType, Reducible[ReductorType, AccumulatorType]]
],
ReductorType,
AccumulatorType

View File

@ -0,0 +1,3 @@
from .stageprotocol import StageProtocol
from .stagestate import *
from .stagestateprotocol import StageStateProtocol

View File

@ -1,7 +1,7 @@
from typing import Generic, TypeVar
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core.nullability.nullablereference import NullableReference
from rainbowadn.core import *
from rainbowadn.nullability import *
__all__ = ('StageProtocol',)

View File

@ -1,15 +1,8 @@
from typing import Generic, Iterable, TypeVar
from rainbowadn.chain.stages.stageprotocol import StageProtocol
from rainbowadn.core.asserts import assert_true
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.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
from rainbowadn.core import *
from rainbowadn.nullability import *
from .stageprotocol import StageProtocol
__all__ = (
'StageStage',

View File

@ -1,10 +1,9 @@
from typing import Generic, TypeVar
from rainbowadn.chain.stages.stage import StateStage
from rainbowadn.chain.states.stateprotocol import StateProtocol
from rainbowadn.core.asserts import assert_true
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core.nullability.nullablereference import NullableReference
from rainbowadn.chain.states import *
from rainbowadn.core import *
from rainbowadn.nullability import *
from .stagestate import StateStage
__all__ = ('StageStateProtocol',)

View File

@ -0,0 +1,3 @@
from .activestateprotocol import ActiveStateProtocol
from .metareductionstateprotocol import MetaReductionStateProtocol
from .stateprotocol import StateProtocol

View File

@ -1,9 +1,8 @@
from typing import TypeVar
from rainbowadn.chain.states.stateprotocol import StateProtocol
from rainbowadn.core.asserts import assert_eq
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core.nullability.nullablereference import NullableReference
from rainbowadn.core import *
from rainbowadn.nullability import *
from .stateprotocol import StateProtocol
__all__ = ('ActiveStateProtocol',)

View File

@ -1,9 +1,8 @@
from typing import TypeVar
from rainbowadn.chain.states.activestateprotocol import ActiveStateProtocol
from rainbowadn.core.asserts import assert_eq
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core.nullability.nullablereference import NullableReference
from rainbowadn.core import *
from rainbowadn.nullability import *
from .activestateprotocol import ActiveStateProtocol
__all__ = ('MetaReductionStateProtocol',)

View File

@ -1,7 +1,7 @@
from typing import Generic, TypeVar
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core.nullability.nullablereference import NullableReference
from rainbowadn.core import *
from rainbowadn.nullability import *
__all__ = ('StateProtocol',)

View File

@ -1,6 +1,6 @@
from typing import Generic, TypeVar
from rainbowadn.core.nullability.nullablereference import NullableReference
from rainbowadn.nullability import *
__all__ = ('CollectionInterface',)

View File

@ -0,0 +1,4 @@
from .comparator import *
from .hashcomparator import HashComparator
from .keyedcomparator import KeyedComparator
from .plaincomparator import PlainComparator

View File

@ -1,7 +1,7 @@
import abc
from typing import Generic, TypeVar
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core import *
__all__ = (
'Comparison',

View File

@ -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 import *
from .comparator import *
from .protocolcomparator import ProtocolComparator
__all__ = ('HashComparator',)

View File

@ -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.collection.keyed import Keyed
from rainbowadn.core import *
from .comparator import *
__all__ = ('KeyedComparator',)

View File

@ -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.atomic.plain import Plain
from rainbowadn.core import *
from .comparator import *
from .protocolcomparator import ProtocolComparator
__all__ = ('PlainComparator',)

View File

@ -1,7 +1,7 @@
import abc
from typing import Generic, TypeVar
from rainbowadn.data.collection.trees.comparison.comparator import Comparator, Equal
from .comparator import *
__all__ = ('ProtocolComparator',)

View File

@ -1,8 +1,7 @@
import abc
from typing import Generic, TypeVar
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core.recursivementionable import RecursiveMentionable
from rainbowadn.core import *
__all__ = ('Keyed',)

View File

@ -1,11 +1,7 @@
from typing import Generic, Iterable, TypeVar
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
from rainbowadn.core import *
from .keyed import Keyed
__all__ = ('KeyMetadata', 'KeyMetadataFactory',)

View File

@ -1,10 +1,7 @@
from typing import Generic, Iterable, TypeVar
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
from rainbowadn.core import *
from .keyed import Keyed
__all__ = ('KeyValue', 'KeyValueFactory',)

View File

@ -0,0 +1,2 @@
from .array import *
from .stack import *

View File

@ -1,11 +1,6 @@
from typing import Generic, Iterable, TypeVar
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.recursivementionable import RecursiveMentionable
from rainbowadn.core.resolverorigin import ResolverOrigin
from rainbowadn.core import *
__all__ = ('Array', 'ArrayFactory',)

View File

@ -1,13 +1,7 @@
from typing import AsyncIterable, Generic, Iterable, TypeVar
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.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
from rainbowadn.core import *
from rainbowadn.nullability import *
__all__ = ('Stack', 'StackFactory',)

View File

@ -1,11 +1,6 @@
from typing import Generic, Iterable, TypeVar
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.recursivementionable import RecursiveMentionable
from rainbowadn.core.resolverorigin import ResolverOrigin
from rainbowadn.core import *
__all__ = ('Pair', 'PairFactory',)

View File

@ -0,0 +1,3 @@
from .activebinarytree import ActiveBinaryTree
from .avl import AVL
from .binarytree import *

View File

@ -0,0 +1,3 @@
from .binaryaction import BinaryAction
from .stdactions import *
from .symmetric import *

View File

@ -1,11 +1,9 @@
from typing import Generic, TypeVar
from rainbowadn.data.collection.trees.binary.binaryprotocolized import BinaryProtocolized
from rainbowadn.collection.trees.binary.core import *
__all__ = ('BinaryAction',)
from rainbowadn.data.collection.trees.binary.protocolizedbinarysplit import ProtocolizedBinarySplit
TreeType = TypeVar('TreeType')
ActiveKeyType = TypeVar('ActiveKeyType')
MetaDataType = TypeVar('MetaDataType')

View File

@ -1,10 +1,10 @@
import abc
from typing import Generic, TypeVar
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.data.collection.trees.binary.actions.binaryaction import BinaryAction
from rainbowadn.data.collection.trees.binary.protocolizedbinarysplit import ProtocolizedBinarySplit
from rainbowadn.data.collection.trees.comparison.comparator import Comparison, Equal, Left, Right
from rainbowadn.collection.comparison import *
from rainbowadn.collection.trees.binary.core import *
from rainbowadn.core import *
from .binaryaction import BinaryAction
__all__ = ('CompareAction',)

View File

@ -1,10 +1,9 @@
from typing import Generic, TypeVar
from rainbowadn.data.collection.trees.binary.actions.binaryaction import BinaryAction
from rainbowadn.data.collection.trees.binary.actions.compareaction import CompareAction
from rainbowadn.data.collection.trees.binary.binaryprotocolized import BinaryProtocolized
from rainbowadn.data.collection.trees.binary.protocolizedbinarysplit import ProtocolizedBinarySplit
from rainbowadn.data.collection.trees.comparison.comparator import Equal, Replace
from rainbowadn.collection.comparison import *
from rainbowadn.collection.trees.binary.core import *
from .binaryaction import BinaryAction
from .compareaction import CompareAction
__all__ = ('AddAction', 'RemoveAction', 'ContainsAction',)
@ -57,7 +56,7 @@ class AddAction(
protocolized: BinaryProtocolized[ActiveKeyType, MetaDataType, TreeType],
) -> TreeType:
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(

View File

@ -1,9 +1,7 @@
from typing import Generic, TypeVar
from rainbowadn.core.hashpoint import HashPoint
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.collection.trees.binary.core import *
from rainbowadn.core import *
__all__ = ('Symmetric', 'InnerOuter', 'OuterInner',)

View File

@ -1,18 +1,12 @@
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
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
from rainbowadn.collection.collectioninterface import CollectionInterface
from rainbowadn.collection.keymetadata import *
from rainbowadn.core import *
from rainbowadn.nullability import *
from .actions import *
from .binarytree import *
from .core import *
__all__ = ('ActiveBinaryTree',)

View File

@ -1,14 +1,9 @@
from typing import Generic, TypeVar
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.data.atomic.integer import Integer
from rainbowadn.data.collection.trees.binary.actions.binaryaction import BinaryAction
from rainbowadn.data.collection.trees.binary.actions.symmetric import InnerOuter, OuterInner, Symmetric
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
from rainbowadn.atomic import *
from rainbowadn.core import *
from .actions import *
from .core import *
__all__ = ('AVL',)
@ -25,16 +20,16 @@ class AVL(BinaryBalancing[ActiveKeyType, Integer, TreeType]):
treel: TreeType,
treer: TreeType,
key: HashPoint[ActiveKeyType],
protocol: BinaryCreation[ActiveKeyType, Integer, TreeType]
creation: BinaryCreation[ActiveKeyType, Integer, TreeType]
) -> HashPoint[Integer]:
assert isinstance(protocol, BinaryCreation)
assert isinstance(creation, BinaryCreation)
return HashPoint.of(
Integer(
1
+
max(
await self.height(BinaryProtocolized(protocol, treel)),
await self.height(BinaryProtocolized(protocol, treer))
await self.height(BinaryProtocolized(creation, treel)),
await self.height(BinaryProtocolized(creation, treer))
)
)
)
@ -97,26 +92,26 @@ class BalanceAction(
@classmethod
async def on_symmetric(
cls,
symmetric: Symmetric[ActiveKeyType, Integer, TreeType],
symmetry: Symmetric[ActiveKeyType, Integer, TreeType],
split: BinarySplit[ActiveKeyType, Integer, TreeType]
) -> TreeType:
assert isinstance(symmetric, Symmetric)
assert isinstance(symmetry, Symmetric)
assert isinstance(split, BinarySplit)
splito = await symmetric.protocol.fsplit(symmetric.outer(split))
splito = await symmetry.protocol.fsplit(symmetry.outer(split))
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))
return await symmetric.tree(
await symmetric.tree(symmetric.inner(split), symmetric.inner(splitoi), split.key),
await symmetric.tree(symmetric.outer(splitoi), symmetric.outer(splito), splito.key),
splitoi = await symmetry.protocol.fsplit(symmetry.inner(splito))
return await symmetry.tree(
await symmetry.tree(symmetry.inner(split), symmetry.inner(splitoi), split.key),
await symmetry.tree(symmetry.outer(splitoi), symmetry.outer(splito), splito.key),
splitoi.key
)
else:
return await symmetric.tree(
await symmetric.tree(symmetric.inner(split), symmetric.inner(splito), split.key),
symmetric.outer(splito),
return await symmetry.tree(
await symmetry.tree(symmetry.inner(split), symmetry.inner(splito), split.key),
symmetry.outer(splito),
splito.key
)

View File

@ -1,12 +1,7 @@
from typing import Generic, Iterable, TypeVar
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.nullability.nullablereference import NullableReference, NullableReferenceFactory
from rainbowadn.core.rainbow_factory import RainbowFactory
from rainbowadn.core.recursivementionable import RecursiveMentionable
from rainbowadn.core.resolverorigin import ResolverOrigin
from rainbowadn.core import *
from rainbowadn.nullability import *
__all__ = ('BinaryTree', 'BinaryTreeFactory',)

View 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

View File

@ -1,14 +1,13 @@
import abc
from typing import Generic, TypeVar
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.data.collection.trees.binary.binarybalancing import BinaryBalancing
from rainbowadn.data.collection.trees.binary.binarycreation import BinaryCreation
from rainbowadn.core import *
from .binarybalancing import BinaryBalancing
from .binarycreation import BinaryCreation
from .binaryprotocolized import BinaryProtocolized
__all__ = ('BalancedCreation',)
from rainbowadn.data.collection.trees.binary.binaryprotocolized import BinaryProtocolized
TreeType = TypeVar('TreeType')
ActiveKeyType = TypeVar('ActiveKeyType')
MetaDataType = TypeVar('MetaDataType')

View File

@ -1,9 +1,9 @@
from typing import Generic, TypeVar
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.data.collection.trees.binary.binarycreation import BinaryCreation
from rainbowadn.data.collection.trees.binary.binaryprotocolized import BinaryProtocolized
from rainbowadn.data.collection.trees.comparison.comparator import Comparator
from rainbowadn.collection.comparison import *
from rainbowadn.core import *
from .binarycreation import BinaryCreation
from .binaryprotocolized import BinaryProtocolized
__all__ = ('BinaryBalancing',)
@ -13,12 +13,9 @@ MetaDataType = TypeVar('MetaDataType')
class BinaryBalancing(Generic[ActiveKeyType, MetaDataType, TreeType]):
def __init__(
self,
comparator: Comparator[ActiveKeyType]
):
assert isinstance(comparator, Comparator)
self.comparator = comparator
def __init__(self, comparator_: Comparator[ActiveKeyType]):
assert isinstance(comparator_, Comparator)
self.comparator = comparator_
def empty_metadata(self) -> HashPoint[MetaDataType]:
raise NotImplementedError
@ -28,7 +25,7 @@ class BinaryBalancing(Generic[ActiveKeyType, MetaDataType, TreeType]):
treel: TreeType,
treer: TreeType,
key: HashPoint[ActiveKeyType],
protocol: BinaryCreation[ActiveKeyType, MetaDataType, TreeType]
creation: BinaryCreation[ActiveKeyType, MetaDataType, TreeType]
) -> HashPoint[MetaDataType]:
raise NotImplementedError

View File

@ -1,8 +1,8 @@
from typing import Generic, Optional, TypeVar
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.data.collection.trees.binary.binarysplit import BinarySplit
from rainbowadn.data.collection.trees.comparison.comparator import Comparator
from rainbowadn.collection.comparison import *
from rainbowadn.core import *
from .binarysplit import BinarySplit
__all__ = ('BinaryCreation',)
@ -12,8 +12,9 @@ MetaDataType = TypeVar('MetaDataType')
class BinaryCreation(Generic[ActiveKeyType, MetaDataType, TreeType]):
def __init__(self, comparator: Comparator[ActiveKeyType]):
self.comparator = comparator
def __init__(self, comparator_: Comparator[ActiveKeyType]):
assert isinstance(comparator_, Comparator)
self.comparator = comparator_
async def split(self, tree: TreeType) -> Optional[
BinarySplit[ActiveKeyType, MetaDataType, TreeType]

View File

@ -1,7 +1,7 @@
from typing import Generic, Optional, TypeVar
from rainbowadn.data.collection.trees.binary.binarycreation import BinaryCreation
from rainbowadn.data.collection.trees.binary.binarysplit import BinarySplit
from .binarycreation import BinaryCreation
from .binarysplit import BinarySplit
__all__ = ('BinaryProtocolized',)
@ -15,12 +15,12 @@ class BinaryProtocolized(
):
def __init__(
self,
protocol: BinaryCreation[ActiveKeyType, MetaDataType, TreeType],
creation: BinaryCreation[ActiveKeyType, MetaDataType, TreeType],
tree: TreeType
):
assert isinstance(protocol, BinaryCreation)
self.protocol = protocol
assert isinstance(creation, BinaryCreation)
self.creation = creation
self.tree = tree
async def split(self) -> Optional[BinarySplit[ActiveKeyType, MetaDataType, TreeType]]:
return await self.protocol.split(self.tree)
return await self.creation.split(self.tree)

View File

@ -1,6 +1,6 @@
from typing import Generic, TypeVar
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core import *
__all__ = ('BinarySplit',)

View File

@ -1,8 +1,8 @@
from typing import Generic, Optional, TypeVar
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 .binarycreation import BinaryCreation
from .binaryprotocolized import BinaryProtocolized
from .binarysplit import BinarySplit
__all__ = ('ProtocolizedBinarySplit',)
@ -45,4 +45,4 @@ class ProtocolizedBinarySplit(
if (split := await protocolized.split()) is None:
return None
else:
return ProtocolizedBinarySplit(protocolized.protocol, split, protocolized.tree)
return ProtocolizedBinarySplit(protocolized.creation, split, protocolized.tree)

View File

@ -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 *

View File

@ -1,5 +1,7 @@
from typing import Optional, TypeVar
__all__ = ('assert_true', 'assert_false', 'assert_none', 'assert_eq',)
def assert_true(value: bool) -> bool:
assert value is True

View File

@ -1,9 +1,11 @@
import abc
from typing import TypeVar
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core.hashresolver import HashResolver
from rainbowadn.core.resolvermetaorigin import ResolverMetaOrigin
from .hashpoint import HashPoint
from .hashresolver import HashResolver
from .resolvermetaorigin import ResolverMetaOrigin
__all__ = ('ExtendableResolver',)
Mentioned = TypeVar('Mentioned')

View File

@ -1,6 +1,6 @@
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core.mentionable import Mentionable
from rainbowadn.core.recursivementionable import RecursiveMentionable
from .hashpoint import HashPoint
from .mentionable import Mentionable
from .recursivementionable import RecursiveMentionable
__all__ = ('hash_point_format', 'tabulate',)

View File

@ -1,11 +1,11 @@
import hashlib
from typing import Generic, TypeVar
from rainbowadn.core.asserts import assert_eq
from rainbowadn.core.localorigin import LocalOrigin
from rainbowadn.core.mentionable import Mentionable
from rainbowadn.core.origin import Origin
from rainbowadn.core.rainbow_factory import RainbowFactory
from .asserts import *
from .localorigin import LocalOrigin
from .mentionable import Mentionable
from .origin import Origin
from .rainbow_factory import RainbowFactory
__all__ = ('HashPoint',)

View File

@ -1,10 +1,10 @@
from typing import Generic, TypeVar
from rainbowadn.core.asserts import assert_eq
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core.metaorigin import MetaOrigin
from rainbowadn.core.origin import Origin
from rainbowadn.core.rainbow_factory import RainbowFactory
from .asserts import *
from .hashpoint import HashPoint
from .metaorigin import MetaOrigin
from .origin import Origin
from .rainbow_factory import RainbowFactory
__all__ = ('LocalMetaOrigin',)

View File

@ -1,7 +1,7 @@
from typing import Generic, TypeVar
from rainbowadn.core.mentionable import Mentionable
from rainbowadn.core.origin import Origin
from .mentionable import Mentionable
from .origin import Origin
__all__ = ('LocalOrigin',)

View File

@ -1,6 +1,6 @@
from typing import TypeVar
from rainbowadn.core.rainbow_factory import RainbowFactory
from .rainbow_factory import RainbowFactory
__all__ = ('Mentionable',)

View File

@ -1,9 +1,9 @@
from typing import Generic, TypeVar
from rainbowadn.core.asserts import assert_eq
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core.origin import Origin
from rainbowadn.core.rainbow_factory import RainbowFactory
from .asserts import *
from .hashpoint import HashPoint
from .origin import Origin
from .rainbow_factory import RainbowFactory
__all__ = ('MetaOrigin',)

View File

@ -1,6 +1,6 @@
from typing import Generic, TypeVar
from rainbowadn.core.rainbow_factory import RainbowFactory
from .rainbow_factory import RainbowFactory
__all__ = ('Origin',)

View File

@ -1,6 +1,6 @@
from typing import Generic, TypeVar
from rainbowadn.core.hashresolver import HashResolver
from .hashresolver import HashResolver
__all__ = ('RainbowFactory',)

View File

@ -1,8 +1,8 @@
import abc
from typing import Iterable
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core.mentionable import Mentionable
from .hashpoint import HashPoint
from .mentionable import Mentionable
__all__ = ('RecursiveMentionable',)

View File

@ -1,12 +1,12 @@
from typing import Generic, TypeVar
from rainbowadn.core.asserts import assert_eq
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core.hashresolver import HashResolver
from rainbowadn.core.metaorigin import MetaOrigin
from rainbowadn.core.origin import Origin
from rainbowadn.core.rainbow_factory import RainbowFactory
from rainbowadn.core.resolverorigin import ResolverOrigin
from .asserts import *
from .hashpoint import HashPoint
from .hashresolver import HashResolver
from .metaorigin import MetaOrigin
from .origin import Origin
from .rainbow_factory import RainbowFactory
from .resolverorigin import ResolverOrigin
__all__ = ('ResolverMetaOrigin',)

View File

@ -1,11 +1,11 @@
from typing import Generic, TypeVar
from rainbowadn.core.asserts import assert_eq
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 .asserts import *
from .hashpoint import HashPoint
from .hashresolver import HashResolver
from .mentionable import Mentionable
from .origin import Origin
from .rainbow_factory import RainbowFactory
__all__ = ('ResolverOrigin',)

View File

@ -1,9 +1,9 @@
import abc
from typing import Generic, Type, TypeVar
from rainbowadn.core.hashresolver import HashResolver
from rainbowadn.core.mentionable import Mentionable
from rainbowadn.core.rainbow_factory import RainbowFactory
from .hashresolver import HashResolver
from .mentionable import Mentionable
from .rainbow_factory import RainbowFactory
__all__ = ('StaticMentionable', 'StaticFactory',)

View File

@ -0,0 +1 @@
from .encrypted import *

View File

@ -3,14 +3,7 @@ from typing import Generic, Iterable, TypeVar
from nacl.bindings import crypto_hash_sha256
from nacl.secret import SecretBox
from rainbowadn.core.asserts import assert_eq
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
from rainbowadn.core import *
__all__ = ('Encrypted', 'EncryptedFactory')
@ -49,9 +42,9 @@ class Encrypted(RecursiveMentionable, Generic[EncryptedType]):
hashpoints = tuple(decrypted.points()) if isinstance(decrypted, RecursiveMentionable) else ()
resolution: tuple[HashPoint[Encrypted[EncryptedType]], ...] = tuple(
[
await cls.encrypt_hashpoint(hashpoint, key)
await cls.encrypt_hashpoint(hash_point, key)
for
hashpoint
hash_point
in
hashpoints
]
@ -65,20 +58,20 @@ class Encrypted(RecursiveMentionable, Generic[EncryptedType]):
@classmethod
async def encrypt_hashpoint(
cls, hashpoint: HashPoint[EncryptedType], key: bytes
cls, hash_point: HashPoint[EncryptedType], key: bytes
) -> HashPoint['Encrypted[EncryptedType]']:
assert isinstance(hashpoint, HashPoint)
assert isinstance(hash_point, HashPoint)
assert isinstance(key, bytes)
if isinstance(hashpoint.origin, ResolverOrigin):
resolver: HashResolver = hashpoint.origin.resolver
if isinstance(hash_point.origin, ResolverOrigin):
resolver: HashResolver = hash_point.origin.resolver
assert isinstance(resolver, HashResolver)
if isinstance(resolver, EncryptedResolver) and resolver.key == key:
return ShortcutOrigin(
hashpoint.factory,
resolver.mapping[hashpoint.point],
hash_point.factory,
resolver.mapping[hash_point.point],
key
).hash_point()
return HashPoint.of(await cls.encrypt(await hashpoint.resolve(), key))
return HashPoint.of(await cls.encrypt(await hash_point.resolve(), key))
@classmethod
def construct(
@ -89,7 +82,7 @@ class Encrypted(RecursiveMentionable, Generic[EncryptedType]):
decrypted: EncryptedType
) -> 'Encrypted[EncryptedType]':
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(
key,
@ -136,12 +129,12 @@ class EncryptedFactory(RainbowFactory[Encrypted[EncryptedType]], Generic[Encrypt
resolution: tuple[HashPoint[Encrypted], ...] = tuple(
ResolverOrigin(
EncryptedFactory(
hashpoint.factory,
hash_point.factory,
self.key
),
plain[8 + i * HashPoint.HASH_LENGTH: 8 + (i + 1) * HashPoint.HASH_LENGTH],
resolver
).hash_point() for i, hashpoint in enumerate(hashpoints)
).hash_point() for i, hash_point in enumerate(hashpoints)
)
return Encrypted.construct(
self.key,
@ -165,13 +158,13 @@ class EncryptedResolver(HashResolver):
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(hashpoint, HashPoint)
assert isinstance(hash_point, HashPoint)
assert isinstance(key, bytes)
self.factory: RainbowFactory[Encrypted[EncryptedType]] = EncryptedFactory(factory, key)
assert isinstance(self.factory, RainbowFactory)
self.hashpoint = hashpoint
self.hashpoint = hash_point
super().__init__(self.factory)
async def resolve(self) -> Encrypted[EncryptedType]:
@ -191,7 +184,7 @@ class ShortcutResolver(HashResolver):
def __init__(self, encrypted: Encrypted):
assert isinstance(encrypted, 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']:

View File

@ -0,0 +1,4 @@
from .notnull import NotNull
from .null import Null
from .nullable import Nullable
from .nullablereference import *

View File

@ -1,6 +1,6 @@
from typing import Generic, TypeVar
from rainbowadn.core.nullability.nullable import Nullable
from .nullable import Nullable
__all__ = ('NotNull',)

View File

@ -1,6 +1,6 @@
from typing import Generic, TypeVar
from rainbowadn.core.nullability.nullable import Nullable
from .nullable import Nullable
__all__ = ('Null',)

View File

@ -1,14 +1,9 @@
from typing import Generic, Iterable, TypeVar
from rainbowadn.core.hash_point_format import hash_point_format
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core.hashresolver import HashResolver
from rainbowadn.core.nullability.notnull import NotNull
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
from rainbowadn.core import *
from .notnull import NotNull
from .null import Null
from .nullable import Nullable
__all__ = ('NullableReference', 'NullableReferenceFactory',)

View File

@ -1,11 +1,11 @@
from collections import OrderedDict
from typing import MutableMapping
from typing import MutableMapping, TypeVar
from rainbowadn.core.extendableresolver import ExtendableResolver, Mentioned
from rainbowadn.core.hashpoint import HashPoint
from rainbowadn.core.hashresolver import HashResolver
from rainbowadn.core.mentionable import Mentionable
from rainbowadn.core.recursivementionable import RecursiveMentionable
from rainbowadn.core import *
__all__ = ('DictResolver',)
Mentioned = TypeVar('Mentioned')
class DictResolver(ExtendableResolver):

Some files were not shown because too many files have changed in this diff Show More