@@ -176,6 +176,10 @@ type State struct {
176176
177177 // gossipDataEnabled controls whether the gossipDataRoutine should run
178178 gossipDataEnabled atomic.Bool
179+
180+ // proposalReceivedTime tracks when the proposal was received for the current height/round
181+ // Used to calculate the duration until full block is received
182+ proposalReceivedTime time.Time
179183}
180184
181185// StateOption sets an optional parameter on the State.
@@ -876,6 +880,7 @@ func (cs *State) updateToState(state sm.State) {
876880 cs .rs .Proposal = nil
877881 cs .rs .ProposalBlock = nil
878882 cs .rs .ProposalBlockParts = nil
883+ cs .proposalReceivedTime = time.Time {}
879884 cs .rs .LockedRound = - 1
880885 cs .rs .LockedBlock = nil
881886 cs .rs .LockedBlockParts = nil
@@ -1244,6 +1249,7 @@ func (cs *State) enterNewRound(height int64, round int32) {
12441249 cs .rs .Proposal = nil
12451250 cs .rs .ProposalBlock = nil
12461251 cs .rs .ProposalBlockParts = nil
1252+ cs .proposalReceivedTime = time.Time {}
12471253 }
12481254
12491255 logger .Debug ("entering new round" ,
@@ -2239,7 +2245,7 @@ func (cs *State) defaultSetProposal(proposal *types.Proposal) error {
22392245 }
22402246
22412247 cs .Logger .Info ("received proposal" , "proposal" , proposal , "proposer" , pubKey .Address ())
2242- schema . WriteFullBlockReceivingTime ( cs .traceClient , proposal . Height , proposal . Round , time .Now (), false )
2248+ cs .proposalReceivedTime = time .Now ()
22432249 return nil
22442250}
22452251
@@ -2296,7 +2302,10 @@ func (cs *State) addProposalBlockPart(msg *BlockPartMessage, peerID p2p.ID) (add
22962302 )
22972303 }
22982304 if added && cs .rs .ProposalBlockParts .IsComplete () {
2299- schema .WriteFullBlockReceivingTime (cs .traceClient , msg .Height , msg .Round , time .Now (), true )
2305+ if ! cs .proposalReceivedTime .IsZero () {
2306+ duration := time .Since (cs .proposalReceivedTime )
2307+ schema .WriteFullBlockReceivingTime (cs .traceClient , msg .Height , msg .Round , duration )
2308+ }
23002309 bz := cs .rs .ProposalBlockParts .GetBytes ()
23012310
23022311 pbb := new (cmtproto.Block )
0 commit comments