diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 2946633ff..3cbf95afa 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -488,13 +488,16 @@ func (bc *Blockchain) persist() error { oldHeight := atomic.SwapUint32(&bc.persistedHeight, bHeight) diff := bHeight - oldHeight + storedHeaderHeight, _, err := storage.CurrentHeaderHeight(bc.store) + if err != nil { + return err + } if persisted > 0 { log.WithFields(log.Fields{ "persistedBlocks": diff, "persistedKeys": persisted, - "headerHeight": bc.HeaderHeight(), - "blockHeight": bc.BlockHeight(), - "persistedHeight": atomic.LoadUint32(&bc.persistedHeight), + "headerHeight": storedHeaderHeight, + "blockHeight": bHeight, "took": time.Since(start), }).Info("blockchain persist completed") } diff --git a/pkg/core/blockchain_test.go b/pkg/core/blockchain_test.go index 9e3b5a515..f99114893 100644 --- a/pkg/core/blockchain_test.go +++ b/pkg/core/blockchain_test.go @@ -134,10 +134,12 @@ func TestGetTransaction(t *testing.T) { b1 := getDecodedBlock(t, 1) block := getDecodedBlock(t, 2) bc := newTestChain(t) + // Turn verification off, because these blocks are really from some other chain + // and can't be verified, but we don't care about that in this test. + bc.config.VerifyBlocks = false - // These are from some kind of different chain, so can't be added via AddBlock(). - assert.Nil(t, bc.storeBlock(b1)) - assert.Nil(t, bc.storeBlock(block)) + assert.Nil(t, bc.AddBlock(b1)) + assert.Nil(t, bc.AddBlock(block)) // Test unpersisted and persisted access for j := 0; j < 2; j++ {