Documentation ¶
Index ¶
- Constants
- type Message
- type Network
- func (ntw *Network) AddressFromPK(publicKey noise.PublicKey) string
- func (ntw *Network) Bootstrap(peerAddrs []string, timeout time.Duration, peerThreshold int) bool
- func (ntw *Network) BootstrapDefault(peerAddrs []string) bool
- func (ntw *Network) Broadcast(code byte, data []byte)
- func (ntw *Network) Close()
- func (ntw *Network) DisconWithPeers(ids []noise.ID)
- func (ntw *Network) Discover()
- func (ntw *Network) ExternalAddress() string
- func (ntw *Network) FindPeer(target noise.PublicKey) []noise.ID
- func (ntw *Network) GetBroadcastChan() chan broadcast.Message
- func (ntw *Network) GetNodeID() noise.ID
- func (ntw *Network) GetNumPeers() int
- func (ntw *Network) GetPeerAddrs() []noise.ID
- func (ntw *Network) GetRelayChan() chan relay.Message
- func (ntw *Network) Node() *noise.Node
- func (ntw *Network) Process()
- func (ntw *Network) Relay(peerID noise.ID, code byte, data []byte)
- func (ntw *Network) RelayToPB(peerID noise.PublicKey, code byte, data []byte)
Constants ¶
const ( // DefaultBootstrapTimeout is the default timeout for bootstrapping with each peer. DefaultBootstrapTimeout = 10 * time.Second // DefaultPeerThreshold is the default threshold above which bootstrapping is considered successful DefaultPeerThreshold = 8 MsgChanSize = 64 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Message ¶
type Network ¶
type Network struct {
// contains filtered or unexported fields
}
Network encapsulates the communication in a noise p2p network.
func New ¶
func New(hostStr string, port uint16, privatekey noise.PrivateKey, logger *zap.Logger, logging bool) (*Network, error)
New creates and returns a new network instance.
func (*Network) AddressFromPK ¶
AddressFromPK returns the address associated with the public key
func (*Network) Bootstrap ¶
Bootstrap bootstraps a network using a list of peer addresses and returns whether bootstrap finished before timeout.
func (*Network) BootstrapDefault ¶
BootstrapDefault runs Bootstrap with default parameters.
func (*Network) DisconWithPeers ¶
func (ntw *Network) DisconWithPeers(ids []noise.ID)
DisconWithPeers discionnects with the given ids
func (*Network) ExternalAddress ¶
func (*Network) GetBroadcastChan ¶
GetBroadcastChan returns the channel for broadcast messages.
func (*Network) GetNodeID ¶
func (ntw *Network) GetNodeID() noise.ID
GetNodeID returns the network node's skademlia ID.
func (*Network) GetNumPeers ¶
GetNumPeers returns the number of peers the network node has.
func (*Network) GetPeerAddrs ¶
func (ntw *Network) GetPeerAddrs() []noise.ID
peers prints out all peers we are already aware of.
func (*Network) GetRelayChan ¶
GetRelayChan returns the channel for relay messages.