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

* [NOD-140] Converted DNSSeeder to use btclog. * [NOD-140] Converted MiningSimulator to use btclog. * [NOD-140] Converted TxGen to use btclog. * [NOD-140] Fixed log level in handlePanic in txgen. * [NOD-140] Renamed logger to log everywhere. Removed superfluous flag-setting to go-log.
48 lines
943 B
Go
48 lines
943 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"time"
|
|
|
|
"github.com/daglabs/btcd/rpcclient"
|
|
)
|
|
|
|
func connectToServers(cfg *config, addressList []string) ([]*simulatorClient, error) {
|
|
clients := make([]*simulatorClient, len(addressList))
|
|
|
|
var cert []byte
|
|
if !cfg.DisableTLS {
|
|
var err error
|
|
cert, err = ioutil.ReadFile(cfg.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",
|
|
DisableTLS: cfg.DisableTLS,
|
|
RequestTimeout: time.Second / 2,
|
|
}
|
|
|
|
if !cfg.DisableTLS {
|
|
connCfg.Certificates = cert
|
|
}
|
|
|
|
var err error
|
|
clients[i], err = newSimulatorClient(address, connCfg)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
log.Infof("Connected to server %s", address)
|
|
}
|
|
|
|
return clients, nil
|
|
}
|