From 4395cea3440893b34ab15a1e1beda59a899cb375 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 11 Sep 2019 20:33:41 +0300 Subject: [PATCH] storage: fix reading overlapping hash blocks from the DB In the unlikely event of overlapping hash block written to the DB we might end up with wrong hash list. That happened to me for some reason when synching with the testnet leading to the following keys with respective values: 150000 -> 2000 hashes 152000 -> 2000 hashes 153999 -> 2000 hashes Reading it hashes number 153999 and 154000 got the same values and the chain couldn't sync correctly. --- pkg/core/storage/helpers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/core/storage/helpers.go b/pkg/core/storage/helpers.go index 2776da38c..4a35d9ad7 100644 --- a/pkg/core/storage/helpers.go +++ b/pkg/core/storage/helpers.go @@ -74,7 +74,7 @@ func HeaderHashes(s Store) ([]util.Uint256, error) { sort.Sort(uint32Slice(sortedKeys)) for _, key := range sortedKeys { - hashes = append(hashes, hashMap[key]...) + hashes = append(hashes[:key], hashMap[key]...) } return hashes, nil