Documentation ¶
Index ¶
Constants ¶
View Source
const IDLength = 20
Variables ¶
This section is empty.
Functions ¶
func IsNetEOFError ¶
func IsNetTimeoutError ¶
Types ¶
type Host ¶
type Host interface { ID() ID ListenAddr() net.Addr LocalAddrInfo() PeerAddrInfo Bootstrap(ctx context.Context, peerAddresses ...PeerAddrInfo) error Ping(ctx context.Context, address PeerAddrInfo) (bool, error) FindNode(ctx context.Context, nodeID ID) ([]PeerInfo, error) Store(ctx context.Context, key string, value []byte) error FindValue(ctx context.Context, key string) ([]byte, bool, error) KBuckets() *KBuckets Close() error }
type KBuckets ¶
type KBuckets struct {
// contains filtered or unexported fields
}
func NewKBuckets ¶
func NewKBuckets(node Host, k int, opts ...KBucketsOption) *KBuckets
func (*KBuckets) KClosestTo ¶
type KBucketsOption ¶
type KBucketsOption func(entry *KBuckets)
func WithPingTimeout ¶
func WithPingTimeout(timeout time.Duration) KBucketsOption
type NodeOption ¶
type NodeOption func(*host)
func WithLogger ¶
func WithLogger(logger *zap.Logger) NodeOption
type PeerAddrInfo ¶
type PeerAddrInfo struct {
Addresses []string
}
func PeerAddrInfoFromStrings ¶
func PeerAddrInfoFromStrings(addresses ...string) PeerAddrInfo
type PeerConn ¶
type PeerConn struct {
// contains filtered or unexported fields
}
func (*PeerConn) RemoteAddr ¶
type PeerInfo ¶
type PeerInfo struct { ID ID AddrInfo PeerAddrInfo }
type PeerListener ¶
type PeerListener struct {
// contains filtered or unexported fields
}
func NewPeerListener ¶
func NewPeerListener(listenAddress string) (*PeerListener, error)
func (*PeerListener) Accept ¶
func (pl *PeerListener) Accept() (*PeerConn, error)
func (*PeerListener) Addr ¶
func (pl *PeerListener) Addr() net.Addr
func (*PeerListener) Close ¶
func (pl *PeerListener) Close() error
func (*PeerListener) Closed ¶
func (pl *PeerListener) Closed() bool
func (*PeerListener) Port ¶
func (pl *PeerListener) Port() int
type ValueStore ¶
type ValueStore struct {
// contains filtered or unexported fields
}
func NewValueStore ¶
func NewValueStore() *ValueStore
func (*ValueStore) Put ¶
func (v *ValueStore) Put(key string, value []byte)
Click to show internal directories.
Click to hide internal directories.