CheckTx and DeliverTx return ResponseCheckTx and ResponseDeliverTx respectively

Commit now returns ResponseCommit
This commit is contained in:
Anton Kaliaev
2017-11-20 20:26:37 -06:00
parent 92801dbd72
commit 3a3d508e5c
7 changed files with 74 additions and 44 deletions

View File

@ -13,14 +13,14 @@ type Application interface {
Query(RequestQuery) ResponseQuery // Query for state
// Mempool Connection
CheckTx(tx []byte) Result // Validate a tx for the mempool
CheckTx(tx []byte) ResponseCheckTx // Validate a tx for the mempool
// Consensus Connection
InitChain(RequestInitChain) // Initialize blockchain with validators and other info from TendermintCore
BeginBlock(RequestBeginBlock) // Signals the beginning of a block
DeliverTx(tx []byte) Result // Deliver a tx for full processing
DeliverTx(tx []byte) ResponseDeliverTx // Deliver a tx for full processing
EndBlock(height uint64) ResponseEndBlock // Signals the end of a block, returns changes to the validator set
Commit() Result // Commit the state and return the application Merkle root hash
Commit() ResponseCommit // Commit the state and return the application Merkle root hash
}
//------------------------------------

View File

@ -15,16 +15,16 @@ func (BaseApplication) SetOption(key string, value string) (log string) {
return ""
}
func (BaseApplication) DeliverTx(tx []byte) Result {
return NewResultOK(nil, "")
func (BaseApplication) DeliverTx(tx []byte) ResponseDeliverTx {
return ResponseDeliverTx{}
}
func (BaseApplication) CheckTx(tx []byte) Result {
return NewResultOK(nil, "")
func (BaseApplication) CheckTx(tx []byte) ResponseCheckTx {
return ResponseCheckTx{}
}
func (BaseApplication) Commit() Result {
return NewResultOK([]byte("nil"), "")
func (BaseApplication) Commit() ResponseCommit {
return ResponseCommit{Code: CodeType_OK, Data: []byte("nil")}
}
func (BaseApplication) Query(req RequestQuery) ResponseQuery {

View File

@ -106,6 +106,10 @@ func (r *ResponseCheckTx) Result() Result {
}
}
func (r ResponseCheckTx) IsErr() bool {
return r.Code != CodeType_OK
}
// Convert ResponseDeliverTx to standard Result
func (r *ResponseDeliverTx) Result() Result {
return Result{
@ -116,6 +120,10 @@ func (r *ResponseDeliverTx) Result() Result {
}
}
func (r ResponseDeliverTx) IsErr() bool {
return r.Code != CodeType_OK
}
type ResultQuery struct {
Code CodeType `json:"code"`
Index int64 `json:"index"`