Added user and password for kevacoin daemon.

This commit is contained in:
Jianping Wu 2019-02-26 17:04:52 -08:00
parent 0d0a700cac
commit 816f10f045
3 changed files with 20 additions and 14 deletions

View File

@ -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"
}
],

View File

@ -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 {

View File

@ -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 {