Browse Source

Added user and password for kevacoin daemon.

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

18
config.example.json

@ -16,19 +16,19 @@
"listen": [ "listen": [
{ {
"host": "0.0.0.0", "host": "127.0.0.1",
"port": 1111, "port": 1111,
"diff": 8000, "diff": 1000,
"maxConn": 32768 "maxConn": 32768
}, },
{ {
"host": "0.0.0.0", "host": "127.0.0.1",
"port": 3333, "port": 3333,
"diff": 16000, "diff": 2000,
"maxConn": 32768 "maxConn": 32768
}, },
{ {
"host": "0.0.0.0", "host": "127.0.0.1",
"port": 5555, "port": 5555,
"diff": 16000, "diff": 16000,
"maxConn": 32768 "maxConn": 32768
@ -38,7 +38,7 @@
"frontend": { "frontend": {
"enabled": true, "enabled": true,
"listen": "0.0.0.0:8082", "listen": "127.0.0.1:8080",
"login": "admin", "login": "admin",
"password": "", "password": "",
"hideIP": false "hideIP": false
@ -48,9 +48,11 @@
"upstream": [ "upstream": [
{ {
"name": "Main", "name": "Test",
"host": "127.0.0.1", "host": "127.0.0.1",
"port": 18081, "port": 19332,
"user": "yourusername",
"password": "yourpassword",
"timeout": "10s" "timeout": "10s"
} }
], ],

10
pool/pool.go

@ -32,10 +32,12 @@ type Port struct {
} }
type Upstream struct { type Upstream struct {
Name string `json:"name"` Name string `json:"name"`
Host string `json:"host"` Host string `json:"host"`
Port int `json:"port"` Port int `json:"port"`
Timeout string `json:"timeout"` User string `json:"user"`
Password string `json:"password"`
Timeout string `json:"timeout"`
} }
type Frontend struct { type Frontend struct {

6
rpc/rpc.go

@ -54,7 +54,7 @@ type JSONRpcResp struct {
} }
func NewRPCClient(cfg *pool.Upstream) (*RPCClient, error) { 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) url, err := url.Parse(rawUrl)
if err != nil { if err != nil {
return nil, err return nil, err
@ -64,11 +64,13 @@ func NewRPCClient(cfg *pool.Upstream) (*RPCClient, error) {
rpcClient.client = &http.Client{ rpcClient.client = &http.Client{
Timeout: timeout, Timeout: timeout,
} }
rpcClient.login = cfg.User
rpcClient.password = cfg.Password
return rpcClient, nil return rpcClient, nil
} }
func (r *RPCClient) GetBlockTemplate(reserveSize int, address string) (*GetBlockTemplateReply, error) { 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) rpcResp, err := r.doPost(r.Url.String(), "getblocktemplate", params)
var reply *GetBlockTemplateReply var reply *GetBlockTemplateReply
if err != nil { if err != nil {

Loading…
Cancel
Save