File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,6 +82,8 @@ type PendingManager interface {
8282 ResetInFlightDataRange (start , end uint64 )
8383 NumPendingHeaders () uint64
8484 NumPendingData () uint64
85+ NumPendingHeadersTotal () uint64
86+ NumPendingDataTotal () uint64
8587}
8688
8789// Manager combines CacheManager and PendingManager.
@@ -340,6 +342,14 @@ func (m *implementation) NumPendingData() uint64 {
340342 return m .pendingData .NumPendingData ()
341343}
342344
345+ func (m * implementation ) NumPendingHeadersTotal () uint64 {
346+ return m .pendingHeaders .NumPendingHeadersTotal ()
347+ }
348+
349+ func (m * implementation ) NumPendingDataTotal () uint64 {
350+ return m .pendingData .NumPendingDataTotal ()
351+ }
352+
343353// SetPendingEvent sets the event at the specified height.
344354func (m * implementation ) SetPendingEvent (height uint64 , event * common.DAHeightEvent ) {
345355 m .pendingMu .Lock ()
Original file line number Diff line number Diff line change @@ -145,6 +145,22 @@ func (pb *pendingBase[T]) numPending() uint64 {
145145 return count
146146}
147147
148+ func (pb * pendingBase [T ]) numPendingTotal () uint64 {
149+ height , err := pb .store .Height (context .Background ())
150+ if err != nil {
151+ pb .logger .Error ().Err (err ).Msg ("failed to get height in numPendingTotal" )
152+ return 0
153+ }
154+
155+ lastSubmitted := pb .lastHeight .Load ()
156+
157+ if height <= lastSubmitted {
158+ return 0
159+ }
160+
161+ return height - lastSubmitted
162+ }
163+
148164func (pb * pendingBase [T ]) getLastSubmittedHeight () uint64 {
149165 return pb .lastHeight .Load ()
150166}
Original file line number Diff line number Diff line change @@ -81,6 +81,11 @@ func (pd *PendingData) NumPendingData() uint64 {
8181 return pd .base .numPending ()
8282}
8383
84+ func (pd * PendingData ) NumPendingDataTotal () uint64 {
85+ pd .advancePastEmptyData (context .Background ())
86+ return pd .base .numPendingTotal ()
87+ }
88+
8489func (pd * PendingData ) SetLastSubmittedDataHeight (ctx context.Context , newLastSubmittedDataHeight uint64 ) {
8590 pd .base .setLastSubmittedHeight (ctx , newLastSubmittedDataHeight )
8691}
Original file line number Diff line number Diff line change @@ -76,6 +76,10 @@ func (ph *PendingHeaders) NumPendingHeaders() uint64 {
7676 return ph .base .numPending ()
7777}
7878
79+ func (ph * PendingHeaders ) NumPendingHeadersTotal () uint64 {
80+ return ph .base .numPendingTotal ()
81+ }
82+
7983func (ph * PendingHeaders ) SetLastSubmittedHeaderHeight (ctx context.Context , newLastSubmittedHeaderHeight uint64 ) {
8084 ph .base .setLastSubmittedHeight (ctx , newLastSubmittedHeaderHeight )
8185}
Original file line number Diff line number Diff line change @@ -484,8 +484,8 @@ func (e *Executor) ProduceBlock(ctx context.Context) error {
484484 shouldCheck := e .config .Node .MaxPendingHeadersAndData <= pendingCheckInterval ||
485485 e .pendingCheckCounter % pendingCheckInterval == 0
486486 if shouldCheck {
487- pendingHeaders := e .cache .NumPendingHeaders ()
488- pendingData := e .cache .NumPendingData ()
487+ pendingHeaders := e .cache .NumPendingHeadersTotal ()
488+ pendingData := e .cache .NumPendingDataTotal ()
489489 if pendingHeaders >= e .config .Node .MaxPendingHeadersAndData ||
490490 pendingData >= e .config .Node .MaxPendingHeadersAndData {
491491 e .logger .Warn ().
You can’t perform that action at this time.
0 commit comments