default:
return "", false
}
- data, exitCode := util.ClientCall(methodPath, ¶m)
+ data, exitCode := ClientCall(methodPath, ¶m)
if exitCode != util.Success {
return "", false
}
func init() {
sendTxCmd.PersistentFlags().IntVar(&thdTxNum, "thdtxnum", 10, " The number of transactions per goroutine")
sendTxCmd.PersistentFlags().IntVar(&thdNum, "thdnum", 5, "goroutine num")
- sendTxCmd.PersistentFlags().IntVar(&assetNum, "assetnum", 10, "Number of transactions asset")
+ sendTxCmd.PersistentFlags().IntVar(&assetNum, "assetnum", 100000000, "Number of transactions asset,unit: neu")
sendTxCmd.PersistentFlags().StringVar(&configFile, "config", "./config.toml", "config file")
}
--- /dev/null
+package core
+
+import (
+ "context"
+
+ "github.com/bytom/api"
+ "github.com/bytom/blockchain/rpc"
+ "github.com/bytom/env"
+)
+
+const (
+ // Success indicates the rpc calling is successful.
+ Success = iota
+ // ErrLocalExe indicates error occurs before the rpc calling.
+ ErrLocalExe
+ // ErrConnect indicates error occurs connecting to the bytomd, e.g.,
+ // bytomd can't parse the received arguments.
+ ErrConnect
+ // ErrLocalParse indicates error occurs locally when parsing the response.
+ ErrLocalParse
+ // ErrRemote indicates error occurs in bytomd.
+ ErrRemote
+)
+
+var (
+ coreURL = env.String("BYTOM_URL", "http://localhost:9888")
+)
+
+// Wraper rpc's client
+func MustRPCClient() *rpc.Client {
+ env.Parse()
+ return &rpc.Client{BaseURL: *coreURL}
+}
+
+// Wrapper rpc call api.
+func ClientCall(path string, req ...interface{}) (interface{}, int) {
+
+ var response = &api.Response{}
+ var request interface{}
+
+ if req != nil {
+ request = req[0]
+ }
+
+ client := MustRPCClient()
+ client.Call(context.Background(), path, request, response)
+
+ switch response.Status {
+ case api.FAIL:
+ return nil, ErrRemote
+ case "":
+ return nil, ErrConnect
+ }
+
+ return response.Data, Success
+}