Documentation ¶
Index ¶
- Constants
- Variables
- func Errors(arr []error) []int
- func ExtractData(pm *Payload) (service.Data, error)
- func New(ctx context.Context, config config.Config, logger log.Log, path string) (*swarm, error)
- func StringIdentifiers(boot ...*swarm) []string
- type IntegrationTestSuite
- func (its *IntegrationTestSuite) ForAll(f func(idx int, s NodeTestInstance) error, filter []int) []error
- func (its *IntegrationTestSuite) ForAllAsync(ctx context.Context, f func(idx int, s NodeTestInstance) error) (error, []error)
- func (its *IntegrationTestSuite) SetupSuite()
- func (its *IntegrationTestSuite) TearDownSuite()
- func (its *IntegrationTestSuite) WaitForGossip(ctx context.Context) error
- type Lookuper
- type NodeTestInstance
- type Payload
- type Peer
- type PeerSubscriptionProvider
- type Peers
- type ProtocolMessage
- type ProtocolMessageMetadata
- type Service
- type UDPMux
- func (mux *UDPMux) ProcessDirectProtocolMessage(sender p2pcrypto.PublicKey, protocol string, data service.Data, ...) error
- func (mux *UDPMux) RegisterDirectProtocolWithChannel(name string, c chan service.DirectMessage) chan service.DirectMessage
- func (mux *UDPMux) SendMessage(peerPubkey p2pcrypto.PublicKey, protocol string, payload []byte) error
- func (mux *UDPMux) SendWrappedMessage(nodeID p2pcrypto.PublicKey, protocol string, payload *service.DataMsgWrapper) error
- func (mux *UDPMux) Shutdown()
- func (mux *UDPMux) Start() error
Constants ¶
const ConnectingTimeout = 20 * time.Second //todo: add to the config
ConnectingTimeout is the timeout we wait when trying to connect a neighborhood
const NoResultsInterval = 1 * time.Second
NoResultsInterval is the timeout we wait between requesting more peers repeatedly
Variables ¶
var ( // ErrBadFormat1 could'nt deserialize the payload ErrBadFormat1 = errors.New("bad msg format, could'nt deserialize 1") // ErrBadFormat2 could'nt deserialize the protocol message payload ErrBadFormat2 = errors.New("bad msg format, could'nt deserialize 2") // ErrOutOfSync is returned when messsage timestamp was out of sync ErrOutOfSync = errors.New("received out of sync msg") // ErrFailDecrypt session cant decrypt ErrFailDecrypt = errors.New("can't decrypt message payload with session key") // ErrNoProtocol we don't have the protocol message ErrNoProtocol = errors.New("received msg to an unsupported protocol") // ErrNoSession we don't have this session ErrNoSession = errors.New("connection is missing a session") )
Functions ¶
func New ¶
New creates a new P2P service a.k.a `swarm` it tries to load node information from the disk.
func StringIdentifiers ¶
func StringIdentifiers(boot ...*swarm) []string
Types ¶
type IntegrationTestSuite ¶
type IntegrationTestSuite struct { suite.Suite BootstrapNodesCount int BootstrappedNodeCount int NeighborsCount int BeforeHook func(idx int, s NodeTestInstance) AfterHook func(idx int, s NodeTestInstance) Instances []*swarm // contains filtered or unexported fields }
IntegrationTestSuite is a suite which bootstraps a network according to the given params and lets you run actions on this network. you must set the params before running the suite.
func (*IntegrationTestSuite) ForAll ¶
func (its *IntegrationTestSuite) ForAll(f func(idx int, s NodeTestInstance) error, filter []int) []error
func (*IntegrationTestSuite) ForAllAsync ¶
func (its *IntegrationTestSuite) ForAllAsync(ctx context.Context, f func(idx int, s NodeTestInstance) error) (error, []error)
func (*IntegrationTestSuite) SetupSuite ¶
func (its *IntegrationTestSuite) SetupSuite()
func (*IntegrationTestSuite) TearDownSuite ¶
func (its *IntegrationTestSuite) TearDownSuite()
func (*IntegrationTestSuite) WaitForGossip ¶
func (its *IntegrationTestSuite) WaitForGossip(ctx context.Context) error
type NodeTestInstance ¶
type Payload ¶
type Payload struct { Payload []byte Wrapped *service.DataMsgWrapper }
type Peers ¶
func NewPeersImpl ¶
NewPeersImpl creates a Peers using specified parameters and returns it
type ProtocolMessage ¶
type ProtocolMessage struct { Metadata *ProtocolMessageMetadata Payload *Payload }
type ProtocolMessageMetadata ¶
type Service ¶
Service is a wrapper for service.Service to expose the Service interface to `p2p` clients
type UDPMux ¶
type UDPMux struct {
// contains filtered or unexported fields
}
UDPMux is a server for receiving and sending udp messages. through protocols.
func NewUDPMux ¶
func NewUDPMux(localNode node.LocalNode, lookuper Lookuper, udpNet udpNetwork, networkid int8, logger log.Log) *UDPMux
NewUDPMux creates a new udp protocol server
func (*UDPMux) ProcessDirectProtocolMessage ¶
func (mux *UDPMux) ProcessDirectProtocolMessage(sender p2pcrypto.PublicKey, protocol string, data service.Data, metadata service.P2PMetadata) error
ProcessDirectProtocolMessage passes a message to the protocol.
func (*UDPMux) RegisterDirectProtocolWithChannel ¶
func (mux *UDPMux) RegisterDirectProtocolWithChannel(name string, c chan service.DirectMessage) chan service.DirectMessage
RegisterDirectProtocolWithChannel registers a protocol on a channel, should be done before `Start` was called. not thread-safe
func (*UDPMux) SendMessage ¶
func (mux *UDPMux) SendMessage(peerPubkey p2pcrypto.PublicKey, protocol string, payload []byte) error
SendMessage is a proxy method to the sendMessageImpl.
func (*UDPMux) SendWrappedMessage ¶
func (mux *UDPMux) SendWrappedMessage(nodeID p2pcrypto.PublicKey, protocol string, payload *service.DataMsgWrapper) error
SendWrappedMessage is a proxy method to the sendMessageImpl. it sends a wrapped message and used within MessageServer
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package discovery implements a Distributed Hash Table based on Kademlia protocol.
|
Package discovery implements a Distributed Hash Table based on Kademlia protocol. |
wire/delimited
Package delimited implements a reader and writer for simple streams of length-delimited byte records.
|
Package delimited implements a reader and writer for simple streams of length-delimited byte records. |