mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-29 18:26:41 +00:00

* [NOD-386] Extract net parsing functionality to a shared place. * [NOD-386] Add extract ActiveNetParams to cmdconfig * [NOD-386] Adding comments so go-vet won't shout at me * [NOD-386] Rename package name to config * [NOD-386] Rename commandConfig to configFlags * [NOD-386] Rename function to ResolveNetwork * [NOD-386] Fix renaming errors * [NOD-386] Refactor network config to btcd level so APIserver and btcd could use it * [NOD-386] Refactor network config to config package * [NOD-386] Move ActiveNetParams to network section * [NOD-386] Explictly return nil * [NOD-386] Reuse activeNetParams from netwrok config * [NOD-386] Set ActiveNetworkFlags instance to be global * [NOD-386] Remove redundant newline * [NOD-386] Init ActiveNetParams in address manager test * [NOD-386] Add dnsseeder network config * [NOD-386] Use ActiveConfig() method to access configuration
40 lines
803 B
Go
40 lines
803 B
Go
package main
|
|
|
|
import (
|
|
"github.com/daglabs/btcd/rpcclient"
|
|
"github.com/pkg/errors"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func connectToServer(cfg *configFlags) (*txgenClient, error) {
|
|
var cert []byte
|
|
if !cfg.DisableTLS {
|
|
var err error
|
|
cert, err = ioutil.ReadFile(cfg.CertificatePath)
|
|
if err != nil {
|
|
return nil, errors.Errorf("Error reading certificates file: %s", err)
|
|
}
|
|
}
|
|
|
|
connCfg := &rpcclient.ConnConfig{
|
|
Host: cfg.Address,
|
|
Endpoint: "ws",
|
|
User: "user",
|
|
Pass: "pass",
|
|
DisableTLS: cfg.DisableTLS,
|
|
}
|
|
|
|
if !cfg.DisableTLS {
|
|
connCfg.Certificates = cert
|
|
}
|
|
|
|
client, err := newTxgenClient(connCfg)
|
|
if err != nil {
|
|
return nil, errors.Errorf("Error connecting to address %s: %s", cfg.Address, err)
|
|
}
|
|
|
|
log.Infof("Connected to server %s", cfg.Address)
|
|
|
|
return client, nil
|
|
}
|