File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -155,6 +155,13 @@ type pendingTx struct {
155155
156156func (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
You can’t perform that action at this time.
0 commit comments