6 jww "github.com/spf13/jwalterweatherman"
7 "github.com/vapor/blockchain/rpc"
12 // Success indicates the rpc calling is successful.
14 // ErrLocalExe indicates error occurs before the rpc calling.
16 // ErrConnect indicates error occurs connecting to the bytomd, e.g.,
17 // bytomd can't parse the received arguments.
19 // ErrLocalParse indicates error occurs locally when parsing the response.
21 // ErrRemote indicates error occurs in bytomd.
26 coreURL = env.String("BYTOM_URL", "http://localhost:8888")
29 // Wraper rpc's client
30 func MustRPCClient() *rpc.Client {
32 return &rpc.Client{BaseURL: *coreURL}
35 // Wrapper rpc call api.
36 func ClientCall(path string, req ...interface{}) (interface{}, int) {
38 var response = &Response{}
39 var request interface{}
45 client := MustRPCClient()
46 client.Call(context.Background(), path, request, response)
48 switch response.Status {
50 jww.ERROR.Println(response.Msg)
53 jww.ERROR.Println("Unable to connect to the bytomd")
54 return nil, ErrConnect
57 return response.Data, Success