[NOD-1040] Don't remove DAG tips from the diffStore's loaded set

This commit is contained in:
stasatdaglabs
2020-06-07 09:18:03 +03:00
parent d15c009b3c
commit d3eba1c182

View File

@@ -156,7 +156,9 @@ func (diffStore *utxoDiffStore) clearDirtyEntries() {
var maxBlueScoreDifferenceToKeepLoaded uint64 = 100
// clearOldEntries removes entries whose blue score is lower than
// virtual.blueScore - maxBlueScoreDifferenceToKeepLoaded.
// virtual.blueScore - maxBlueScoreDifferenceToKeepLoaded. Note
// that tips are not removed either, even if their blue score is
// lower than the above.
func (diffStore *utxoDiffStore) clearOldEntries() {
virtualBlueScore := diffStore.dag.VirtualBlueScore()
minBlueScore := virtualBlueScore - maxBlueScoreDifferenceToKeepLoaded
@@ -164,9 +166,11 @@ func (diffStore *utxoDiffStore) clearOldEntries() {
minBlueScore = 0
}
tips := diffStore.dag.virtual.tips()
toRemove := make(map[*blockNode]struct{})
for node := range diffStore.loaded {
if node.blueScore < minBlueScore {
if node.blueScore < minBlueScore && !tips.contains(node) {
toRemove[node] = struct{}{}
}
}