diff --git a/blockchain/reactor.go b/blockchain/reactor.go index f7c7586e9..bfa671d02 100644 --- a/blockchain/reactor.go +++ b/blockchain/reactor.go @@ -235,23 +235,18 @@ FOR_LOOP: break SYNC_LOOP } else { bcR.pool.PopRequest() - // TODO: use ApplyBlock instead of Exec/Commit/SetAppHash/Save + + bcR.store.SaveBlock(first, firstParts, second.LastCommit) + // TODO: should we be firing events? need to fire NewBlock events manually ... - err := bcR.state.ExecBlock(bcR.evsw, bcR.proxyAppConn, first, firstPartsHeader) - if err != nil { - // TODO This is bad, are we zombie? - PanicQ(Fmt("Failed to process committed block (%d:%X): %v", first.Height, first.Hash(), err)) - } // NOTE: we could improve performance if we // didn't make the app commit to disk every block // ... but we would need a way to get the hash without it persisting - res := bcR.proxyAppConn.CommitSync() - if res.IsErr() { - // TODO Handle gracefully. - PanicQ(Fmt("Failed to commit block at application: %v", res)) + err := bcR.state.ApplyBlock(bcR.evsw, bcR.proxyAppConn, first, firstPartsHeader, sm.MockMempool{}) + if err != nil { + // TODO This is bad, are we zombie? + PanicQ(Fmt("Failed to process committed block (%d:%X): %v", first.Height, first.Hash(), err)) } - bcR.store.SaveBlock(first, firstParts, second.LastCommit) - bcR.state.AppHash = res.Data bcR.state.Save() } } diff --git a/state/execution.go b/state/execution.go index 016fe50c3..cec4849ab 100644 --- a/state/execution.go +++ b/state/execution.go @@ -280,12 +280,12 @@ type Mempool interface { Update(height int, txs []types.Tx) } -type mockMempool struct { +type MockMempool struct { } -func (m mockMempool) Lock() {} -func (m mockMempool) Unlock() {} -func (m mockMempool) Update(height int, txs []types.Tx) {} +func (m MockMempool) Lock() {} +func (m MockMempool) Unlock() {} +func (m MockMempool) Update(height int, txs []types.Tx) {} //---------------------------------------------------------------- // Handshake with app to sync to latest state of core by replaying blocks @@ -386,7 +386,7 @@ func (h *Handshaker) ReplayBlocks(appHash []byte, appBlockHeight int, appConnCon var eventCache types.Fireable // nil // replay the block against the actual tendermint state - return h.state.ApplyBlock(eventCache, appConnConsensus, block, blockMeta.PartsHeader, mockMempool{}) + return h.state.ApplyBlock(eventCache, appConnConsensus, block, blockMeta.PartsHeader, MockMempool{}) } else { // either we're caught up or there's blocks to replay diff --git a/state/execution_test.go b/state/execution_test.go index e0527a42e..cbaab0997 100644 --- a/state/execution_test.go +++ b/state/execution_test.go @@ -20,7 +20,7 @@ var ( privKey = crypto.GenPrivKeyEd25519FromSecret([]byte("handshake_test")) chainID = "handshake_chain" nBlocks = 5 - mempool = mockMempool{} + mempool = MockMempool{} testPartSize = 65536 )