Documentation ¶
Index ¶
- type NetAdapter
- func (na *NetAdapter) ID() *id.ID
- func (na *NetAdapter) P2PBroadcast(netConnections []*NetConnection, message appmessage.Message) error
- func (na *NetAdapter) P2PConnect(address string) error
- func (na *NetAdapter) P2PConnectionCount() int
- func (na *NetAdapter) P2PConnections() []*NetConnection
- func (na *NetAdapter) SetP2PRouterInitializer(routerInitializer RouterInitializer)
- func (na *NetAdapter) SetRPCRouterInitializer(routerInitializer RouterInitializer)
- func (na *NetAdapter) Start() error
- func (na *NetAdapter) Stop() error
- type NetConnection
- func (c *NetConnection) Address() string
- func (c *NetConnection) Disconnect()
- func (c *NetConnection) ID() *id.ID
- func (c *NetConnection) IsOutbound() bool
- func (c *NetConnection) NetAddress() *appmessage.NetAddress
- func (c *NetConnection) SetID(peerID *id.ID)
- func (c *NetConnection) SetOnInvalidMessageHandler(onInvalidMessageHandler server.OnInvalidMessageHandler)
- func (c *NetConnection) String() string
- type RouterInitializer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NetAdapter ¶
type NetAdapter struct {
// contains filtered or unexported fields
}
NetAdapter is an abstraction layer over networking. This type expects a RouteInitializer function. This function weaves together the various "routes" (messages and message handlers) without exposing anything related to networking internals.
func NewNetAdapter ¶
func NewNetAdapter(cfg *config.Config) (*NetAdapter, error)
NewNetAdapter creates and starts a new NetAdapter on the given listeningPort
func (*NetAdapter) ID ¶
func (na *NetAdapter) ID() *id.ID
ID returns this netAdapter's ID in the network
func (*NetAdapter) P2PBroadcast ¶
func (na *NetAdapter) P2PBroadcast(netConnections []*NetConnection, message appmessage.Message) error
P2PBroadcast sends the given `message` to every peer corresponding to each NetConnection in the given netConnections
func (*NetAdapter) P2PConnect ¶
func (na *NetAdapter) P2PConnect(address string) error
P2PConnect tells the NetAdapter's underlying p2p server to initiate a connection to the given address
func (*NetAdapter) P2PConnectionCount ¶
func (na *NetAdapter) P2PConnectionCount() int
P2PConnectionCount returns the count of the connected p2p connections
func (*NetAdapter) P2PConnections ¶
func (na *NetAdapter) P2PConnections() []*NetConnection
P2PConnections returns a list of p2p connections currently connected and active
func (*NetAdapter) SetP2PRouterInitializer ¶
func (na *NetAdapter) SetP2PRouterInitializer(routerInitializer RouterInitializer)
SetP2PRouterInitializer sets the p2pRouterInitializer function for the net adapter
func (*NetAdapter) SetRPCRouterInitializer ¶
func (na *NetAdapter) SetRPCRouterInitializer(routerInitializer RouterInitializer)
SetRPCRouterInitializer sets the rpcRouterInitializer function for the net adapter
func (*NetAdapter) Start ¶
func (na *NetAdapter) Start() error
Start begins the operation of the NetAdapter
type NetConnection ¶
type NetConnection struct {
// contains filtered or unexported fields
}
NetConnection is a wrapper to a server connection for use by services external to NetAdapter
func (*NetConnection) Address ¶
func (c *NetConnection) Address() string
Address returns the address associated with this connection
func (*NetConnection) Disconnect ¶
func (c *NetConnection) Disconnect()
Disconnect disconnects the given connection
func (*NetConnection) ID ¶
func (c *NetConnection) ID() *id.ID
ID returns the ID associated with this connection
func (*NetConnection) IsOutbound ¶
func (c *NetConnection) IsOutbound() bool
IsOutbound returns whether the connection is outbound
func (*NetConnection) NetAddress ¶
func (c *NetConnection) NetAddress() *appmessage.NetAddress
NetAddress returns the NetAddress associated with this connection
func (*NetConnection) SetID ¶
func (c *NetConnection) SetID(peerID *id.ID)
SetID sets the ID associated with this connection
func (*NetConnection) SetOnInvalidMessageHandler ¶
func (c *NetConnection) SetOnInvalidMessageHandler(onInvalidMessageHandler server.OnInvalidMessageHandler)
SetOnInvalidMessageHandler sets the invalid message handler for this connection
func (*NetConnection) String ¶
func (c *NetConnection) String() string
type RouterInitializer ¶
type RouterInitializer func(*routerpkg.Router, *NetConnection)
RouterInitializer is a function that initializes a new router to be used with a new connection