Documentation ¶
Overview ¶
package neteng provides a template for implementing Networks Network implements a mesh256.Network in terms of a Router
Index ¶
- type DeliverFunc
- type InfoFunc
- type Network
- func (n *Network) Bootstrap(ctx context.Context) error
- func (n *Network) Close() error
- func (n *Network) FindAddr(ctx context.Context, prefix []byte, nbits int) (inet256.Addr, error)
- func (n *Network) LocalAddr() inet256.Addr
- func (n *Network) LookupPublicKey(ctx context.Context, target inet256.Addr) (inet256.PublicKey, error)
- func (n *Network) MTU(ctx context.Context, target inet256.Addr) int
- func (n *Network) PublicKey() inet256.PublicKey
- func (n *Network) Receive(ctx context.Context, fn func(p2p.Message[inet256.Addr])) error
- func (n *Network) Tell(ctx context.Context, dst inet256.Addr, data p2p.IOVec) error
- type PublicKeyFunc
- type Router
- type SendFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeliverFunc ¶
DeliverFunc is the type of functions used to deliver data to the application
type Network ¶
type Network struct {
// contains filtered or unexported fields
}
func (*Network) LookupPublicKey ¶
type PublicKeyFunc ¶
PublicKeyFunc is the type of functinos used to get the public key for an ID
type Router ¶
type Router interface { // Reset is called to clear the state of the router Reset(privateKey inet256.PrivateKey, peers mesh256.PeerSet, getPublicKey PublicKeyFunc, now time.Time) // HandleAbove handles a message from the application HandleAbove(to inet256.Addr, data p2p.IOVec, send SendFunc) bool // HandleBelow handles a message from the network. HandleBelow(from inet256.Addr, data []byte, send SendFunc, deliver DeliverFunc, info InfoFunc) // Heartbeat is called periodically with the current time. Heartbeat(now time.Time, send SendFunc) // FindAddr looks up an address FindAddr(send SendFunc, info InfoFunc, prefix []byte, nbits int) // LookupPublicKey looks up a public key LookupPublicKey(send SendFunc, info InfoFunc, target inet256.Addr) }
Router contains logic for routing messages throughout the network Routers do not maintain any backgroud goroutines or allocate any additional resources If all references to a router are lost, resources MUST not leak.
Click to show internal directories.
Click to hide internal directories.