peerstore

package
v0.0.0-...-0bc3d7e Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PeerInfoFromAddr

func PeerInfoFromAddr(addr string) (*peer.AddrInfo, error)

PeerInfoFromAddr extracts the AddrInfo from a multiaddr string.

func PeerInfoFromAddrs

func PeerInfoFromAddrs(addrs []string) ([]*peer.AddrInfo, map[string]string)

PeerInfoFromAddrs extracts the AddrInfo from a multiaddr string slice.

Types

type PeerStore

type PeerStore struct {
	// contains filtered or unexported fields
}

PeerStore implements Peerstore and CertifiedAddrBook.

func MakePhonebook

func MakePhonebook(connectionsRateLimitingCount uint,
	connectionsRateLimitingWindow time.Duration) (*PeerStore, error)

MakePhonebook creates a phonebook with the passed configuration values

func NewPeerStore

func NewPeerStore(addrInfo []*peer.AddrInfo, network string) (*PeerStore, error)

NewPeerStore creates a new peerstore backed by a datastore.

func (*PeerStore) AddPersistentPeers

func (ps *PeerStore) AddPersistentPeers(addrInfo []*peer.AddrInfo, networkName string, role phonebook.PhoneBookEntryRoles)

AddPersistentPeers stores addresses of peers which are persistent. i.e. they won't be replaced by ReplacePeerList calls

func (*PeerStore) GetAddresses

func (ps *PeerStore) GetAddresses(n int, role phonebook.PhoneBookEntryRoles) []*peer.AddrInfo

GetAddresses returns up to N addresses, but may return fewer

func (*PeerStore) GetConnectionWaitTime

func (ps *PeerStore) GetConnectionWaitTime(addrOrPeerID string) (bool, time.Duration, time.Time)

GetConnectionWaitTime will calculate and return the wait time to prevent exceeding connectionsRateLimitingCount. The connection should be established when the waitTime is 0. It will register a provisional next connection time when the waitTime is 0. The provisional time should be updated after the connection with UpdateConnectionTime

func (*PeerStore) Length

func (ps *PeerStore) Length() int

Length returns the number of addrs in peerstore

func (*PeerStore) ReplacePeerList

func (ps *PeerStore) ReplacePeerList(addressesThey []*peer.AddrInfo, networkName string, role phonebook.PhoneBookEntryRoles)

ReplacePeerList replaces the peer list for the given networkName and role.

func (*PeerStore) UpdateConnectionTime

func (ps *PeerStore) UpdateConnectionTime(addrOrPeerID string, provisionalTime time.Time) bool

UpdateConnectionTime updates the connection time for the given address.

func (*PeerStore) UpdateRetryAfter

func (ps *PeerStore) UpdateRetryAfter(addr string, retryAfter time.Time)

UpdateRetryAfter updates the retryAfter time for the given address.

Jump to

Keyboard shortcuts

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