internal

package
v0.38.0-preview.0.0.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDisallowCacheEntityNotFound = errors.New("disallow list cache entity not found")
)

Functions

This section is empty.

Types

type DisallowListCache

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

DisallowListCache is the disallow-list cache. It is used to keep track of the disallow-listed peers and the reasons for it.

func NewDisallowListCache

func NewDisallowListCache(sizeLimit uint32, logger zerolog.Logger, collector module.HeroCacheMetrics) *DisallowListCache

NewDisallowListCache creates a new disallow-list cache. The cache is backed by a stdmap.Backend. Args: - sizeLimit: the size limit of the cache, i.e., the maximum number of records that the cache can hold, recommended size is 100 * number of authorized nodes. - logger: the logger used by the cache. - collector: the metrics collector used by the cache. Returns: - *DisallowListCache: the created cache.

func (*DisallowListCache) AllowFor

AllowFor removes a cause from the disallow list cache entity for the peerID. Args: - peerID: the peerID of the peer to be allow-listed. - cause: the cause for allow-listing the peer. Returns: - the list of causes for which the peer is disallow-listed. - error if the entity for the peerID is not found in the cache it returns ErrDisallowCacheEntityNotFound, which is a benign error.

func (*DisallowListCache) DisallowFor

DisallowFor disallow-lists a peer for a cause. Args: - peerID: the peerID of the peer to be disallow-listed. - cause: the cause for disallow-listing the peer. Returns: - []network.DisallowListedCause: the list of causes for which the peer is disallow-listed. - error: if the operation fails, error is irrecoverable.

func (*DisallowListCache) IsDisallowListed

func (d *DisallowListCache) IsDisallowListed(peerID peer.ID) ([]network.DisallowListedCause, bool)

IsDisallowListed determines whether the given peer is disallow-listed for any reason. Args: - peerID: the peer to check. Returns: - []network.DisallowListedCause: the list of causes for which the given peer is disallow-listed. If the peer is not disallow-listed for any reason, a nil slice is returned. - bool: true if the peer is disallow-listed for any reason, false otherwise.

type ProtocolPeerCache

type ProtocolPeerCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ProtocolPeerCache store a mapping from protocol ID to peers who support that protocol

func NewProtocolPeerCache

func NewProtocolPeerCache(logger zerolog.Logger, h host.Host) (*ProtocolPeerCache, error)

func (*ProtocolPeerCache) AddProtocols

func (p *ProtocolPeerCache) AddProtocols(peerID peer.ID, protocols []protocol.ID)

func (*ProtocolPeerCache) GetPeers

func (p *ProtocolPeerCache) GetPeers(pid protocol.ID) map[peer.ID]struct{}

func (*ProtocolPeerCache) RemovePeer

func (p *ProtocolPeerCache) RemovePeer(peerID peer.ID)

func (*ProtocolPeerCache) RemoveProtocols

func (p *ProtocolPeerCache) RemoveProtocols(peerID peer.ID, protocols []protocol.ID)

Jump to

Keyboard shortcuts

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