Documentation ¶
Index ¶
- Variables
- type DisallowListCache
- func (d *DisallowListCache) AllowFor(peerID peer.ID, cause network.DisallowListedCause) []network.DisallowListedCause
- func (d *DisallowListCache) DisallowFor(peerID peer.ID, cause network.DisallowListedCause) ([]network.DisallowListedCause, error)
- func (d *DisallowListCache) IsDisallowListed(peerID peer.ID) ([]network.DisallowListedCause, bool)
- type ProtocolPeerCache
Constants ¶
This section is empty.
Variables ¶
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 ¶
func (d *DisallowListCache) AllowFor(peerID peer.ID, cause network.DisallowListedCause) []network.DisallowListedCause
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 ¶
func (d *DisallowListCache) DisallowFor(peerID peer.ID, cause network.DisallowListedCause) ([]network.DisallowListedCause, error)
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 ¶
ProtocolPeerCache store a mapping from protocol ID to peers who support that protocol
func NewProtocolPeerCache ¶
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)