6 jww "github.com/spf13/jwalterweatherman"
8 "github.com/vapor/blockchain/rpc"
13 // Success indicates the rpc calling is successful.
15 // ErrLocalExe indicates error occurs before the rpc calling.
17 // ErrConnect indicates error occurs connecting to the bytomd, e.g.,
18 // bytomd can't parse the received arguments.
20 // ErrLocalParse indicates error occurs locally when parsing the response.
22 // ErrRemote indicates error occurs in bytomd.
27 coreURL = env.String("BYTOM_URL", "http://127.0.0.1:9889")
30 // Wraper rpc's client
31 func MustRPCClient() *rpc.Client {
33 return &rpc.Client{BaseURL: *coreURL}
36 // Wrapper rpc call api.
37 func ClientCall(path string, req ...interface{}) (interface{}, int) {
39 var response = &api.Response{}
40 var request interface{}
46 client := MustRPCClient()
47 client.Call(context.Background(), path, request, response)
49 switch response.Status {
51 jww.ERROR.Println(response.Msg)
54 jww.ERROR.Println("Unable to connect to the bytomd")
55 return nil, ErrConnect
58 return response.Data, Success