mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 09:42:22 +00:00
core: remove unused context parameter from persist()
This commit is contained in:
parent
c885a69edb
commit
70407f0c19
2 changed files with 8 additions and 9 deletions
|
@ -175,7 +175,7 @@ func (bc *Blockchain) Run(ctx context.Context) {
|
||||||
persistTimer := time.NewTimer(persistInterval)
|
persistTimer := time.NewTimer(persistInterval)
|
||||||
defer func() {
|
defer func() {
|
||||||
persistTimer.Stop()
|
persistTimer.Stop()
|
||||||
if err := bc.persist(ctx); err != nil {
|
if err := bc.persist(); err != nil {
|
||||||
log.Warnf("failed to persist: %s", err)
|
log.Warnf("failed to persist: %s", err)
|
||||||
}
|
}
|
||||||
if err := bc.store.Close(); err != nil {
|
if err := bc.store.Close(); err != nil {
|
||||||
|
@ -191,7 +191,7 @@ func (bc *Blockchain) Run(ctx context.Context) {
|
||||||
bc.headersOpDone <- struct{}{}
|
bc.headersOpDone <- struct{}{}
|
||||||
case <-persistTimer.C:
|
case <-persistTimer.C:
|
||||||
go func() {
|
go func() {
|
||||||
err := bc.persist(ctx)
|
err := bc.persist()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("failed to persist blockchain: %s", err)
|
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.
|
// 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 (
|
var (
|
||||||
start = time.Now()
|
start = time.Now()
|
||||||
persisted int
|
persisted int
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/CityOfZion/neo-go/pkg/core/storage"
|
"github.com/CityOfZion/neo-go/pkg/core/storage"
|
||||||
|
@ -53,7 +52,7 @@ func TestAddBlock(t *testing.T) {
|
||||||
assert.Equal(t, lastBlock.Hash(), bc.CurrentHeaderHash())
|
assert.Equal(t, lastBlock.Hash(), bc.CurrentHeaderHash())
|
||||||
|
|
||||||
// This one tests persisting blocks, so it does need to persist()
|
// 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 {
|
for _, block := range blocks {
|
||||||
key := storage.AppendPrefix(storage.DataBlock, block.Hash().BytesReverse())
|
key := storage.AppendPrefix(storage.DataBlock, block.Hash().BytesReverse())
|
||||||
|
@ -82,7 +81,7 @@ func TestGetHeader(t *testing.T) {
|
||||||
b2 := newBlock(2)
|
b2 := newBlock(2)
|
||||||
_, err = bc.GetHeader(b2.Hash())
|
_, err = bc.GetHeader(b2.Hash())
|
||||||
assert.Error(t, err)
|
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].Index, block.Index)
|
||||||
assert.Equal(t, blocks[i].Hash(), block.Hash())
|
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)
|
newBlock := newBlock(51)
|
||||||
assert.False(t, bc.HasBlock(newBlock.Hash()))
|
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.Inputs))
|
||||||
assert.Equal(t, 1, io.GetVarSize(tx.Outputs))
|
assert.Equal(t, 1, io.GetVarSize(tx.Outputs))
|
||||||
assert.Equal(t, 1, io.GetVarSize(tx.Scripts))
|
assert.Equal(t, 1, io.GetVarSize(tx.Scripts))
|
||||||
assert.NoError(t, bc.persist(context.Background()))
|
assert.NoError(t, bc.persist())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue