Documentation ¶
Overview ¶
package mesh256 implements an INET256 Service in terms of a distributed routing algorithm and a dynamic set of one hop connections to peers.
Index ¶
- Constants
- func NewAddrSchema(swarms map[string]multiswarm.DynSwarm) multiswarm.AddrSchema
- func NewPeerStore() peers.Store[TransportAddr]
- func NewTestServers(t testing.TB, nf NetworkFactory, xs []inet256.Service)
- func SecureDynSwarm(protoName string, s multiswarm.DynSwarm, privateKey p2p.PrivateKey) (string, multiswarm.DynSecureSwarm)
- func SecureProtocolName(x string) string
- type Addr
- type FindAddrFunc
- type Network
- type NetworkFactory
- type NetworkParams
- type Node
- type NodeParams
- type Params
- type PeerSet
- type PeerStatus
- type Server
- func (s *Server) Close() error
- func (s *Server) Drop(ctx context.Context, privateKey inet256.PrivateKey) error
- func (s *Server) FindAddr(ctx context.Context, prefix []byte, nbits int) (Addr, error)
- func (s *Server) LocalAddr() Addr
- func (s *Server) LookupPublicKey(ctx context.Context, target Addr) (inet256.PublicKey, error)
- func (s *Server) MTU(ctx context.Context, target Addr) int
- func (s *Server) MainAddr() (Addr, error)
- func (s *Server) MainNode() Node
- func (s *Server) Open(ctx context.Context, privateKey inet256.PrivateKey, opts ...inet256.NodeOption) (Node, error)
- func (s *Server) PeerStatus() ([]PeerStatus, error)
- func (s *Server) TransportAddrs() ([]multiswarm.Addr, error)
- type Service
- type Swarm
- type TransportAddr
Constants ¶
const ( TransportMTU = (1 << 16) - 1 MinMTU = inet256.MinMTU MaxMTU = inet256.MaxMTU )
Variables ¶
This section is empty.
Functions ¶
func NewAddrSchema ¶
func NewAddrSchema(swarms map[string]multiswarm.DynSwarm) multiswarm.AddrSchema
func NewPeerStore ¶
func NewPeerStore() peers.Store[TransportAddr]
func NewTestServers ¶
func NewTestServers(t testing.TB, nf NetworkFactory, xs []inet256.Service)
func SecureDynSwarm ¶ added in v0.0.5
func SecureDynSwarm(protoName string, s multiswarm.DynSwarm, privateKey p2p.PrivateKey) (string, multiswarm.DynSecureSwarm)
SecureDynSwarm
func SecureProtocolName ¶ added in v0.0.5
SecureProtocolName returns the name of the protocol after securing an insecure swarm It will match what is returned by Server.TransportAddrs()
Types ¶
type FindAddrFunc ¶
type Network ¶
type Network interface { p2p.Teller[inet256.Addr] LocalAddr() inet256.Addr MTU(context.Context, inet256.Addr) int Close() error LookupPublicKey(context.Context, inet256.Addr) (inet256.PublicKey, error) PublicKey() inet256.PublicKey FindAddr(ctx context.Context, prefix []byte, nbits int) (inet256.Addr, error) }
Network is an instantiated network routing algorithm
This interface is not described in the spec, and is incidental to the implementation.
func NetworkFromSwarm ¶
func NetworkFromSwarm(x Swarm, findAddr FindAddrFunc) Network
NetworkFromSwarm creates a Network from a Swarm
type NetworkFactory ¶
type NetworkFactory func(NetworkParams) Network
NetworkFactory is a constructor for a network
type NetworkParams ¶
type NetworkParams struct { // PrivateKey is the private signing key used for proving identity on the network. PrivateKey inet256.PrivateKey // Swarm facillitates communication with adjacent Nodes. Swarm Swarm // Peers is the set of peers to communicate with. Peers PeerSet // Background is the context that should be used for background operations. // It enables instrumentation through the stdctx/logctx package. Background context.Context }
Params are passed to a NetworkFactory to create a Network. This type really defines the problem domain quite well. Essentially it is a set of one-hop peers and a means to send messages to them.
type NodeParams ¶ added in v0.0.7
type NodeParams struct { PrivateKey inet256.PrivateKey Swarms map[string]multiswarm.DynSwarm Peers peers.Store[TransportAddr] NewNetwork NetworkFactory }
NodeParams configure a Node
type Params ¶
type Params NodeParams
type PeerStatus ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewTestServer ¶
func NewTestServer(t testing.TB, nf NetworkFactory) *Server
func (*Server) LookupPublicKey ¶
func (*Server) Open ¶
func (s *Server) Open(ctx context.Context, privateKey inet256.PrivateKey, opts ...inet256.NodeOption) (Node, error)
func (*Server) PeerStatus ¶
func (s *Server) PeerStatus() ([]PeerStatus, error)
func (*Server) TransportAddrs ¶
func (s *Server) TransportAddrs() ([]multiswarm.Addr, error)
type Swarm ¶
type Swarm interface { p2p.Teller[inet256.Addr] LookupPublicKey(context.Context, inet256.Addr) (inet256.PublicKey, error) PublicKey() inet256.PublicKey LocalAddr() Addr MTU(ctx context.Context, addr Addr) int Close() error }
Swarm is similar to a p2p.Swarm, but uses inet256.Addrs instead of p2p.Addrs
This interface is not described in the spec, and is incidental to the implementation.
type TransportAddr ¶
type TransportAddr = multiswarm.Addr