From bb765ccfa727f69efa1107227bece1b35ce5027e Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 27 Nov 2019 13:27:47 +0300 Subject: [PATCH 1/2] core: gofmt --- pkg/core/blockchain.go | 4 ++-- pkg/core/blockchain_state.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index abb4ca456..2e589ca29 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -1216,7 +1216,7 @@ func (bc *Blockchain) GetStandByValidators() (keys.PublicKeys, error) { // GetValidators returns validators. // Golang implementation of GetValidators method in C# (https://github.com/neo-project/neo/blob/c64748ecbac3baeb8045b16af0d518398a6ced24/neo/Persistence/Snapshot.cs#L182) -func (bc *Blockchain) GetValidators(txes... *transaction.Transaction) ([]*keys.PublicKey, error) { +func (bc *Blockchain) GetValidators(txes ...*transaction.Transaction) ([]*keys.PublicKey, error) { chainState := NewBlockChainState(bc.store) if len(txes) > 0 { for _, tx := range txes { @@ -1320,7 +1320,7 @@ func (bc *Blockchain) GetValidators(txes... *transaction.Transaction) ([]*keys.P return result, nil } -func processStateTX(chainState *BlockChainState, tx *transaction.StateTX, ) error { +func processStateTX(chainState *BlockChainState, tx *transaction.StateTX) error { for _, desc := range tx.Descriptors { switch desc.Type { case transaction.Account: diff --git a/pkg/core/blockchain_state.go b/pkg/core/blockchain_state.go index ce472becc..b2f868013 100644 --- a/pkg/core/blockchain_state.go +++ b/pkg/core/blockchain_state.go @@ -31,7 +31,7 @@ func NewBlockChainState(store *storage.MemCachedStore) *BlockChainState { } // commit commits all the data in current state into storage. -func (state *BlockChainState) commit() error { +func (state *BlockChainState) commit() error { if err := state.accounts.commit(state.store); err != nil { return err } From 467c9c146daf6e4ccbd118c584b16af8506d5425 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 27 Nov 2019 13:28:13 +0300 Subject: [PATCH 2/2] core: restore intermediate block-level store Commit c80ee952a1a8a5a971cf2579d0985ee091cc39a5 removed temporary store used to contain changes of the block being processed. It's wrong in that the block changes should be applied to the database in a single transaction so that there wouldn't be any intermediate state observed from the outside (which is possible now). Also, this made changes commiting persist them to the underlying store effectively making our persist loop a no-op (and not producing `persist completed` log lines that we love so much). --- pkg/core/blockchain_state.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/core/blockchain_state.go b/pkg/core/blockchain_state.go index b2f868013..db13408f8 100644 --- a/pkg/core/blockchain_state.go +++ b/pkg/core/blockchain_state.go @@ -19,8 +19,9 @@ type BlockChainState struct { // NewBlockChainState creates blockchain state with it's memchached store. func NewBlockChainState(store *storage.MemCachedStore) *BlockChainState { + tmpStore := storage.NewMemCachedStore(store) return &BlockChainState{ - store: store, + store: tmpStore, unspentCoins: make(UnspentCoins), spentCoins: make(SpentCoins), accounts: make(Accounts),