fix comment etc.

This commit is contained in:
Raycho Mukelov 2023-11-05 07:04:32 +02:00
parent 30ba492caf
commit a288abb16f
1 changed files with 5 additions and 5 deletions

View File

@ -32,10 +32,10 @@ type
# Define logical functions (conditions) computed from our NodeType etc. (Truth Table) # Define logical functions (conditions) computed from our NodeType etc. (Truth Table)
LogicalFunctionConditionValueType* = bool LogicalFunctionConditionValueType* = bool
LogicalFunctionCondition*[EventType, NodeTytpe, RaftMessageBase] = LogicalFunctionCondition*[NodeTytpe, RaftMessageBase] =
proc(e: EventType, n: NodeTytpe, msg: Option[RaftMessageBase]): bool proc(n: NodeTytpe, msg: Option[RaftMessageBase]): LogicalFunctionConditionValueType
LogicalFunctionConditionsLUT*[RaftNodeState, EventType, NodeType, RaftMessageBase] = LogicalFunctionConditionsLUT*[RaftNodeState, EventType, NodeType, RaftMessageBase] =
Table[(RaftNodeState, EventType), seq[LogicalFunctionCondition[EventType, NodeType, Option[RaftMessageBase]]]] Table[(RaftNodeState, EventType), seq[LogicalFunctionCondition[NodeType, Option[RaftMessageBase]]]]
# Define Terminals as a tuple of a Event and a sequence of logical functions (conditions) and their respective values computed from NodeType, NodeTytpe and RaftMessageBase # Define Terminals as a tuple of a Event and a sequence of logical functions (conditions) and their respective values computed from NodeType, NodeTytpe and RaftMessageBase
# (kind of Truth Table) # (kind of Truth Table)
@ -43,6 +43,7 @@ type
(EventType, seq[LogicalFunctionConditionValueType]) (EventType, seq[LogicalFunctionConditionValueType])
# Define State Transition Rules LUT of the form ( NonTerminal -> Terminal ) -> NonTerminal ) # Define State Transition Rules LUT of the form ( NonTerminal -> Terminal ) -> NonTerminal )
# NonTerminal is a NodeState and Terminal is a TerminalSymbol - the tuple (EventType, seq[LogicalFunctionConditionValueType])
StateTransitionsRulesLUT*[RaftNodeState, EventType, NodeType, RaftMessageBase] = Table[ StateTransitionsRulesLUT*[RaftNodeState, EventType, NodeType, RaftMessageBase] = Table[
(RaftNodeState, TerminalSymbol[NodeType, EventType, Option[RaftMessageBase]]), (RaftNodeState, TerminalSymbol[NodeType, EventType, Option[RaftMessageBase]]),
(RaftNodeState, Option[ConsensusFSMTransActionType]) (RaftNodeState, Option[ConsensusFSMTransActionType])
@ -59,8 +60,7 @@ type
proc new*[RaftNodeState, EventType, NodeType, RaftNodeStates]( proc new*[RaftNodeState, EventType, NodeType, RaftNodeStates](
T: type ConsensusFSM[RaftNodeState, EventType, NodeType, RaftMessageBase], startSymbol: RaftNodeState): T = T: type ConsensusFSM[RaftNodeState, EventType, NodeType, RaftMessageBase], startSymbol: RaftNodeState): T =
result = (ConsensusFSM[NodeType, EventType, RaftNodeStates]) result = new(ConsensusFSM[NodeType, EventType, RaftNodeStates])
result = ConsensusFSM[NodeType, EventType, RaftNodeStates].new
initRLock(result.mtx) initRLock(result.mtx)
result.state = startSymbol result.state = startSymbol
debug "new: ", fsm=repr(result) debug "new: ", fsm=repr(result)