diff --git a/mempool/mempool_test.go b/mempool/mempool_test.go index ad655c6df..16dd656f2 100644 --- a/mempool/mempool_test.go +++ b/mempool/mempool_test.go @@ -75,9 +75,9 @@ func TestSerialReap(t *testing.T) { res.Code, res.Data, res.Log) } } - hash, log := appConnCon.Commit() - if len(hash) != 8 { - t.Errorf("Error committing. Hash:%X log:%v", hash, log) + res := appConnCon.Commit() + if len(res.Data) != 8 { + t.Errorf("Error committing. Hash:%X log:%v", res.Data, res.Log) } } diff --git a/node/node.go b/node/node.go index 8beafcee8..79e4b9c39 100644 --- a/node/node.go +++ b/node/node.go @@ -258,12 +258,12 @@ func getProxyApp(addr string, hash []byte) (proxyAppConn proxy.AppConn) { } // Check the hash - currentHash, _, err := proxyAppConn.CommitSync() - if err != nil { - PanicCrisis(Fmt("Error in getting proxyAppConn hash: %v", err)) + res := proxyAppConn.CommitSync() + if res.IsErr() { + PanicCrisis(Fmt("Error in getting proxyAppConn hash: %v", res)) } - if !bytes.Equal(hash, currentHash) { - PanicCrisis(Fmt("ProxyApp hash does not match. Expected %X, got %X", hash, currentHash)) + if !bytes.Equal(hash, res.Data) { + PanicCrisis(Fmt("ProxyApp hash does not match. Expected %X, got %X", hash, res.Data)) } return proxyAppConn diff --git a/proxy/app_conn.go b/proxy/app_conn.go index b371f6d28..7311a07b6 100644 --- a/proxy/app_conn.go +++ b/proxy/app_conn.go @@ -18,7 +18,7 @@ type AppConn interface { InfoSync() (info string, err error) FlushSync() error - CommitSync() (hash []byte, log string, err error) + CommitSync() (res tmsp.Result) InitChainSync(validators []*tmsp.Validator) (err error) EndBlockSync(height uint64) (changedValidators []*tmsp.Validator, err error) } diff --git a/proxy/local_app_conn.go b/proxy/local_app_conn.go index 59ae33b52..c2cab0718 100644 --- a/proxy/local_app_conn.go +++ b/proxy/local_app_conn.go @@ -74,11 +74,11 @@ func (app *localAppConn) CheckTxAsync(tx []byte) *tmspcli.ReqRes { func (app *localAppConn) CommitAsync() *tmspcli.ReqRes { app.mtx.Lock() - hash, log := app.Application.Commit() + res := app.Application.Commit() app.mtx.Unlock() return app.callback( tmsp.RequestCommit(), - tmsp.ResponseCommit(hash, log), + tmsp.ResponseCommit(res.Code, res.Data, res.Log), ) } @@ -93,11 +93,11 @@ func (app *localAppConn) FlushSync() error { return nil } -func (app *localAppConn) CommitSync() (hash []byte, log string, err error) { +func (app *localAppConn) CommitSync() (res tmsp.Result) { app.mtx.Lock() - hash, log = app.Application.Commit() + res = app.Application.Commit() app.mtx.Unlock() - return hash, log, nil + return res } func (app *localAppConn) InitChainSync(validators []*tmsp.Validator) (err error) { diff --git a/state/execution.go b/state/execution.go index 199cc8054..404efa26d 100644 --- a/state/execution.go +++ b/state/execution.go @@ -95,18 +95,18 @@ func (s *State) execBlockOnProxyApp(evsw *events.EventSwitch, proxyAppConn proxy log.Info("TODO: Do something with changedValidators", changedValidators) // Commit block, get hash back - hash, logStr, err := proxyAppConn.CommitSync() - if err != nil { - log.Warn("Error in proxyAppConn.CommitSync", "error", err) - return err + res := proxyAppConn.CommitSync() + if res.IsErr() { + log.Warn("Error in proxyAppConn.CommitSync", "error", res) + return res } - if logStr != "" { - log.Debug("Commit.Log: " + logStr) + if res.Log != "" { + log.Debug("Commit.Log: " + res.Log) } log.Info(Fmt("ExecBlock got %v valid txs and %v invalid txs", validTxs, invalidTxs)) // Set the state's new AppHash - s.AppHash = hash + s.AppHash = res.Data return nil }