github.com/evdatsion/aphelion-dpos-bft@v0.32.1/rpc/core/abci.go (about) 1 package core 2 3 import ( 4 abci "github.com/evdatsion/aphelion-dpos-bft/abci/types" 5 cmn "github.com/evdatsion/aphelion-dpos-bft/libs/common" 6 "github.com/evdatsion/aphelion-dpos-bft/proxy" 7 ctypes "github.com/evdatsion/aphelion-dpos-bft/rpc/core/types" 8 rpctypes "github.com/evdatsion/aphelion-dpos-bft/rpc/lib/types" 9 ) 10 11 // Query the application for some information. 12 // 13 // ```shell 14 // curl 'localhost:26657/abci_query?path=""&data="abcd"&prove=false' 15 // ``` 16 // 17 // ```go 18 // client := client.NewHTTP("tcp://0.0.0.0:26657", "/websocket") 19 // err := client.Start() 20 // if err != nil { 21 // // handle error 22 // } 23 // defer client.Stop() 24 // result, err := client.ABCIQuery("", "abcd", true) 25 // ``` 26 // 27 // > The above command returns JSON structured like this: 28 // 29 // ```json 30 // { 31 // "error": "", 32 // "result": { 33 // "response": { 34 // "log": "exists", 35 // "height": "0", 36 // "proof": "010114FED0DAD959F36091AD761C922ABA3CBF1D8349990101020103011406AA2262E2F448242DF2C2607C3CDC705313EE3B0001149D16177BC71E445476174622EA559715C293740C", 37 // "value": "61626364", 38 // "key": "61626364", 39 // "index": "-1", 40 // "code": "0" 41 // } 42 // }, 43 // "id": "", 44 // "jsonrpc": "2.0" 45 // } 46 // ``` 47 // 48 // ### Query Parameters 49 // 50 // | Parameter | Type | Default | Required | Description | 51 // |-----------+--------+---------+----------+------------------------------------------------| 52 // | path | string | false | false | Path to the data ("/a/b/c") | 53 // | data | []byte | false | true | Data | 54 // | height | int64 | 0 | false | Height (0 means latest) | 55 // | prove | bool | false | false | Includes proof if true | 56 func ABCIQuery(ctx *rpctypes.Context, path string, data cmn.HexBytes, height int64, prove bool) (*ctypes.ResultABCIQuery, error) { 57 resQuery, err := proxyAppQuery.QuerySync(abci.RequestQuery{ 58 Path: path, 59 Data: data, 60 Height: height, 61 Prove: prove, 62 }) 63 if err != nil { 64 return nil, err 65 } 66 logger.Info("ABCIQuery", "path", path, "data", data, "result", resQuery) 67 return &ctypes.ResultABCIQuery{Response: *resQuery}, nil 68 } 69 70 // Get some info about the application. 71 // 72 // ```shell 73 // curl 'localhost:26657/abci_info' 74 // ``` 75 // 76 // ```go 77 // client := client.NewHTTP("tcp://0.0.0.0:26657", "/websocket") 78 // err := client.Start() 79 // if err != nil { 80 // // handle error 81 // } 82 // defer client.Stop() 83 // info, err := client.ABCIInfo() 84 // ``` 85 // 86 // > The above command returns JSON structured like this: 87 // 88 // ```json 89 // { 90 // "error": "", 91 // "result": { 92 // "response": { 93 // "data": "{\"size\":3}" 94 // } 95 // }, 96 // "id": "", 97 // "jsonrpc": "2.0" 98 // } 99 // ``` 100 func ABCIInfo(ctx *rpctypes.Context) (*ctypes.ResultABCIInfo, error) { 101 resInfo, err := proxyAppQuery.InfoSync(proxy.RequestInfo) 102 if err != nil { 103 return nil, err 104 } 105 return &ctypes.ResultABCIInfo{Response: *resInfo}, nil 106 }