Browse Source

Added user and password for kevacoin daemon.

pool
Jianping Wu 6 years ago
parent
commit
816f10f045
  1. 18
      config.example.json
  2. 2
      pool/pool.go
  3. 6
      rpc/rpc.go

18
config.example.json

@ -16,19 +16,19 @@ @@ -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 @@ @@ -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 @@ @@ -48,9 +48,11 @@
"upstream": [
{
"name": "Main",
"name": "Test",
"host": "127.0.0.1",
"port": 18081,
"port": 19332,
"user": "yourusername",
"password": "yourpassword",
"timeout": "10s"
}
],

2
pool/pool.go

@ -35,6 +35,8 @@ type Upstream struct { @@ -35,6 +35,8 @@ type Upstream struct {
Name string `json:"name"`
Host string `json:"host"`
Port int `json:"port"`
User string `json:"user"`
Password string `json:"password"`
Timeout string `json:"timeout"`
}

6
rpc/rpc.go

@ -54,7 +54,7 @@ type JSONRpcResp struct { @@ -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) { @@ -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 {

Loading…
Cancel
Save