Skip to content

Commit 6909b30

Browse files
committed
updates
1 parent 067a769 commit 6909b30

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

block/internal/reaping/reaper.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,13 @@ type pendingTx struct {
155155

156156
func (r *Reaper) drainMempool() (bool, error) {
157157
var totalSubmitted int
158+
submitted := false
159+
160+
defer func() {
161+
if submitted && r.onTxsSubmitted != nil {
162+
r.onTxsSubmitted()
163+
}
164+
}()
158165

159166
for {
160167
txs, err := r.exec.GetTxs(r.ctx)
@@ -172,20 +179,14 @@ func (r *Reaper) drainMempool() (bool, error) {
172179

173180
n, err := r.submitFiltered(filtered)
174181
if err != nil {
175-
// partial drain, still submit
176-
if totalSubmitted > 0 && r.onTxsSubmitted != nil {
177-
r.onTxsSubmitted()
178-
}
179182
return totalSubmitted > 0, err
180183
}
181184
totalSubmitted += n
185+
submitted = true
182186
}
183187

184188
if totalSubmitted > 0 {
185189
r.logger.Debug().Int("total_txs", totalSubmitted).Msg("drained mempool")
186-
if r.onTxsSubmitted != nil {
187-
r.onTxsSubmitted()
188-
}
189190
}
190191

191192
return totalSubmitted > 0, nil

0 commit comments

Comments
 (0)