6 "github.com/tendermint/go-wire/data"
9 // Result is a common result object for ABCI calls.
10 // CONTRACT: a zero Result is OK.
12 Code CodeType `json:"code"`
13 Data data.Bytes `json:"data"`
14 Log string `json:"log"` // Can be non-deterministic
17 func NewResult(code CodeType, data []byte, log string) Result {
25 func (res Result) IsOK() bool {
26 return res.Code == CodeType_OK
29 func (res Result) IsErr() bool {
30 return res.Code != CodeType_OK
33 func (res Result) IsSameCode(compare Result) bool {
34 return res.Code == compare.Code
37 func (res Result) Error() string {
38 return fmt.Sprintf("ABCI{code:%v, data:%X, log:%v}", res.Code, res.Data, res.Log)
41 func (res Result) String() string {
42 return fmt.Sprintf("ABCI{code:%v, data:%X, log:%v}", res.Code, res.Data, res.Log)
45 func (res Result) PrependLog(log string) Result {
49 Log: log + ";" + res.Log,
53 func (res Result) AppendLog(log string) Result {
57 Log: res.Log + ";" + log,
61 func (res Result) SetLog(log string) Result {
69 func (res Result) SetData(data []byte) Result {
77 //----------------------------------------
79 // NOTE: if data == nil and log == "", same as zero Result.
80 func NewResultOK(data []byte, log string) Result {
88 func NewError(code CodeType, log string) Result {
95 //----------------------------------------
96 // Convenience methods for turning the
97 // pb type into one using data.Bytes
99 // Convert ResponseCheckTx to standard Result
100 func (r *ResponseCheckTx) Result() Result {
108 // Convert ResponseDeliverTx to standard Result
109 func (r *ResponseDeliverTx) Result() Result {
117 type ResultQuery struct {
118 Code CodeType `json:"code"`
119 Index int64 `json:"index"`
120 Key data.Bytes `json:"key"`
121 Value data.Bytes `json:"value"`
122 Proof data.Bytes `json:"proof"`
123 Height uint64 `json:"height"`
124 Log string `json:"log"`
127 func (r *ResponseQuery) Result() *ResultQuery {