This commit is contained in:
Raycho Mukelov 2023-11-05 01:13:11 +02:00
parent 903f4d9260
commit 32fba0b9dc
1 changed files with 6 additions and 6 deletions

View File

@ -42,11 +42,11 @@ type
mtx: RLock mtx: RLock
state: NonTerminalSymbol[NodeType] state: NonTerminalSymbol[NodeType]
stateTransitionsLUT: StateTransitionsRulesLUT[NodeState, EventType, NodeType, RaftMessageBase] stateTransitionsLUT: StateTransitionsRulesLUT[NodeState, EventType, NodeType, RaftMessageBase]
logicalFunctionsLut: LogicalFunctionConditionsLUT[EventType, NodeType, RaftMessageBase] logicalFunctionsLut: LogicalFunctionConditionsLUT[NodeState, EventType, NodeType, RaftMessageBase]
# FSM type constructor # FSM type constructor
proc new*[NodeType, EventType, NodeStates](T: type ConsensusFSM[NodeType, EventType, RaftMessageBase], proc new*[NodeState, EventType, NodeType, NodeStates](T: type ConsensusFSM[NodeState, EventType, NodeType, RaftMessageBase],
lut: StateTransitionsRulesLUT[NodeType, EventType, RaftMessageBase], lut: StateTransitionsRulesLUT[NodeState, EventType, NodeType, RaftMessageBase],
startSymbol: NonTerminalSymbol[NodeType] startSymbol: NonTerminalSymbol[NodeType]
): T = ): T =
result = new(ConsensusFSM[NodeType, EventType, NodeStates]) result = new(ConsensusFSM[NodeType, EventType, NodeStates])
@ -54,8 +54,8 @@ proc new*[NodeType, EventType, NodeStates](T: type ConsensusFSM[NodeType, EventT
result.state = startSymbol result.state = startSymbol
result.stateTransitionsLUT = lut result.stateTransitionsLUT = lut
proc computeFSMLogicFunctionsPermutationValue[NonTerminalSymbol, NodeType, EventType, RaftMessageBase]( proc computeFSMLogicFunctionsPermutationValue[NonTerminalSymbol, NodeState, NodeType, EventType, RaftMessageBase](
fsm: ConsensusFSM[NodeType, EventType, RaftMessageBase], fsm: ConsensusFSM[NodeState, EventType, NodeType, RaftMessageBase],
nts: NonTerminalSymbol, rawInput: TerminalSymbol, msg: Option[RaftMessageBase]): TerminalSymbol = nts: NonTerminalSymbol, rawInput: TerminalSymbol, msg: Option[RaftMessageBase]): TerminalSymbol =
let let
e = rawInput[0] e = rawInput[0]
@ -68,7 +68,7 @@ proc computeFSMLogicFunctionsPermutationValue[NonTerminalSymbol, NodeType, Event
rawInput[1] = logicFunctionsConds rawInput[1] = logicFunctionsConds
result = rawInput result = rawInput
proc consensusFSMAdvance[NodeType, EventType](fsm: ConsensusFSM[NodeType, EventType, RaftMessageBase], node: NodeType, event: EventType, proc consensusFSMAdvance[NodeState, EventType, NodeType, RaftMessageBase](fsm: ConsensusFSM[NodeState, EventType, NodeType, RaftMessageBase], node: NodeType, event: EventType,
rawInput: TerminalSymbol[EventType, NodeType, RaftMessageBase], msg: Option[RaftMessageBase]): NonTerminalSymbol[NodeType] = rawInput: TerminalSymbol[EventType, NodeType, RaftMessageBase], msg: Option[RaftMessageBase]): NonTerminalSymbol[NodeType] =
withRLock(): withRLock():
var var