diff --git a/account/priv_account.go b/account/priv_account.go index 4e016a0f40a966683f282e7015232d8157567ce7..eb5f424ffbcca05208d0a26c40bd08e1fb93d848 100644 --- a/account/priv_account.go +++ b/account/priv_account.go @@ -3,8 +3,8 @@ package account import ( "github.com/tendermint/ed25519" . "github.com/tendermint/go-common" - "github.com/tendermint/go-wire" "github.com/tendermint/go-crypto" + "github.com/tendermint/go-wire" ) type PrivAccount struct { @@ -37,7 +37,7 @@ func (pA *PrivAccount) String() string { // Generates a new account with private key. func GenPrivAccount() *PrivAccount { privKeyBytes := new([64]byte) - copy(privKeyBytes[:32], CRandBytes(32)) + copy(privKeyBytes[:32], crypto.CRandBytes(32)) pubKeyBytes := ed25519.MakePublicKey(privKeyBytes) pubKey := crypto.PubKeyEd25519(*pubKeyBytes) privKey := crypto.PrivKeyEd25519(*privKeyBytes) diff --git a/erisdb/serve.go b/erisdb/serve.go index 813e9ce4b637875afe64510055d98760908a9397..478ae9aa7b3a1b09d79e7b6dab45ae5fbd2df481 100644 --- a/erisdb/serve.go +++ b/erisdb/serve.go @@ -108,7 +108,7 @@ func ServeErisDB(workDir string) (*server.ServeProcess, error) { // Start the tmsp listener for state update commands go func() { // TODO config - _, err := tmsp.StartListener(sConf.Consensus.TMSPListener, app) + _, err := tmsp.NewServer(sConf.Consensus.TMSPListener, app) if err != nil { // TODO: play nice Exit(err.Error()) diff --git a/tmsp/erisdb.go b/tmsp/erisdb.go index 8ab9db62455a95962e1c258fbb65f9da2c4b16cc..99757c0f44feb4e07f7472913db78bafdadb3082 100644 --- a/tmsp/erisdb.go +++ b/tmsp/erisdb.go @@ -100,7 +100,7 @@ func (app *ErisDBApp) SetOption(key string, value string) (log string) { } // Implements tmsp.Application -func (app ErisDBApp) AppendTx(txBytes []byte) (code tmsp.CodeType, result []byte, log string) { +func (app ErisDBApp) AppendTx(txBytes []byte) (res tmsp.Result) { // XXX: if we had tx ids we could cache the decoded txs on CheckTx var n int var err error @@ -108,26 +108,25 @@ func (app ErisDBApp) AppendTx(txBytes []byte) (code tmsp.CodeType, result []byte buf := bytes.NewBuffer(txBytes) wire.ReadBinaryPtr(tx, buf, len(txBytes), &n, &err) if err != nil { - return tmsp.CodeType_EncodingError, nil, fmt.Sprintf("Encoding error: %v", err) + return tmsp.NewError(tmsp.CodeType_EncodingError, fmt.Sprintf("Encoding error: %v", err)) } err = sm.ExecTx(app.cache, *tx, true, app.evc) if err != nil { - return tmsp.CodeType_InternalError, nil, fmt.Sprintf("Encoding error: %v", err) + return tmsp.NewError(tmsp.CodeType_InternalError, fmt.Sprintf("Encoding error: %v", err)) } - - return tmsp.CodeType_OK, nil, "" + return tmsp.NewResultOK(nil, "Success") } // Implements tmsp.Application -func (app ErisDBApp) CheckTx(txBytes []byte) (code tmsp.CodeType, result []byte, log string) { +func (app ErisDBApp) CheckTx(txBytes []byte) (res tmsp.Result) { var n int var err error tx := new(types.Tx) buf := bytes.NewBuffer(txBytes) wire.ReadBinaryPtr(tx, buf, len(txBytes), &n, &err) if err != nil { - return tmsp.CodeType_EncodingError, nil, fmt.Sprintf("Encoding error: %v", err) + return tmsp.NewError(tmsp.CodeType_EncodingError, fmt.Sprintf("Encoding error: %v", err)) } // we need the lock because CheckTx can run concurrently with Commit, @@ -136,15 +135,15 @@ func (app ErisDBApp) CheckTx(txBytes []byte) (code tmsp.CodeType, result []byte, defer app.mtx.Unlock() err = sm.ExecTx(app.checkCache, *tx, false, nil) if err != nil { - return tmsp.CodeType_InternalError, nil, fmt.Sprintf("Encoding error: %v", err) + return tmsp.NewError(tmsp.CodeType_InternalError, fmt.Sprintf("Encoding error: %v", err)) } - return tmsp.CodeType_OK, nil, "" + return tmsp.NewResultOK(nil, "Success") } // Implements tmsp.Application // Commit the state (called at end of block) -func (app *ErisDBApp) Commit() (hash []byte, log string) { +func (app *ErisDBApp) Commit() (res tmsp.Result) { // sync the AppendTx cache app.cache.Sync() @@ -157,9 +156,9 @@ func (app *ErisDBApp) Commit() (hash []byte, log string) { // flush events to listeners (XXX: note issue with blocking) app.evc.Flush() - return app.state.Hash(), "" + return tmsp.NewResultOK(app.state.Hash(), "Success") } -func (app *ErisDBApp) Query(query []byte) (code tmsp.CodeType, result []byte, log string) { - return tmsp.CodeType_OK, nil, "" +func (app *ErisDBApp) Query(query []byte) (res tmsp.Result) { + return tmsp.NewResultOK(nil, "Success") }