revcache

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterNew

func FilterNew(ctx context.Context, revCache RevCache,
	revocations []*path_mgmt.RevInfo) ([]*path_mgmt.RevInfo, error)

FilterNew filters the given revocations against the revCache, only the ones which are not in the cache are returned. This is a convenience wrapper around the Revocations type and its filter new method.

func NewCleaner

func NewCleaner(rc RevCache, s string) *cleaner.Cleaner

NewCleaner creates a cleaner task that deletes expired revocations.

func NoRevokedHopIntf

func NoRevokedHopIntf(ctx context.Context, revCache RevCache,
	s *seg.PathSegment) (bool, error)

NoRevokedHopIntf returns true if there is no on-segment revocation.

func RelevantRevInfos

func RelevantRevInfos(ctx context.Context, revCache RevCache,
	allSegs ...[]*seg.PathSegment) ([]*path_mgmt.RevInfo, error)

RelevantRevInfos finds all revocations for the given segments.

Types

type Key

type Key struct {
	IA   addr.IA
	IfId common.IFIDType
}

Key denotes the key for the revocation cache.

func NewKey

func NewKey(ia addr.IA, ifId common.IFIDType) *Key

NewKey creates a new key for the revocation cache.

func (Key) String

func (k Key) String() string

type KeySet

type KeySet map[Key]struct{}

KeySet is a set of keys.

func SingleKey

func SingleKey(ia addr.IA, ifId common.IFIDType) KeySet

SingleKey is a convenience function to return a KeySet with a single key.

type ResultChan

type ResultChan <-chan RevOrErr

ResultChan is a channel of results.

type RevCache

type RevCache interface {
	// Get items with the given keys from the cache. Returns all present requested items that are
	// not expired or an error if the query failed.
	Get(ctx context.Context, keys KeySet) (Revocations, error)
	// GetAll returns a channel that will provide all items in the revocation cache. If the cache
	// can't prepare the result channel a nil channel and the error are returned. If the querying
	// succeeded the channel will contain the revocations in the cache, or an error if the stored
	// data could not be parsed. Note that implementations can spawn a goroutine to fill the
	// channel, which means the channel must be fully drained to guarantee the destruction of the
	// goroutine.
	GetAll(ctx context.Context) (ResultChan, error)
	// Insert inserts or updates the given revocation into the cache.
	// Returns whether an insert was performed.
	Insert(ctx context.Context, rev *path_mgmt.RevInfo) (bool, error)
	// DeleteExpired deletes expired entries from the cache.
	// Users of the revcache should make sure to periodically call this method to prevent an
	// ever growing cache.
	// Returns the amount of deleted entries.
	DeleteExpired(ctx context.Context) (int64, error)
	db.LimitSetter
	io.Closer
}

RevCache is a cache for revocations. Revcache implementations must be safe for concurrent usage.

type RevOrErr

type RevOrErr struct {
	Rev *path_mgmt.RevInfo
	Err error
}

RevOrErr is either a revocation or an error.

type Revocations

type Revocations map[Key]*path_mgmt.RevInfo

Revocations is the map of revocations.

func RevocationToMap

func RevocationToMap(revs []*path_mgmt.RevInfo) (Revocations, error)

RevocationToMap converts a slice of revocations to a revocation map. If extracting the info field fails from a revocation, nil and the error is returned.

func (Revocations) FilterNew

func (r Revocations) FilterNew(ctx context.Context, revCache RevCache) error

FilterNew drops all revocations in r that are already in the revCache.

func (Revocations) Keys

func (r Revocations) Keys() KeySet

Keys returns the set of keys in this revocation map.

func (Revocations) ToSlice

func (r Revocations) ToSlice() []*path_mgmt.RevInfo

ToSlice extracts the values from this revocation map.

Directories

Path Synopsis
Package mock_revcache is a generated GoMock package.
Package mock_revcache is a generated GoMock package.

Jump to

Keyboard shortcuts

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