Documentation ¶
Index ¶
- func GenerateKeyPairWithPath(path string) error
- func GetKeyPairFromPath(path string) (crypto.PrivKey, error)
- func GetPeerIDFromPath(path string) (string, error)
- type Channel
- type Config
- type DefaultConn
- type DefaultNodeInfo
- type DefaultPeer
- type Module
- type NetAddress
- type NodeInfo
- type Peer
- type PeerID
- type PeerSet
- type RawConn
- type Switch
- func (sw *Switch) AddReactor(mo Module, f libs.Reactor) error
- func (sw *Switch) Broadcast(chID int32, msgBytes []byte)
- func (sw *Switch) GetP2PID(peerID string) (string, error)
- func (sw *Switch) Send(peer string, chID int32, msgBytes []byte) error
- func (sw *Switch) Start() error
- func (sw *Switch) Stop() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateKeyPairWithPath ¶
func GetPeerIDFromPath ¶
Types ¶
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
func NewChannel ¶
func NewChannel(id int32, conn *DefaultConn, log libs.Logger) *Channel
type Config ¶
type Config struct { Address string BootStrap []string PrivateKey string // only for networking PublicKey string // only for networking TickerTimeSec int64 }
---------------------------------------------------------------------------------------------------
type DefaultConn ¶
type DefaultConn struct {
// contains filtered or unexported fields
}
func NewDefaultConn ¶
func (*DefaultConn) AddChannel ¶
func (dc *DefaultConn) AddChannel(id int32) error
func (*DefaultConn) FlushStop ¶
func (dc *DefaultConn) FlushStop()
FlushStop replicates the logic of OnStop. It additionally ensures that all successful .Send() calls will get flushed before closing the connection.
func (*DefaultConn) Start ¶
func (dc *DefaultConn) Start()
type DefaultNodeInfo ¶
type DefaultNodeInfo struct {
// contains filtered or unexported fields
}
func (*DefaultNodeInfo) CompatibleWith ¶
func (n *DefaultNodeInfo) CompatibleWith(other NodeInfo) error
func (*DefaultNodeInfo) ID ¶
func (n *DefaultNodeInfo) ID() PeerID
func (*DefaultNodeInfo) NetAddress ¶
func (n *DefaultNodeInfo) NetAddress() (*NetAddress, error)
func (*DefaultNodeInfo) Validate ¶
func (n *DefaultNodeInfo) Validate() error
for use in the handshake.
type DefaultPeer ¶
type DefaultPeer struct { *DefaultNodeInfo // contains filtered or unexported fields }
func (*DefaultPeer) FlushStop ¶
func (p *DefaultPeer) FlushStop()
func (*DefaultPeer) Start ¶
func (dc *DefaultPeer) Start()
type NetAddress ¶
NetAddress defines information about a peer on the network including its ID, IP address, and port.
type NodeInfo ¶
type NodeInfo interface { ID() PeerID NetAddress() (*NetAddress, error) // for use in the handshake. Validate() error CompatibleWith(other NodeInfo) error }
NodeInfo exposes basic info of a node and determines if we're compatible.
type PeerSet ¶
type PeerSet struct {
// contains filtered or unexported fields
}
PeerSet is a special structure for keeping a table of peers. Iteration over the peers is super fast and thread-safe.
func NewPeerSet ¶
func NewPeerSet() *PeerSet
type Switch ¶
type Switch struct {
// contains filtered or unexported fields
}
func (*Switch) AddReactor ¶
AddReactor should be invoked before switch.Start(), consensus module must be registered.
func (*Switch) Broadcast ¶
Broadcast runs a go routine for each attempted send, which will block trying to send for defaultSendTimeoutSeconds. Returns a channel which receives success values for each attempted send (false if times out). Channel will be closed once msg bytes are sent to all peers (or time out).
NOTE: Broadcast uses goroutines, so order of broadcast may not be preserved.