Skip to content

Commit

Permalink
indexers, utreexobackends: fix flush bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
kcalvinalvin committed Aug 28, 2024
1 parent 9f74eaf commit 1546209
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion blockchain/indexers/utreexobackend.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ func InitUtreexoState(cfg *UtreexoConfig, chain *blockchain.BlockChain,
isFlushNeeded = func() bool {
nodesNeedsFlush := nodesDB.IsFlushNeeded()
leavesNeedsFlush := cachedLeavesDB.IsFlushNeeded()
return nodesNeedsFlush && leavesNeedsFlush
return nodesNeedsFlush || leavesNeedsFlush
}
} else {
log.Infof("loading the utreexo state from disk...")
Expand Down
4 changes: 4 additions & 0 deletions blockchain/internal/utreexobackends/cachedleavesmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ func (ms *CachedLeavesMapSlice) ClearMaps() {
delete(ms.maps[i], key)
}
}

for key := range ms.overflow {
delete(ms.overflow, key)
}
}

// ForEach loops through all the elements in the cachedleaves map slice and calls fn with the key-value pairs.
Expand Down
4 changes: 4 additions & 0 deletions blockchain/internal/utreexobackends/nodesmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ func (ms *NodesMapSlice) ClearMaps() {
delete(ms.maps[i], key)
}
}

for key := range ms.overflow {
delete(ms.overflow, key)
}
}

// ForEach loops through all the elements in the nodes map slice and calls fn with the key-value pairs.
Expand Down

0 comments on commit 1546209

Please sign in to comment.