@@ -27,7 +27,7 @@ import (
27
27
// It will try to get the proof for the given key. If it is successful,
28
28
// it will return the height and also unserialize proof.Data into the data
29
29
// argument (so pass in a pointer to the appropriate struct)
30
- func GetParsed (key []byte , data interface {}, height int , prove bool ) (uint64 , error ) {
30
+ func GetParsed (key []byte , data interface {}, height int64 , prove bool ) (int64 , error ) {
31
31
bs , h , err := Get (key , height , prove )
32
32
if err != nil {
33
33
return 0 , err
@@ -47,16 +47,19 @@ func GetParsed(key []byte, data interface{}, height int, prove bool) (uint64, er
47
47
// we just repeat whatever any (potentially malicious) node gives us.
48
48
// Only use that if you are running the full node yourself,
49
49
// and it is localhost or you have a secure connection (not HTTP)
50
- func Get (key []byte , height int , prove bool ) (data.Bytes , uint64 , error ) {
50
+ func Get (key []byte , height int64 , prove bool ) (data.Bytes , int64 , error ) {
51
51
if height < 0 {
52
52
return nil , 0 , fmt .Errorf ("Height cannot be negative" )
53
53
}
54
54
55
55
if ! prove {
56
56
node := commands .GetNode ()
57
57
resp , err := node .ABCIQueryWithOptions ("/key" , key ,
58
- rpcclient.ABCIQueryOptions {Trusted : true , Height : uint64 (height )})
59
- return data .Bytes (resp .Value ), resp .Height , err
58
+ rpcclient.ABCIQueryOptions {Trusted : true , Height : int64 (height )})
59
+ if resp == nil {
60
+ return nil , height , err
61
+ }
62
+ return data .Bytes (resp .Response .Value ), resp .Response .Height , err
60
63
}
61
64
val , h , _ , err := GetWithProof (key , height )
62
65
return val , h , err
@@ -65,7 +68,7 @@ func Get(key []byte, height int, prove bool) (data.Bytes, uint64, error) {
65
68
// GetWithProof returns the values stored under a given key at the named
66
69
// height as in Get. Additionally, it will return a validated merkle
67
70
// proof for the key-value pair if it exists, and all checks pass.
68
- func GetWithProof (key []byte , height int ) (data.Bytes , uint64 , iavl.KeyProof , error ) {
71
+ func GetWithProof (key []byte , height int64 ) (data.Bytes , int64 , iavl.KeyProof , error ) {
69
72
node := commands .GetNode ()
70
73
cert , err := commands .GetCertifier ()
71
74
if err != nil {
@@ -93,19 +96,19 @@ func ParseHexKey(args []string, argname string) ([]byte, error) {
93
96
}
94
97
95
98
// GetHeight reads the viper config for the query height
96
- func GetHeight () int {
97
- return viper .GetInt (FlagHeight )
99
+ func GetHeight () int64 {
100
+ return int64 ( viper .GetInt (FlagHeight ) )
98
101
}
99
102
100
103
type proof struct {
101
- Height uint64 `json:"height"`
104
+ Height int64 `json:"height"`
102
105
Data interface {} `json:"data"`
103
106
}
104
107
105
108
// FoutputProof writes the output of wrapping height and info
106
109
// in the form {"data": <the_data>, "height": <the_height>}
107
110
// to the provider io.Writer
108
- func FoutputProof (w io.Writer , v interface {}, height uint64 ) error {
111
+ func FoutputProof (w io.Writer , v interface {}, height int64 ) error {
109
112
wrap := & proof {height , v }
110
113
blob , err := data .ToJSON (wrap )
111
114
if err != nil {
@@ -118,6 +121,6 @@ func FoutputProof(w io.Writer, v interface{}, height uint64) error {
118
121
// OutputProof prints the proof to stdout
119
122
// reuse this for printing proofs and we should enhance this for text/json,
120
123
// better presentation of height
121
- func OutputProof (data interface {}, height uint64 ) error {
124
+ func OutputProof (data interface {}, height int64 ) error {
122
125
return FoutputProof (os .Stdout , data , height )
123
126
}
0 commit comments