Documentation ¶
Index ¶
- Constants
- type Store
- func (s *Store) Add(ns string, info peer.AddrInfo) (time.Duration, error)
- func (s *Store) Backup(ctx context.Context) error
- func (s *Store) NamespacePeers(ns string, limit int) []peer.AddrInfo
- func (s *Store) Peers() []peer.AddrInfo
- func (s *Store) Remove(ns string, pid peer.ID)
- func (s *Store) Restore(ctx context.Context) error
- func (s *Store) Start()
- func (s *Store) Stop()
- type StoreOption
- type StoreOptions
Constants ¶
View Source
const ( // PeerRegistrationTTL is a deadline for the next registration. PeerRegistrationTTL = time.Hour )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is an in-memory data structure for storing peers' data.
func NewStore ¶
func NewStore(b backup.Backend, opts ...StoreOption) *Store
NewStore creates a new peer store.
func (*Store) NamespacePeers ¶
NamespacePeers returns a random selection of peers from the given namespace.
type StoreOption ¶
type StoreOption func(opts *StoreOptions)
StoreOption is a store option setter.
func WithMaxNamespacePeers ¶
func WithMaxNamespacePeers(max int) StoreOption
WithMaxNamespacePeers configures maximum number of peers in a namespace.
func WithMaxPeerNamespaces ¶
func WithMaxPeerNamespaces(max int) StoreOption
WithMaxPeerNamespaces configures maximum number of peer's namespaces.
func WithMaxPeers ¶
func WithMaxPeers(max int) StoreOption
WithMaxPeers configures maximum number of peers.
type StoreOptions ¶
type StoreOptions struct {
// contains filtered or unexported fields
}
StoreOptions are store options.
func DefaultStoreOptions ¶
func DefaultStoreOptions() *StoreOptions
DefaultStoreOptions returns the default store options.
Click to show internal directories.
Click to hide internal directories.