kaspad/cmd/txgen/connect.go
Ori Newman 6250342b86 [NOD-205] Reimplement txgen (#320)
* [NOD-205] Reimplement txgen

* [NOD-205] remove prev outpoints of all initial transactions

* [NOD-205] break txloop to smaller functions

* [NOD-205] Limit collectTransactions iterations

* [NOD-205] Use requiredConfirmations constant instead of inline number

* [NOD-205] Rename wTx -> walletTx

* [NOD-205] Remove handleNewBlock

* [NOD-205] Fix search and replace error
2019-06-04 18:06:35 +03:00

41 lines
775 B
Go

package main
import (
"fmt"
"github.com/daglabs/btcd/rpcclient"
"io/ioutil"
)
func connectToServer(cfg *config) (*txgenClient, error) {
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)
}
}
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, fmt.Errorf("Error connecting to address %s: %s", cfg.Address, err)
}
log.Infof("Connected to server %s", cfg.Address)
return client, nil
}