@@ -1006,6 +1006,14 @@ func (cs *State) receiveRoutine(ctx context.Context, maxSteps int) {
1006
1006
// TODO should we handle context cancels here?
1007
1007
}
1008
1008
}
1009
+ func (cs * State ) fsyncAndCompleteProposal (ctx context.Context , fsyncUponCompletion bool , height int64 , span otrace.Span ) {
1010
+ if fsyncUponCompletion {
1011
+ if err := cs .wal .FlushAndSync (); err != nil { // fsync
1012
+ panic ("error flushing wal after receiving all block parts" )
1013
+ }
1014
+ }
1015
+ cs .handleCompleteProposal (ctx , height , span )
1016
+ }
1009
1017
1010
1018
// state transitions on complete-proposal, 2/3-any, 2/3-one
1011
1019
func (cs * State ) handleMsg (ctx context.Context , mi msgInfo , fsyncUponCompletion bool ) {
@@ -1032,18 +1040,12 @@ func (cs *State) handleMsg(ctx context.Context, mi msgInfo, fsyncUponCompletion
1032
1040
created := cs .tryCreateProposalBlock (msg .Proposal .Height , msg .Proposal .Round , msg .Proposal .Header , msg .Proposal .LastCommit , msg .Proposal .Evidence , msg .Proposal .ProposerAddress )
1033
1041
cs .metrics .ProposalBlockCreatedOnPropose .With ("success" , strconv .FormatBool (created )).Add (1 )
1034
1042
if created {
1035
- if fsyncUponCompletion {
1036
- if err := cs .wal .FlushAndSync (); err != nil { // fsync
1037
- panic ("error flushing wal after receiving all block parts" )
1038
- }
1039
- }
1040
- cs .handleCompleteProposal (ctx , msg .Proposal .Height , span )
1041
-
1043
+ cs .fsyncAndCompleteProposal (ctx , fsyncUponCompletion , msg .Proposal .Height , span )
1042
1044
}
1043
1045
}
1044
1046
1045
1047
case * BlockPartMessage :
1046
- spanCtx , span := cs .tracer .Start (cs .getTracingCtx (ctx ), "cs.state.handleBlockPartMsg" )
1048
+ _ , span := cs .tracer .Start (cs .getTracingCtx (ctx ), "cs.state.handleBlockPartMsg" )
1047
1049
span .SetAttributes (attribute .Int ("round" , int (msg .Round )))
1048
1050
defer span .End ()
1049
1051
@@ -1065,16 +1067,7 @@ func (cs *State) handleMsg(ctx context.Context, mi msgInfo, fsyncUponCompletion
1065
1067
1066
1068
cs .mtx .Lock ()
1067
1069
if added && cs .ProposalBlockParts .IsComplete () {
1068
- if fsyncUponCompletion {
1069
- _ , fsyncSpan := cs .tracer .Start (spanCtx , "cs.state.handleBlockPartMsg.fsync" )
1070
- if err := cs .wal .FlushAndSync (); err != nil { // fsync
1071
- panic ("error flushing wal after receiving all block parts" )
1072
- }
1073
- fsyncSpan .End ()
1074
- }
1075
- cs .handleCompleteProposal (ctx , msg .Height , span )
1076
- } else {
1077
- //cs.logger.Info("PSULOG - did not complete proposal", "added", added, "proposalblockparts", cs.ProposalBlockParts, "proposal", cs.Proposal)
1070
+ cs .fsyncAndCompleteProposal (ctx , fsyncUponCompletion , msg .Height , span )
1078
1071
}
1079
1072
if added {
1080
1073
select {
0 commit comments