From 70407f0c19a743f05375dc05cf7aa5436356ce06 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 21 Oct 2019 10:04:58 +0300 Subject: [PATCH] core: remove unused context parameter from persist() --- pkg/core/blockchain.go | 6 +++--- pkg/core/blockchain_test.go | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 263606ee1..2946633ff 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -175,7 +175,7 @@ func (bc *Blockchain) Run(ctx context.Context) { persistTimer := time.NewTimer(persistInterval) defer func() { persistTimer.Stop() - if err := bc.persist(ctx); err != nil { + if err := bc.persist(); err != nil { log.Warnf("failed to persist: %s", err) } if err := bc.store.Close(); err != nil { @@ -191,7 +191,7 @@ func (bc *Blockchain) Run(ctx context.Context) { bc.headersOpDone <- struct{}{} case <-persistTimer.C: go func() { - err := bc.persist(ctx) + err := bc.persist() if err != nil { log.Warnf("failed to persist blockchain: %s", err) } @@ -470,7 +470,7 @@ func (bc *Blockchain) storeBlock(block *Block) error { } // persist flushes current in-memory store contents to the persistent storage. -func (bc *Blockchain) persist(ctx context.Context) error { +func (bc *Blockchain) persist() error { var ( start = time.Now() persisted int diff --git a/pkg/core/blockchain_test.go b/pkg/core/blockchain_test.go index 71756941d..9e3b5a515 100644 --- a/pkg/core/blockchain_test.go +++ b/pkg/core/blockchain_test.go @@ -1,7 +1,6 @@ package core import ( - "context" "testing" "github.com/CityOfZion/neo-go/pkg/core/storage" @@ -53,7 +52,7 @@ func TestAddBlock(t *testing.T) { assert.Equal(t, lastBlock.Hash(), bc.CurrentHeaderHash()) // This one tests persisting blocks, so it does need to persist() - require.NoError(t, bc.persist(context.Background())) + require.NoError(t, bc.persist()) for _, block := range blocks { key := storage.AppendPrefix(storage.DataBlock, block.Hash().BytesReverse()) @@ -82,7 +81,7 @@ func TestGetHeader(t *testing.T) { b2 := newBlock(2) _, err = bc.GetHeader(b2.Hash()) assert.Error(t, err) - assert.NoError(t, bc.persist(context.Background())) + assert.NoError(t, bc.persist()) } } @@ -106,7 +105,7 @@ func TestGetBlock(t *testing.T) { assert.Equal(t, blocks[i].Index, block.Index) assert.Equal(t, blocks[i].Hash(), block.Hash()) } - assert.NoError(t, bc.persist(context.Background())) + assert.NoError(t, bc.persist()) } } @@ -127,7 +126,7 @@ func TestHasBlock(t *testing.T) { } newBlock := newBlock(51) assert.False(t, bc.HasBlock(newBlock.Hash())) - assert.NoError(t, bc.persist(context.Background())) + assert.NoError(t, bc.persist()) } } @@ -151,6 +150,6 @@ func TestGetTransaction(t *testing.T) { assert.Equal(t, 1, io.GetVarSize(tx.Inputs)) assert.Equal(t, 1, io.GetVarSize(tx.Outputs)) assert.Equal(t, 1, io.GetVarSize(tx.Scripts)) - assert.NoError(t, bc.persist(context.Background())) + assert.NoError(t, bc.persist()) } }