store

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddrBook

type AddrBook interface {
	// AddAddr append some net addresses of peer.
	AddAddr(pid peer.ID, addr ...ma.Multiaddr)
	// SetAddrs record some addresses of peer.
	// This function will clean all addresses that not in list.
	SetAddrs(pid peer.ID, addrs []ma.Multiaddr)
	// RemoveAddr remove some net addresses of peer.
	RemoveAddr(pid peer.ID, addr ...ma.Multiaddr)
	// GetFirstAddr return first net address of peer.
	// If no address stored, return nil.
	GetFirstAddr(pid peer.ID) ma.Multiaddr
	// GetAddrs return all net address of peer.
	GetAddrs(pid peer.ID) []ma.Multiaddr
	// RemovePeer pid
	RemovePeer(pid peer.ID)
}

AddrBook is a store that manage the net addresses of peers.

type PeerStore

type PeerStore interface {
	// AddrBook is a store that manage the net addresses of peers.
	AddrBook
	// ProtocolBook is a store that manage the protocols supported by peers.
	ProtocolBook
}

PeerStore is an interface wrapped AddrBook and ProtocolBook.

type ProtocolBook

type ProtocolBook interface {
	// AddProtocol append some protocols supported by peer.
	AddProtocol(pid peer.ID, protocols ...protocol.ID)
	// SetProtocols record some protocols supported by peer.
	// This function will clean all protocols that not in list.
	SetProtocols(pid peer.ID, protocols []protocol.ID)
	// DeleteProtocol remove some protocols of peer.
	DeleteProtocol(pid peer.ID, protocols ...protocol.ID)
	// ClearProtocol remove all records of peer.
	ClearProtocol(pid peer.ID)
	// GetProtocols return protocols list of peer.
	GetProtocols(pid peer.ID) []protocol.ID
	// ContainsProtocol return whether peer has supported all the protocols in list.
	ContainsProtocol(pid peer.ID, protocol protocol.ID) bool
	// ProtocolContained return the list of protocols supported
	// that was contained in the list given.
	ProtocolContained(pid peer.ID, protocol ...protocol.ID) []protocol.ID
	// AllSupportProtocolPeers return the list of peer id
	// which is the id of peers who support all protocols given.
	AllSupportProtocolPeers(protocol ...protocol.ID) []peer.ID
}

ProtocolBook is a store that manage the protocols supported by peers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL