@@ -81,19 +81,20 @@ func (h *manager) SetSubStatus(ctx context.Context, mtx *apitypes.ManagedTX, sub
8181 mtx .History = mtx .History [1 :]
8282 }
8383
84- // As was as detailed sub-status records (which might be a long list and early entries
84+ // As we have a possibly indefinite list of sub-status records (which might be a long list and early entries
8585 // get purged at some point) we keep a separate list of all the discrete types of sub-status
86- // we've ever seen for this transaction along with a count of them. This means an early sub-status
86+ // and action we've we've ever seen for this transaction along with a count of them. This means an early sub-status
8787 // (e.g. "queued") followed by 100s of different sub-status types will still be recorded
8888 for _ , statusType := range mtx .HistorySummary {
8989 if statusType .Status == subStatus {
90- // Just increment the counter
90+ // Just increment the counter and last timestamp
91+ statusType .LastOccurrence = fftypes .Now ()
9192 statusType .Count ++
9293 return
9394 }
9495 }
9596
96- mtx .HistorySummary = append (mtx .HistorySummary , & apitypes.TxHistorySummaryEntry {Status : subStatus , Count : 1 , FirstOccurrence : fftypes .Now ()})
97+ mtx .HistorySummary = append (mtx .HistorySummary , & apitypes.TxHistorySummaryEntry {Status : subStatus , Count : 1 , FirstOccurrence : fftypes .Now (), LastOccurrence : fftypes . Now () })
9798}
9899
99100// Takes a string that might be valid JSON, and returns valid JSON that is either:
@@ -141,6 +142,20 @@ func (h *manager) AddSubStatusAction(ctx context.Context, mtx *apitypes.ManagedT
141142 if info != nil {
142143 entry .LastInfo = jsonOrString (info )
143144 }
145+
146+ // As we have a possibly indefinite list of sub-status records (which might be a long list and early entries
147+ // get purged at some point) we keep a separate list of all the discrete types of sub-status
148+ // and action we've we've ever seen for this transaction along with a count of them. This means an early sub-status
149+ // (e.g. "queued") with an action that never happens again (e.g. "assignNonce") followed by 100s of different sub-status
150+ // types will still be recorded
151+ for _ , actionType := range mtx .HistorySummary {
152+ if actionType .Action == action {
153+ // Just increment the counter and last timestamp
154+ actionType .LastOccurrence = fftypes .Now ()
155+ actionType .Count ++
156+ break
157+ }
158+ }
144159 return
145160 }
146161 }
@@ -163,4 +178,5 @@ func (h *manager) AddSubStatusAction(ctx context.Context, mtx *apitypes.ManagedT
163178 }
164179
165180 currentSubStatus .Actions = append (currentSubStatus .Actions , newAction )
181+ mtx .HistorySummary = append (mtx .HistorySummary , & apitypes.TxHistorySummaryEntry {Action : action , Count : 1 , FirstOccurrence : fftypes .Now (), LastOccurrence : fftypes .Now ()})
166182}
0 commit comments