mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-21 22:36:42 +00:00
27 lines
562 B
Go
27 lines
562 B
Go
package server
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/kaspanet/kaspad/domain/dagconfig"
|
|
"github.com/kaspanet/kaspad/infrastructure/network/rpcclient"
|
|
)
|
|
|
|
func connectToRPC(params *dagconfig.Params, rpcServer string, timeout uint32) (*rpcclient.RPCClient, error) {
|
|
rpcAddress, err := params.NormalizeRPCServerAddress(rpcServer)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
rpcClient, err := rpcclient.NewRPCClient(rpcAddress)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if timeout != 0 {
|
|
rpcClient.SetTimeout(time.Duration(timeout) * time.Second)
|
|
}
|
|
|
|
return rpcClient, err
|
|
}
|