@@ -243,13 +243,13 @@ func indexTransactions(db ethdb.Database, from uint64, to uint64, interrupt chan
243
243
}
244
244
}
245
245
}
246
- // If there exists uncommitted data, flush them.
247
- if batch . ValueSize () > 0 {
248
- WriteTxIndexTail ( batch , lastNum ) // Also write the tail there
249
- if err := batch . Write (); err != nil {
250
- log . Crit ( "Failed writing batch to db" , "error" , err )
251
- return
252
- }
246
+ // Flush the new indexing tail and the last committed data. It can also happen
247
+ // that the last batch is empty because nothing to index, but the tail has to
248
+ // be flushed anyway.
249
+ WriteTxIndexTail ( batch , lastNum )
250
+ if err := batch . Write (); err != nil {
251
+ log . Crit ( "Failed writing batch to db" , "error" , err )
252
+ return
253
253
}
254
254
select {
255
255
case <- interrupt :
@@ -334,13 +334,13 @@ func unindexTransactions(db ethdb.Database, from uint64, to uint64, interrupt ch
334
334
}
335
335
}
336
336
}
337
- // Commit the last batch if there exists uncommitted data
338
- if batch . ValueSize () > 0 {
339
- WriteTxIndexTail ( batch , nextNum )
340
- if err := batch . Write (); err != nil {
341
- log . Crit ( "Failed writing batch to db" , "error" , err )
342
- return
343
- }
337
+ // Flush the new indexing tail and the last committed data. It can also happen
338
+ // that the last batch is empty because nothing to unindex, but the tail has to
339
+ // be flushed anyway.
340
+ WriteTxIndexTail ( batch , nextNum )
341
+ if err := batch . Write (); err != nil {
342
+ log . Crit ( "Failed writing batch to db" , "error" , err )
343
+ return
344
344
}
345
345
select {
346
346
case <- interrupt :
0 commit comments