Browse Source

CommitSync() returns tmsp.Result

pull/206/merge
Jae Kwon 9 years ago
parent
commit
8183e3201b
5 changed files with 21 additions and 21 deletions
  1. +3
    -3
      mempool/mempool_test.go
  2. +5
    -5
      node/node.go
  3. +1
    -1
      proxy/app_conn.go
  4. +5
    -5
      proxy/local_app_conn.go
  5. +7
    -7
      state/execution.go

+ 3
- 3
mempool/mempool_test.go View File

@ -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)
}
}


+ 5
- 5
node/node.go View File

@ -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


+ 1
- 1
proxy/app_conn.go View File

@ -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)
}

+ 5
- 5
proxy/local_app_conn.go View File

@ -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) {


+ 7
- 7
state/execution.go View File

@ -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
}


Loading…
Cancel
Save