Merge branch 'master' into wb/issue-5908

This commit is contained in:
William Banfield
2021-08-12 12:25:12 -04:00
committed by GitHub
18 changed files with 615 additions and 266 deletions
+5 -4
View File
@@ -2,6 +2,7 @@ package local
import (
"context"
"errors"
"fmt"
"time"
@@ -46,15 +47,15 @@ type Local struct {
// NodeService describes the portion of the node interface that the
// local RPC client constructor needs to build a local client.
type NodeService interface {
ConfigureRPC() (*rpccore.Environment, error)
RPCEnvironment() *rpccore.Environment
EventBus() *types.EventBus
}
// New configures a client that calls the Node directly.
func New(node NodeService) (*Local, error) {
env, err := node.ConfigureRPC()
if err != nil {
return nil, err
env := node.RPCEnvironment()
if env == nil {
return nil, errors.New("rpc is nil")
}
return &Local{
EventBus: node.EventBus(),
+8
View File
@@ -36,6 +36,10 @@ func (env *Environment) NetInfo(ctx *rpctypes.Context) (*ctypes.ResultNetInfo, e
// UnsafeDialSeeds dials the given seeds (comma-separated id@IP:PORT).
func (env *Environment) UnsafeDialSeeds(ctx *rpctypes.Context, seeds []string) (*ctypes.ResultDialSeeds, error) {
if env.P2PPeers == nil {
return nil, errors.New("peer management system does not support this operation")
}
if len(seeds) == 0 {
return &ctypes.ResultDialSeeds{}, fmt.Errorf("%w: no seeds provided", ctypes.ErrInvalidRequest)
}
@@ -53,6 +57,10 @@ func (env *Environment) UnsafeDialPeers(
peers []string,
persistent, unconditional, private bool) (*ctypes.ResultDialPeers, error) {
if env.P2PPeers == nil {
return nil, errors.New("peer management system does not support this operation")
}
if len(peers) == 0 {
return &ctypes.ResultDialPeers{}, fmt.Errorf("%w: no peers provided", ctypes.ErrInvalidRequest)
}