Documentation ¶
Index ¶
- Constants
- type Contacts
- type ErrHandleEvent
- type Node
- func (n *Node) AddContact(id peer.ID, services ...Service)
- func (n *Node) AddProtocol(p bspl.Protocol, roles ...bspl.Role)
- func (n *Node) AddServices(id peer.ID, services ...Service)
- func (n Node) Addrs() []multiaddr.Multiaddr
- func (n *Node) Announce()
- func (n *Node) ExportKey() []byte
- func (n *Node) FindContact(protocolKey string, role bspl.Role) []peer.ID
- func (n *Node) FindNodes()
- func (n Node) ID() peer.ID
- func (n *Node) Peerstore() peerstore.Peerstore
- func (n *Node) Reasoner() bspl.Reasoner
- func (n *Node) SendEvent(target peer.ID, event events.Event) (bool, error)
- type Service
- type Services
Constants ¶
const (
// LogName identifies the log of this module
LogName = "nahs/net"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrHandleEvent ¶
ErrHandleEvent is returned when handling events and sent as a response
func (ErrHandleEvent) Error ¶
func (e ErrHandleEvent) Error() string
type Node ¶
type Node struct { // Contacts of the Node Contacts Contacts // OpenInstances maps instance keys to peer.IDs to // verify that the node sending the event is the one // who created it OpenInstances map[string]peer.ID // contains filtered or unexported fields }
Node represents a single NaHS peer.
func LocalNode ¶
LocalNode returns a new node without settings up the discovery protocols. This is useful for testing without connection or wasting time.
func NodeFromPrivKey ¶
NodeFromPrivKey is a newNode wrapper to create a new Node with the specified private key. Additional options may be provided.
func (*Node) AddContact ¶
AddContact adds a new contact to the Node
func (*Node) AddProtocol ¶
AddProtocol adds a protocol to the node and establishes what roles the node plays in that protocol. If the protocol was already added, the roles that weren't already established are added.
func (*Node) AddServices ¶
AddServices is functionally the same as AddContact for now.
func (Node) Addrs ¶
func (n Node) Addrs() []multiaddr.Multiaddr
Addrs returns the multiaddr of the libp2p host of the Node
func (*Node) FindContact ¶
FindContact finds a contact that offers a service and plays a role in that service. A slice of the peer.ID of those contacts is returned.
func (*Node) FindNodes ¶
func (n *Node) FindNodes()
FindNodes searches for other NaHS nodes in the network