From ba5880fab1501560edbe622e8f826f9c64a654a7 Mon Sep 17 00:00:00 2001 From: Ori Newman Date: Mon, 23 Aug 2021 07:26:43 +0300 Subject: [PATCH] Fix pruning candidate (#1821) --- .../consensus/datastructures/pruningstore/pruning_store.go | 2 +- domain/consensus/processes/pruningmanager/pruning_test.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/domain/consensus/datastructures/pruningstore/pruning_store.go b/domain/consensus/datastructures/pruningstore/pruning_store.go index b39c06118..97ea8c9cd 100644 --- a/domain/consensus/datastructures/pruningstore/pruning_store.go +++ b/domain/consensus/datastructures/pruningstore/pruning_store.go @@ -60,7 +60,7 @@ func (ps *pruningStore) PruningPointCandidate(dbContext model.DBReader, stagingA return ps.pruningPointCandidateCache, nil } - candidateBytes, err := dbContext.Get(ps.pruningBlockHashKey) + candidateBytes, err := dbContext.Get(ps.candidatePruningPointHashKey) if err != nil { return nil, err } diff --git a/domain/consensus/processes/pruningmanager/pruning_test.go b/domain/consensus/processes/pruningmanager/pruning_test.go index 8a983f9a7..044005241 100644 --- a/domain/consensus/processes/pruningmanager/pruning_test.go +++ b/domain/consensus/processes/pruningmanager/pruning_test.go @@ -2,6 +2,7 @@ package pruningmanager_test import ( "encoding/json" + "github.com/kaspanet/kaspad/infrastructure/db/database" "os" "path/filepath" "testing" @@ -107,7 +108,9 @@ func TestPruning(t *testing.T) { blockHashToID[*blockHash] = dagBlock.ID pruningPointCandidate, err := tc.PruningStore().PruningPointCandidate(tc.DatabaseContext(), stagingArea) - if err != nil { + if database.IsNotFoundError(err) { + pruningPointCandidate = consensusConfig.GenesisHash + } else if err != nil { return err }