peering

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package mock_interfaces is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDiscoveryListener

func NewDiscoveryListener(logger *logrus.Logger, addr net.Addr) interfaces.RPCListener

NewDiscoveryListener returns a new Listener that conforms to the RPCListener interface.

func NewListener

func NewListener(logger *logrus.Logger, addr net.Addr) interfaces.RPCListener

NewListener returns a new Listener that conforms to the RPCListener interface.

Types

type DiscoveryListener

type DiscoveryListener struct {
	// contains filtered or unexported fields
}

DiscoveryListener allows a P2PConn to be converted into a net.Conn through the Accept method. This allows the injection of P2PConn objects into the grpc server through registering the Listener as the listener used by a grpc server.

func (*DiscoveryListener) Accept

func (rpcl *DiscoveryListener) Accept() (net.Conn, error)

Accept allows Listener to implement net.Listener interface When called, Accept returns a net.Conn connection to the caller as new connections arrive.

func (*DiscoveryListener) Addr

func (rpcl *DiscoveryListener) Addr() net.Addr

Addr allows Listener to implement net.Listener interface

func (*DiscoveryListener) Close

func (rpcl *DiscoveryListener) Close() error

Close allows Listener to implement net.Listener interface Close also closes the Listener Accept method and raises an error to the caller of Accept.

func (*DiscoveryListener) NewConnection

func (rpcl *DiscoveryListener) NewConnection(conn interfaces.P2PConn) error

NewConnection allows a P2PConn to be injected into the Listener such that the goroutine calling Accept will recv the P2PConn as a net.Conn

type GossipFunc

type GossipFunc func(fn func(interfaces.PeerLease) error)

GossipFunc is a function to be passed in that allows the local node to gossip outbound messages. Use peerManager.Gossip

type Listener

type Listener struct {
	// contains filtered or unexported fields
}

Listener allows a P2PConn to be converted into a net.Conn through the Accept method. This allows the injection of P2PConn objects into the grpc server through registering the Listener as the listener used by a grpc server.

func (*Listener) Accept

func (rpcl *Listener) Accept() (net.Conn, error)

Accept allows Listener to implement net.Listener interface When called, Accept returns a net.Conn connection to the caller as new connections arrive.

func (*Listener) Addr

func (rpcl *Listener) Addr() net.Addr

Addr allows Listener to implement net.Listener interface

func (*Listener) Close

func (rpcl *Listener) Close() error

Close allows Listener to implement net.Listener interface Close also closes the Listener Accept method and raises an error to the caller of Accept.

func (*Listener) NewConnection

func (rpcl *Listener) NewConnection(conn interfaces.P2PConn) error

NewConnection allows a P2PConn to be injected into the Listener such that the goroutine calling Accept will recv the P2PConn as a net.Conn

type MockP2PClient

type MockP2PClient struct {
	// contains filtered or unexported fields
}

MockP2PClient is a mock of P2PClient interface

func NewMockP2PClient

func NewMockP2PClient(ctrl *gomock.Controller) *MockP2PClient

NewMockP2PClient creates a new mock instance

func (*MockP2PClient) Close

func (m *MockP2PClient) Close() error

Close mocks base method

func (*MockP2PClient) CloseChan

func (m *MockP2PClient) CloseChan() <-chan struct{}

CloseChan mocks base method

func (*MockP2PClient) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockP2PClient) GetBlockHeaders

GetBlockHeaders mocks base method

func (*MockP2PClient) GetMinedTxs

GetMinedTxs mocks base method

func (*MockP2PClient) GetPeers

GetPeers mocks base method

func (*MockP2PClient) GetPendingTxs

GetPendingTxs mocks base method

func (*MockP2PClient) GetSnapShotNode

GetSnapShotNodes mocks base method

func (*MockP2PClient) GetSnapShotStateData

GetSnapShotLeaves mocks base method

func (*MockP2PClient) GossipBlockHeader

GossipBlockHeader mocks base method

func (*MockP2PClient) GossipNextHeight

GossipNextHeight mocks base method

func (*MockP2PClient) GossipNextRound

GossipNextRound mocks base method

func (*MockP2PClient) GossipPreCommit

GossipPreCommit mocks base method

func (*MockP2PClient) GossipPreCommitNil

GossipPreCommitNil mocks base method

func (*MockP2PClient) GossipPreVote

GossipPreVote mocks base method

func (*MockP2PClient) GossipPreVoteNil

GossipPreVoteNil mocks base method

func (*MockP2PClient) GossipProposal

GossipProposal mocks base method

func (*MockP2PClient) GossipTransaction

GossipTransaction mocks base method

func (*MockP2PClient) NodeAddr

func (m *MockP2PClient) NodeAddr() interfaces.NodeAddr

NodeAddr mocks base method

func (*MockP2PClient) Status

Status mocks base method

type MockP2PClientMockRecorder

type MockP2PClientMockRecorder struct {
	// contains filtered or unexported fields
}

MockP2PClientMockRecorder is the mock recorder for MockP2PClient

func (*MockP2PClientMockRecorder) Close

func (mr *MockP2PClientMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close

func (*MockP2PClientMockRecorder) CloseChan

func (mr *MockP2PClientMockRecorder) CloseChan() *gomock.Call

CloseChan indicates an expected call of CloseChan

func (*MockP2PClientMockRecorder) GetBlockHeaders

func (mr *MockP2PClientMockRecorder) GetBlockHeaders(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call

GetBlockHeaders indicates an expected call of GetBlockHeaders

func (*MockP2PClientMockRecorder) GetMinedTxs

func (mr *MockP2PClientMockRecorder) GetMinedTxs(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call

GetMinedTxs indicates an expected call of GetMinedTxs

func (*MockP2PClientMockRecorder) GetPeers

func (mr *MockP2PClientMockRecorder) GetPeers(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call

GetPeers indicates an expected call of GetPeers

func (*MockP2PClientMockRecorder) GetPendingTxs

func (mr *MockP2PClientMockRecorder) GetPendingTxs(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call

GetPendingTxs indicates an expected call of GetPendingTxs

func (*MockP2PClientMockRecorder) GetSnapShotNodes

func (mr *MockP2PClientMockRecorder) GetSnapShotNodes(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call

GetSnapShotNodes indicates an expected call of GetSnapShotNodes

func (*MockP2PClientMockRecorder) GetSnapShotStateData

func (mr *MockP2PClientMockRecorder) GetSnapShotStateData(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call

GetSnapShotLeaves indicates an expected call of GetSnapShotLeaves

func (*MockP2PClientMockRecorder) GossipBlockHeader

func (mr *MockP2PClientMockRecorder) GossipBlockHeader(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call

GossipBlockHeader indicates an expected call of GossipBlockHeader

func (*MockP2PClientMockRecorder) GossipNextHeight

func (mr *MockP2PClientMockRecorder) GossipNextHeight(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call

GossipNextHeight indicates an expected call of GossipNextHeight

func (*MockP2PClientMockRecorder) GossipNextRound

func (mr *MockP2PClientMockRecorder) GossipNextRound(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call

GossipNextRound indicates an expected call of GossipNextRound

func (*MockP2PClientMockRecorder) GossipPreCommit

func (mr *MockP2PClientMockRecorder) GossipPreCommit(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call

GossipPreCommit indicates an expected call of GossipPreCommit

func (*MockP2PClientMockRecorder) GossipPreCommitNil

func (mr *MockP2PClientMockRecorder) GossipPreCommitNil(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call

GossipPreCommitNil indicates an expected call of GossipPreCommitNil

func (*MockP2PClientMockRecorder) GossipPreVote

func (mr *MockP2PClientMockRecorder) GossipPreVote(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call

GossipPreVote indicates an expected call of GossipPreVote

func (*MockP2PClientMockRecorder) GossipPreVoteNil

func (mr *MockP2PClientMockRecorder) GossipPreVoteNil(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call

GossipPreVoteNil indicates an expected call of GossipPreVoteNil

func (*MockP2PClientMockRecorder) GossipProposal

func (mr *MockP2PClientMockRecorder) GossipProposal(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call

GossipProposal indicates an expected call of GossipProposal

func (*MockP2PClientMockRecorder) GossipTransaction

func (mr *MockP2PClientMockRecorder) GossipTransaction(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call

GossipTransaction indicates an expected call of GossipTransaction

func (*MockP2PClientMockRecorder) NodeAddr

func (mr *MockP2PClientMockRecorder) NodeAddr() *gomock.Call

NodeAddr indicates an expected call of NodeAddr

func (*MockP2PClientMockRecorder) Status

func (mr *MockP2PClientMockRecorder) Status(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call

Status indicates an expected call of Status

type MuxHandler

type MuxHandler struct {
	// contains filtered or unexported fields
}

MuxHandler allows a P2PMuxConn to be converted into a bidirectional grpc client and server connection. The server side connection is injected into an exiting grpc server running the P2P service and the client is bound against a the P2P service.

func NewMuxServerHandler

func NewMuxServerHandler(logger *logrus.Logger, addr net.Addr, service interfaces.P2PServer) *MuxHandler

NewMuxServerHandler creates a new multiplexed grpc tunneling system for P2PMuxConn objects.

func (*MuxHandler) Close

func (rpcm *MuxHandler) Close() error

Close will shutdown the server handler.

func (*MuxHandler) HandleConnection

func (rpcm *MuxHandler) HandleConnection(conn interfaces.P2PMuxConn) (interfaces.P2PClient, error)

HandleConnection binds the P2PMuxConn to a grpc client and server. Internally this method uses the Initiator() method to determine if it should run the client or server side handshake. The only object returned is the P2PClient. The server side connection is handed off to the grpc server. Both the client and the server side connections may be shut down using the original P2PMuxConn Close method.

type PeerLeaseFunc

type PeerLeaseFunc func(ctx context.Context) (interfaces.PeerLease, error)

PeerLeaseFunc is a function that takes in a context and returns a PeerLease object. The PeerLease object represents a peer with an active P2P connection. This object may be used to invoke requests against a remote peer.

type PeerManager

type PeerManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

PeerManager is a self contained system for management of peering. Other packages that need to send data to peers may subscribe to the peer manager and be notified of active peers. This notification occurs through the peer subscription system.

func NewPeerManager

func NewPeerManager(p2pServer interfaces.P2PServer, chainID uint32, pLimMin int, pLimMax int, fwMode bool, fwHost, listenAddr, tprivk string) (*PeerManager, error)

NewPeerManager creates a new peer manager based on the Configuration values passed to the process.

func (*PeerManager) Close

func (ps *PeerManager) Close() error

Close will shutdown the peer manager causing all transports and connections to be closed as well.

func (*PeerManager) CloseChan

func (ps *PeerManager) CloseChan() <-chan struct{}

CloseChan returns a channel that is closed when the peerManager is shutting down.

func (*PeerManager) Counts

func (ps *PeerManager) Counts() (int, int)

Counts returns the active and inactive peer counts

func (*PeerManager) GetPeers

func (ps *PeerManager) GetPeers(ctx context.Context, req *pb.GetPeersRequest) (*pb.GetPeersResponse, error)

GetPeers is the handler for the get peers request.

func (*PeerManager) HandleP2PGetPeers

func (ps *PeerManager) HandleP2PGetPeers(ctx context.Context, req *pb.GetPeersRequest) (*pb.GetPeersResponse, error)

HandleP2PGetPeers is the handler for the P2P method GetPeers

func (*PeerManager) PeeringComplete

func (ps *PeerManager) PeeringComplete() bool

PeeringComplete returns true if the peering is complete for the node

func (*PeerManager) Start

func (ps *PeerManager) Start()

Start launches the background loops of the peer manager

func (*PeerManager) Status

func (ps *PeerManager) Status(smap map[string]interface{}) (map[string]interface{}, error)

Status returns the data needed for the status logger.

func (*PeerManager) Subscribe

func (ps *PeerManager) Subscribe() interfaces.PeerSubscription

Subscribe returns a peer subscription. This allows the caller to have a remote copy of the active peer set for calling rpc methods on the peers without blocking the discovery system. The remote copy will update as peers are added and dropped, but any peer in the remote active set may have its connections closed at any time. Thus the caller should always gracefully handle communication failures.

type PeerSubscription

type PeerSubscription struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

PeerSubscription allows a remote service to maintain a reference to the active peer set. This reference will be kept in sync with the local copy of the active peer set and allows external services to perform P2P RPC with the active peers set.

func (*PeerSubscription) CloseChan

func (p *PeerSubscription) CloseChan() <-chan struct{}

CloseChan returns a channel that will be closed when the subscription *BEGINS* shutdown

func (*PeerSubscription) GossipConsensus

func (p *PeerSubscription) GossipConsensus(hsh []byte, fn func(context.Context, interfaces.PeerLease) error)

GossipConsensus allows a service to Gossip a consensus message to all active peers

func (*PeerSubscription) GossipTx

func (p *PeerSubscription) GossipTx(hsh []byte, fn func(context.Context, interfaces.PeerLease) error)

GossipTx allows a service to Gossip a transaction all active peers

func (*PeerSubscription) PeerLease

PeerLease returns a random active peer

func (*PeerSubscription) PreventGossipConsensus

func (p *PeerSubscription) PreventGossipConsensus(addr interfaces.NodeAddr, hsh []byte)

PreventGossipConsensus allows a peer to be marked as having knowledge of a message. This will prevent the peer from being spammed by stale gossip as well as allow the local node to request any associated data directly from the providing peer.

func (*PeerSubscription) PreventGossipTx

func (p *PeerSubscription) PreventGossipTx(addr interfaces.NodeAddr, hsh []byte)

PreventGossipTx allows a peer to be marked as having knowledge of a message. This will prevent the peer from being spammed by stale gossip as well as allow the local node to request any associated data directly from the providing peer.

func (*PeerSubscription) RequestLease

func (p *PeerSubscription) RequestLease(ctx context.Context, msg []byte) (interfaces.PeerLease, error)

RequestLease returns an active peer that has sent the requested msg

type ServerHandler

type ServerHandler struct {
	// contains filtered or unexported fields
}

ServerHandler binds a RPCListener to a grpc server such that the connections injected into the listener will be bound against the grpc server.

func NewBootNodeServerHandler

func NewBootNodeServerHandler(logger *logrus.Logger, addr net.Addr, service interfaces.BootNodeServer) *ServerHandler

NewBootNodeServerHandler returns a RPC ServerHandler for the BootNode Service.

func NewDiscoveryServerHandler

func NewDiscoveryServerHandler(logger *logrus.Logger, addr net.Addr, service interfaces.DiscoveryServer) *ServerHandler

NewDiscoveryServerHandler returns a RPC ServerHandler for the Discovery Service.

func (*ServerHandler) Close

func (rpch *ServerHandler) Close() error

Close will shutdown the server handler.

func (*ServerHandler) HandleConnection

func (rpch *ServerHandler) HandleConnection(conn interfaces.P2PConn) error

HandleConnection will inject the provided P2PConn into the NewConnection method of the bound RPCListener for consumption by the grpc server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL