32 lines
985 B
Python
32 lines
985 B
Python
from typing import TypeVar
|
|
|
|
from rainbowadn.chain.states.stateprotocol import StateProtocol
|
|
from rainbowadn.core.hashpoint import HashPoint
|
|
from rainbowadn.core.nullability.nullablereference import NullableReference
|
|
|
|
__all__ = ('ActiveStateProtocol',)
|
|
|
|
HeaderType = TypeVar('HeaderType')
|
|
StateType = TypeVar('StateType')
|
|
|
|
|
|
class ActiveStateProtocol(StateProtocol[HeaderType, StateType]):
|
|
def verify(
|
|
self,
|
|
previous: NullableReference[StateType],
|
|
header: HashPoint[HeaderType],
|
|
state: HashPoint[StateType]
|
|
) -> bool:
|
|
assert isinstance(previous, NullableReference)
|
|
assert isinstance(header, HashPoint)
|
|
assert isinstance(state, HashPoint)
|
|
assert state == self.derive(previous, header)
|
|
return True
|
|
|
|
def derive(
|
|
self,
|
|
previous: NullableReference[StateType],
|
|
header: HashPoint[HeaderType],
|
|
) -> HashPoint[StateType]:
|
|
raise NotImplementedError
|