Browse Source

types: methods convert pb types to use data.Bytes

pull/1780/head
Ethan Buchman 8 years ago
parent
commit
8d8e35ae53
1 changed files with 47 additions and 3 deletions
  1. +47
    -3
      types/result.go

+ 47
- 3
types/result.go View File

@ -8,9 +8,9 @@ import (
// CONTRACT: a zero Result is OK.
type Result struct {
Code CodeType
Data data.Bytes
Log string // Can be non-deterministic
Code CodeType `json:"code"`
Data data.Bytes `json:"data"`
Log string `json:"log"` // Can be non-deterministic
}
func NewResult(code CodeType, data []byte, log string) Result {
@ -86,3 +86,47 @@ func NewError(code CodeType, log string) Result {
Log: log,
}
}
//----------------------------------------
// Convenience methods for turning the
// pb type into one using data.Bytes
// Convert ResponseCheckTx to standard Result
func (r *ResponseCheckTx) Result() Result {
return Result{
Code: r.Code,
Data: r.Data,
Log: r.Log,
}
}
// Convert ResponseDeliverTx to standard Result
func (r *ResponseDeliverTx) Result() Result {
return Result{
Code: r.Code,
Data: r.Data,
Log: r.Log,
}
}
type ResultQuery struct {
Code CodeType `json:"code"`
Index int64 `json:"index"`
Key data.Bytes `json:"key"`
Value data.Bytes `json:"value"`
Proof data.Bytes `json:"proof"`
Height uint64 `json:"height"`
Log string `json:"log"`
}
func (r *ResponseQuery) Result() *ResultQuery {
return &ResultQuery{
Code: r.Code,
Index: r.Index,
Key: r.Key,
Value: r.Value,
Proof: r.Proof,
Height: r.Height,
Log: r.Log,
}
}

Loading…
Cancel
Save