diff --git a/config.example.json b/config.example.json index 7078ec0..5e3fd71 100644 --- a/config.example.json +++ b/config.example.json @@ -16,19 +16,19 @@ "listen": [ { - "host": "0.0.0.0", + "host": "127.0.0.1", "port": 1111, - "diff": 8000, + "diff": 1000, "maxConn": 32768 }, { - "host": "0.0.0.0", + "host": "127.0.0.1", "port": 3333, - "diff": 16000, + "diff": 2000, "maxConn": 32768 }, { - "host": "0.0.0.0", + "host": "127.0.0.1", "port": 5555, "diff": 16000, "maxConn": 32768 @@ -38,7 +38,7 @@ "frontend": { "enabled": true, - "listen": "0.0.0.0:8082", + "listen": "127.0.0.1:8080", "login": "admin", "password": "", "hideIP": false @@ -48,9 +48,11 @@ "upstream": [ { - "name": "Main", + "name": "Test", "host": "127.0.0.1", - "port": 18081, + "port": 19332, + "user": "yourusername", + "password": "yourpassword", "timeout": "10s" } ], diff --git a/pool/pool.go b/pool/pool.go index 80d226b..4c8e6c5 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -32,10 +32,12 @@ type Port struct { } type Upstream struct { - Name string `json:"name"` - Host string `json:"host"` - Port int `json:"port"` - Timeout string `json:"timeout"` + Name string `json:"name"` + Host string `json:"host"` + Port int `json:"port"` + User string `json:"user"` + Password string `json:"password"` + Timeout string `json:"timeout"` } type Frontend struct { diff --git a/rpc/rpc.go b/rpc/rpc.go index cbdab21..3e09348 100644 --- a/rpc/rpc.go +++ b/rpc/rpc.go @@ -54,7 +54,7 @@ type JSONRpcResp struct { } func NewRPCClient(cfg *pool.Upstream) (*RPCClient, error) { - rawUrl := fmt.Sprintf("http://%s:%v/json_rpc", cfg.Host, cfg.Port) + rawUrl := fmt.Sprintf("http://%s:%v/", cfg.Host, cfg.Port) url, err := url.Parse(rawUrl) if err != nil { return nil, err @@ -64,11 +64,13 @@ func NewRPCClient(cfg *pool.Upstream) (*RPCClient, error) { rpcClient.client = &http.Client{ Timeout: timeout, } + rpcClient.login = cfg.User + rpcClient.password = cfg.Password return rpcClient, nil } func (r *RPCClient) GetBlockTemplate(reserveSize int, address string) (*GetBlockTemplateReply, error) { - params := map[string]interface{}{"reserve_size": reserveSize, "wallet_address": address} + params := []string{} rpcResp, err := r.doPost(r.Url.String(), "getblocktemplate", params) var reply *GetBlockTemplateReply if err != nil {