Documentation
¶
Index ¶
- func PeerInfoFromAddr(addr string) (*peer.AddrInfo, error)
- func PeerInfoFromAddrs(addrs []string) ([]*peer.AddrInfo, map[string]string)
- type PeerStore
- func (ps *PeerStore) AddPersistentPeers(addrInfo []*peer.AddrInfo, networkName string, role phonebook.Role)
- func (ps *PeerStore) GetAddresses(n int, role phonebook.Role) []*peer.AddrInfo
- func (ps *PeerStore) GetConnectionWaitTime(addrOrPeerID string) (bool, time.Duration, time.Time)
- func (ps *PeerStore) HasRole(peerID peer.ID, role phonebook.Role) bool
- func (ps *PeerStore) Length() int
- func (ps *PeerStore) ReplacePeerList(addressesThey []*peer.AddrInfo, networkName string, role phonebook.Role)
- func (ps *PeerStore) UpdateConnectionTime(addrOrPeerID string, provisionalTime time.Time) bool
- func (ps *PeerStore) UpdateRetryAfter(addr string, retryAfter time.Time)
- type RoleChecker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PeerInfoFromAddr ¶
PeerInfoFromAddr extracts the AddrInfo from a multiaddr string.
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 ¶
NewPeerStore creates a new peerstore backed by a datastore.
func (*PeerStore) AddPersistentPeers ¶
func (ps *PeerStore) AddPersistentPeers(addrInfo []*peer.AddrInfo, networkName string, role phonebook.Role)
AddPersistentPeers stores addresses of peers which are persistent. i.e. they won't be replaced by ReplacePeerList calls. If a peer is already in the peerstore, its role will be updated.
func (*PeerStore) GetAddresses ¶
GetAddresses returns up to N addresses, but may return fewer
func (*PeerStore) GetConnectionWaitTime ¶
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) ReplacePeerList ¶
func (ps *PeerStore) ReplacePeerList(addressesThey []*peer.AddrInfo, networkName string, role phonebook.Role)
ReplacePeerList replaces the peer list for the given networkName and role. new entries in addressesThey are being added existing items that aren't included in addressesThey are being removed matching entries roles gets updated as needed and persistent peers are not touched
func (*PeerStore) UpdateConnectionTime ¶
UpdateConnectionTime updates the connection time for the given address.