diff --git a/aggregator/aggregator.go b/aggregator/aggregator.go index cad8bd030..e5eb20f02 100644 --- a/aggregator/aggregator.go +++ b/aggregator/aggregator.go @@ -2436,6 +2436,9 @@ func (w *Writer) DeleteAccount(addr []byte, trace bool) { key, _ := g.Next(nil) if bytes.HasPrefix(key, addr) { val, _ := g.Next(nil) + if len(val) > 0 { + val = val[1:] + } heap.Push(&cp, &CursorItem{t: FILE_CURSOR, key: key, val: val, dg: g, endBlock: item.endBlock}) } } diff --git a/aggregator/history.go b/aggregator/history.go index 47d3c9b10..ff5b2e797 100644 --- a/aggregator/history.go +++ b/aggregator/history.go @@ -224,11 +224,17 @@ func (hr *HistoryReader) searchInHistory(bitmapType, historyType FileType, key [ if _, err = bm.ReadFrom(bytes.NewReader(bitmapVal)); err != nil { return false } - bm.RemoveRange(0, searchTx) - if bm.IsEmpty() { + if searchTx == 0 { + foundTxNum = bm.Minimum() + foundEndBlock = item.endBlock + found = true + return false + } + searchRank := bm.Rank(searchTx - 1) + if searchRank >= bm.GetCardinality() { continue } - foundTxNum = bm.Minimum() + foundTxNum, _ = bm.Select(searchRank) foundEndBlock = item.endBlock found = true return false