Documentation
¶
Index ¶
- Constants
- type Addrbook
- func (b *Addrbook) ActivePeers(remote dndm.Peer) []string
- func (b *Addrbook) AddConn(p dndm.Peer, outbound bool, c network.Conn) error
- func (b *Addrbook) AddPeers(outbound bool, peers ...dndm.Peer) error
- func (b *Addrbook) Addrbook() []*p2ptypes.AddrbookEntry
- func (b *Addrbook) DelConn(p dndm.Peer, c network.Conn)
- func (b *Addrbook) Dials() chan *AddrbookEntry
- func (b *Addrbook) Entry(p dndm.Peer) (*AddrbookEntry, bool)
- func (b *Addrbook) Init(ctx context.Context, log *slog.Logger) error
- func (b *Addrbook) NumConnectedPeers() int
- func (b *Addrbook) Self() dndm.Peer
- func (b *Addrbook) SetSharedPeers(remote dndm.Peer, activePeers []string)
- type AddrbookEntry
- func (a *AddrbookEntry) Dial(ctx context.Context, log *slog.Logger, dialer network.Dialer, ...) (io.ReadWriter, error)
- func (a *AddrbookEntry) IsActive() bool
- func (a *AddrbookEntry) SetConn(c network.Conn) error
- func (a *AddrbookEntry) SetSharedPeers(peers []string)
- func (a *AddrbookEntry) SharedPeers() map[string]struct{}
- func (a *AddrbookEntry) WasPeerShared(peer string) bool
- type Container
- type Endpoint
- func (t *Endpoint) Addrbook() []*p2ptypes.AddrbookEntry
- func (t *Endpoint) Close() error
- func (t *Endpoint) Init(ctx context.Context, logger *slog.Logger, addIntent dndm.IntentCallback, ...) error
- func (t *Endpoint) Local() dndm.Peer
- func (t *Endpoint) Publish(route dndm.Route, opt ...dndm.PubOpt) (dndm.Intent, error)
- func (t *Endpoint) Remote() dndm.Peer
- func (t *Endpoint) Subscribe(route dndm.Route, opt ...dndm.SubOpt) (dndm.Interest, error)
- type HandshakeState
- type Handshaker
- func (h *Handshaker) Close() error
- func (h *Handshaker) Init(ctx context.Context, logger *slog.Logger, addIntent dndm.IntentCallback, ...) error
- func (h *Handshaker) Name() string
- func (h *Handshaker) OnClose(f func()) dndm.Endpoint
- func (h *Handshaker) Publish(route dndm.Route, opt ...dndm.PubOpt) (dndm.Intent, error)
- func (h *Handshaker) SetName(name string)
- func (h *Handshaker) Subscribe(route dndm.Route, opt ...dndm.SubOpt) (dndm.Interest, error)
Constants ¶
View Source
const NumDialers = 10
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Addrbook ¶
type Addrbook struct {
// contains filtered or unexported fields
}
func NewAddrbook ¶
func (*Addrbook) ActivePeers ¶
ActivePeers returns a list of active peers to be shared to the remote peer. The remote peer itself will be excluded as well as any peers that were already shared with the remote.
func (*Addrbook) Addrbook ¶
func (b *Addrbook) Addrbook() []*p2ptypes.AddrbookEntry
func (*Addrbook) Dials ¶
func (b *Addrbook) Dials() chan *AddrbookEntry
func (*Addrbook) NumConnectedPeers ¶
type AddrbookEntry ¶
type AddrbookEntry struct {
sync.Mutex
Peer dndm.Peer
Persistent bool
MaxAttempts int
DefaultBackoff time.Duration
MaxBackoff time.Duration
BackoffMultiplier float64
Attempts int
Failed int
LastSuccess time.Time
Backoff time.Duration
// contains filtered or unexported fields
}
func NewAddrbookEntry ¶
func NewAddrbookEntry(log *slog.Logger, p *p2ptypes.AddrbookEntry) *AddrbookEntry
func (*AddrbookEntry) Dial ¶
func (a *AddrbookEntry) Dial(ctx context.Context, log *slog.Logger, dialer network.Dialer, q chan<- *AddrbookEntry) (io.ReadWriter, error)
func (*AddrbookEntry) IsActive ¶
func (a *AddrbookEntry) IsActive() bool
func (*AddrbookEntry) SetSharedPeers ¶
func (a *AddrbookEntry) SetSharedPeers(peers []string)
func (*AddrbookEntry) SharedPeers ¶
func (a *AddrbookEntry) SharedPeers() map[string]struct{}
func (*AddrbookEntry) WasPeerShared ¶
func (a *AddrbookEntry) WasPeerShared(peer string) bool
type Endpoint ¶
func (*Endpoint) Addrbook ¶
func (t *Endpoint) Addrbook() []*p2ptypes.AddrbookEntry
func (*Endpoint) Init ¶
func (t *Endpoint) Init(ctx context.Context, logger *slog.Logger, addIntent dndm.IntentCallback, addInterest dndm.InterestCallback) error
type HandshakeState ¶
type HandshakeState int
const ( HS_INIT HandshakeState = iota HS_WAIT HS_PEERS HS_DONE )
type Handshaker ¶
type Handshaker struct {
dndm.BaseEndpoint
// contains filtered or unexported fields
}
func NewHandshaker ¶
func NewHandshaker(addrbook *Addrbook, remotePeer dndm.Peer, size int, timeout, pingDuration time.Duration, rw io.ReadWriter, state HandshakeState) *Handshaker
NewHandshake creates a Endpoint wrapper over Remote endpoint that acts as a handshake middleware.
initial state transitions:
Connect to remote: 1. HS_INIT 2. HS_WAIT 3. HS_DONE Remote connects to us: 1. HS_WAIT 2. HS_DONE
func (*Handshaker) Close ¶
func (h *Handshaker) Close() error
func (*Handshaker) Init ¶
func (h *Handshaker) Init(ctx context.Context, logger *slog.Logger, addIntent dndm.IntentCallback, addInterest dndm.InterestCallback) error
Init is used by the Router to initialize this transport.
func (*Handshaker) Name ¶
func (h *Handshaker) Name() string
func (*Handshaker) OnClose ¶
func (h *Handshaker) OnClose(f func()) dndm.Endpoint
func (*Handshaker) SetName ¶
func (h *Handshaker) SetName(name string)
Click to show internal directories.
Click to hide internal directories.