@@ -2,77 +2,77 @@ package tendermint
22
33import "github.com/NethermindEth/juno/consensus/types"
44
5- func (t * stateMachine [V , H , A ]) ProcessStart (round types.Round ) []types.Action [V , H , A ] {
6- return t .processLoop (t .startRound (round ), nil )
5+ func (s * stateMachine [V , H , A ]) ProcessStart (round types.Round ) []types.Action [V , H , A ] {
6+ return s .processLoop (s .startRound (round ), nil )
77}
88
9- func (t * stateMachine [V , H , A ]) ProcessProposal (p * types.Proposal [V , H , A ]) []types.Action [V , H , A ] {
10- return t .processMessage (p .MessageHeader , func () {
11- if t .voteCounter .AddProposal (p ) && ! t .replayMode && p .Height == t .state .height {
9+ func (s * stateMachine [V , H , A ]) ProcessProposal (p * types.Proposal [V , H , A ]) []types.Action [V , H , A ] {
10+ return s .processMessage (p .MessageHeader , func () {
11+ if s .voteCounter .AddProposal (p ) && ! s .replayMode && p .Height == s .state .height {
1212 // Store proposal if its the first time we see it
13- if err := t .db .SetWALEntry (p ); err != nil {
14- t .log .Fatalf ("Failed to store prevote in WAL" )
13+ if err := s .db .SetWALEntry (p ); err != nil {
14+ s .log .Fatalf ("Failed to store prevote in WAL" )
1515 }
1616 }
1717 })
1818}
1919
20- func (t * stateMachine [V , H , A ]) ProcessPrevote (p * types.Prevote [H , A ]) []types.Action [V , H , A ] {
21- return t .processMessage (p .MessageHeader , func () {
22- if t .voteCounter .AddPrevote (p ) && ! t .replayMode && p .Height == t .state .height {
20+ func (s * stateMachine [V , H , A ]) ProcessPrevote (p * types.Prevote [H , A ]) []types.Action [V , H , A ] {
21+ return s .processMessage (p .MessageHeader , func () {
22+ if s .voteCounter .AddPrevote (p ) && ! s .replayMode && p .Height == s .state .height {
2323 // Store prevote if its the first time we see it
24- if err := t .db .SetWALEntry (p ); err != nil {
25- t .log .Fatalf ("Failed to store prevote in WAL" )
24+ if err := s .db .SetWALEntry (p ); err != nil {
25+ s .log .Fatalf ("Failed to store prevote in WAL" )
2626 }
2727 }
2828 })
2929}
3030
31- func (t * stateMachine [V , H , A ]) ProcessPrecommit (p * types.Precommit [H , A ]) []types.Action [V , H , A ] {
32- return t .processMessage (p .MessageHeader , func () {
33- if t .voteCounter .AddPrecommit (p ) && ! t .replayMode && p .Height == t .state .height {
31+ func (s * stateMachine [V , H , A ]) ProcessPrecommit (p * types.Precommit [H , A ]) []types.Action [V , H , A ] {
32+ return s .processMessage (p .MessageHeader , func () {
33+ if s .voteCounter .AddPrecommit (p ) && ! s .replayMode && p .Height == s .state .height {
3434 // Store precommit if its the first time we see it
35- if err := t .db .SetWALEntry (p ); err != nil {
36- t .log .Fatalf ("Failed to store prevote in WAL" )
35+ if err := s .db .SetWALEntry (p ); err != nil {
36+ s .log .Fatalf ("Failed to store prevote in WAL" )
3737 }
3838 }
3939 })
4040}
4141
42- func (t * stateMachine [V , H , A ]) processMessage (header types.MessageHeader [A ], addMessage func ()) []types.Action [V , H , A ] {
43- if ! t .preprocessMessage (header , addMessage ) {
42+ func (s * stateMachine [V , H , A ]) processMessage (header types.MessageHeader [A ], addMessage func ()) []types.Action [V , H , A ] {
43+ if ! s .preprocessMessage (header , addMessage ) {
4444 return nil
4545 }
4646
47- return t .processLoop (nil , & header .Round )
47+ return s .processLoop (nil , & header .Round )
4848}
4949
50- func (t * stateMachine [V , H , A ]) ProcessTimeout (tm types.Timeout ) []types.Action [V , H , A ] {
51- if ! t .replayMode && tm .Height == t .state .height {
52- if err := t .db .SetWALEntry (tm ); err != nil {
53- t .log .Fatalf ("Failed to store timeout trigger in WAL" )
50+ func (s * stateMachine [V , H , A ]) ProcessTimeout (tm types.Timeout ) []types.Action [V , H , A ] {
51+ if ! s .replayMode && tm .Height == s .state .height {
52+ if err := s .db .SetWALEntry (tm ); err != nil {
53+ s .log .Fatalf ("Failed to store timeout trigger in WAL" )
5454 }
5555 }
5656 switch tm .Step {
5757 case types .StepPropose :
58- return t .processLoop (t .onTimeoutPropose (tm .Height , tm .Round ), nil )
58+ return s .processLoop (s .onTimeoutPropose (tm .Height , tm .Round ), nil )
5959 case types .StepPrevote :
60- return t .processLoop (t .onTimeoutPrevote (tm .Height , tm .Round ), nil )
60+ return s .processLoop (s .onTimeoutPrevote (tm .Height , tm .Round ), nil )
6161 case types .StepPrecommit :
62- return t .processLoop (t .onTimeoutPrecommit (tm .Height , tm .Round ), nil )
62+ return s .processLoop (s .onTimeoutPrecommit (tm .Height , tm .Round ), nil )
6363 }
6464
6565 return nil
6666}
6767
68- func (t * stateMachine [V , H , A ]) processLoop (action types.Action [V , H , A ], recentlyReceivedRound * types.Round ) []types.Action [V , H , A ] {
68+ func (s * stateMachine [V , H , A ]) processLoop (action types.Action [V , H , A ], recentlyReceivedRound * types.Round ) []types.Action [V , H , A ] {
6969 actions , shouldContinue := []types.Action [V , H , A ]{}, true
7070 if action != nil {
7171 actions = append (actions , action )
7272 }
7373
7474 for shouldContinue {
75- action , shouldContinue = t .process (recentlyReceivedRound )
75+ action , shouldContinue = s .process (recentlyReceivedRound )
7676 if action != nil {
7777 actions = append (actions , action )
7878 }
@@ -81,46 +81,46 @@ func (t *stateMachine[V, H, A]) processLoop(action types.Action[V, H, A], recent
8181 return actions
8282}
8383
84- func (t * stateMachine [V , H , A ]) process (recentlyReceivedRound * types.Round ) (action types.Action [V , H , A ], shouldContinue bool ) {
85- cachedProposal := t .findProposal (t .state .round )
84+ func (s * stateMachine [V , H , A ]) process (recentlyReceivedRound * types.Round ) (action types.Action [V , H , A ], shouldContinue bool ) {
85+ cachedProposal := s .findProposal (s .state .round )
8686
8787 var roundCachedProposal * CachedProposal [V , H , A ]
8888 if recentlyReceivedRound != nil {
89- roundCachedProposal = t .findProposal (* recentlyReceivedRound )
89+ roundCachedProposal = s .findProposal (* recentlyReceivedRound )
9090 }
9191
9292 switch {
9393 // Line 22
94- case cachedProposal != nil && t .uponFirstProposal (cachedProposal ):
95- return t .doFirstProposal (cachedProposal ), true
94+ case cachedProposal != nil && s .uponFirstProposal (cachedProposal ):
95+ return s .doFirstProposal (cachedProposal ), true
9696
9797 // Line 28
98- case cachedProposal != nil && t .uponProposalAndPolkaPrevious (cachedProposal ):
99- return t .doProposalAndPolkaPrevious (cachedProposal ), true
98+ case cachedProposal != nil && s .uponProposalAndPolkaPrevious (cachedProposal ):
99+ return s .doProposalAndPolkaPrevious (cachedProposal ), true
100100
101101 // Line 34
102- case t .uponPolkaAny ():
103- return t .doPolkaAny (), true
102+ case s .uponPolkaAny ():
103+ return s .doPolkaAny (), true
104104
105105 // Line 36
106- case cachedProposal != nil && t .uponProposalAndPolkaCurrent (cachedProposal ):
107- return t .doProposalAndPolkaCurrent (cachedProposal ), true
106+ case cachedProposal != nil && s .uponProposalAndPolkaCurrent (cachedProposal ):
107+ return s .doProposalAndPolkaCurrent (cachedProposal ), true
108108
109109 // Line 44
110- case t .uponPolkaNil ():
111- return t .doPolkaNil (), true
110+ case s .uponPolkaNil ():
111+ return s .doPolkaNil (), true
112112
113113 // Line 47
114- case t .uponPrecommitAny ():
115- return t .doPrecommitAny (), true
114+ case s .uponPrecommitAny ():
115+ return s .doPrecommitAny (), true
116116
117117 // Line 49
118- case roundCachedProposal != nil && t .uponCommitValue (roundCachedProposal ):
119- return t .doCommitValue (roundCachedProposal ), false // We should stop immediately after committing
118+ case roundCachedProposal != nil && s .uponCommitValue (roundCachedProposal ):
119+ return s .doCommitValue (roundCachedProposal ), false // We should stop immediately after committing
120120
121121 // Line 55
122- case recentlyReceivedRound != nil && t .uponSkipRound (* recentlyReceivedRound ):
123- return t .doSkipRound (* recentlyReceivedRound ), true
122+ case recentlyReceivedRound != nil && s .uponSkipRound (* recentlyReceivedRound ):
123+ return s .doSkipRound (* recentlyReceivedRound ), true
124124
125125 default :
126126 return nil , false // We should stop if none of the above conditions are met
0 commit comments