mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-02 12:16:43 +00:00

* [NOD-70] Added GetBlockTemplate method to rpcclient * [NOD-70] Basic infrastructure for mining simulator * [NOD-70] Fix txFees in NewBlockTempalte: include value for fee transaction + don't set fee for coinbase = -totalFees. * [NOD-70] Added capabilities parameter to Client.GetBlockTemplate call * [NOD-70] Dirty version of mining simulator complete * [NOD-70] cleaned up mining simulator * [NOD-70] Added dockerfile to mining simulator * [NOD-70] Updated base config path of mining simulator to mining_simulator * [NOD-70] Remove error return from msgblock.AddTransaction - it never returns one * [NOD-70] Renamed r -> random * [NOD-70] Move paths initialization of mining simulator to main * [NOD-70] Cleaned up mining simulator dockerfile * [NOD-70] Add '--' to tini argument
42 lines
834 B
Go
42 lines
834 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"log"
|
|
|
|
"github.com/daglabs/btcd/rpcclient"
|
|
)
|
|
|
|
var certificatePath string
|
|
|
|
func connectToServers(addressList []string) ([]*rpcclient.Client, error) {
|
|
clients := make([]*rpcclient.Client, len(addressList))
|
|
|
|
cert, err := ioutil.ReadFile(certificatePath)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("Error reading certificates file: %s", err)
|
|
}
|
|
|
|
for i, address := range addressList {
|
|
connCfg := &rpcclient.ConnConfig{
|
|
Host: address,
|
|
Endpoint: "ws",
|
|
User: "user",
|
|
Pass: "pass",
|
|
Certificates: cert,
|
|
}
|
|
|
|
client, err := rpcclient.New(connCfg, nil)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("Error connecting to address %s: %s", address, err)
|
|
}
|
|
|
|
clients[i] = client
|
|
|
|
log.Printf("Connected to server %s", address)
|
|
}
|
|
|
|
return clients, nil
|
|
}
|