seghandler

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrVerification = serrors.New("all segments failed to verify")
	ErrDB           = serrors.New("database error")
)

Errors

Functions

This section is empty.

Types

type DefaultStorage

type DefaultStorage struct {
	PathDB   pathdb.PathDB
	RevCache revcache.RevCache
}

DefaultStorage wraps path DB and revocation cache and offers convenience methods that implement the Storage interface.

func (*DefaultStorage) StoreRevs

func (s *DefaultStorage) StoreRevs(ctx context.Context,
	revs []*path_mgmt.SignedRevInfo) error

StoreRevs stores the given revocations in the revocation cache.

func (*DefaultStorage) StoreSegs

func (s *DefaultStorage) StoreSegs(ctx context.Context, segs []*SegWithHP) (SegStats, error)

StoreSegs stores the given segments in the pathdb in a transaction.

type DefaultVerifier

type DefaultVerifier struct {
	Verifier infra.Verifier
}

DefaultVerifier is a convenience wrapper around segverifier that implements the Verifier interface.

func (*DefaultVerifier) Verify

func (v *DefaultVerifier) Verify(ctx context.Context, recs Segments,
	server net.Addr) (chan segverifier.UnitResult, int)

Verify calls segverifier for the given reply.

type Handler

type Handler struct {
	Verifier Verifier
	Storage  Storage
}

Handler is a handler that verifies and stores seg replies. The handler supports an early trigger, so that a partial result can be stored early to possibly reply to clients earlier.

func (*Handler) Handle

func (h *Handler) Handle(ctx context.Context, recs Segments, server net.Addr,
	earlyTrigger <-chan struct{}) *ProcessedResult

Handle verifies and stores a set of segments.

type ProcessedResult

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

ProcessedResult is the result of handling a segment reply.

func (*ProcessedResult) EarlyTriggerProcessed

func (r *ProcessedResult) EarlyTriggerProcessed() <-chan int

EarlyTriggerProcessed returns a channel that will contain the number of successfully stored segments once it is done processing the early trigger.

func (*ProcessedResult) Err

func (r *ProcessedResult) Err() error

Err indicates the error that happened when storing the segments. This should only be accessed after FullReplyProcessed channel has been closed.

func (*ProcessedResult) FullReplyProcessed

func (r *ProcessedResult) FullReplyProcessed() <-chan struct{}

FullReplyProcessed returns a channel that will be closed once the full reply has been processed.

func (*ProcessedResult) Stats

func (r *ProcessedResult) Stats() Stats

Stats provides insights about storage and verification of segments.

func (*ProcessedResult) VerificationErrors

func (r *ProcessedResult) VerificationErrors() serrors.List

VerificationErrors returns the list of verification errors that happened.

type SegStats

type SegStats struct {
	// InsertedSegs are the log IDs of the inserted segments.
	InsertedSegs []string
	// UpdatedSegs are the log IDs of the updated segments.
	UpdatedSegs []string
}

SegStats provides statistics about segment insertion/updates.

func (*SegStats) Log

func (s *SegStats) Log(logger log.Logger)

Log logs the statistics with the given logger.

func (SegStats) Total

func (s SegStats) Total() int

Total returns the total amount of updates and inserts.

type SegWithHP

type SegWithHP struct {
	Seg     *seg.Meta
	HPGroup hiddenpath.GroupId
}

SegWithHP is a segment with hidden path cfg ids.

func (*SegWithHP) String

func (s *SegWithHP) String() string

type Segments

type Segments struct {
	Segs      []*seg.Meta
	SRevInfos []*path_mgmt.SignedRevInfo
	HPGroupID hiddenpath.GroupId
}

Segments is a list of segments and revocations belonging to them. Optionally a hidden path group ID is attached.

type Stats

type Stats struct {

	// VerifiedSegs contains all segments that were successfully verified.
	VerifiedSegs []*SegWithHP
	// StoredRevs contains all revocations that were verified and stored.
	StoredRevs []*path_mgmt.SignedRevInfo
	// VerifiedRevs contains all revocations that were verified.
	VerifiedRevs []*path_mgmt.SignedRevInfo
	// contains filtered or unexported fields
}

Stats provides statistics about handling segments.

func (Stats) RevDBErrs

func (s Stats) RevDBErrs() int

RevDBErrs returns the amount of db errors for storing revocations.

func (Stats) RevStored

func (s Stats) RevStored() int

RevStored returns the amount of stored revocations.

func (Stats) RevVerifyErrors

func (s Stats) RevVerifyErrors() int

RevVerifyErrors returns the amount of verification errors for revocations.

func (Stats) SegVerifyErrors

func (s Stats) SegVerifyErrors() int

SegVerifyErrors returns the amount of segment verification errors.

func (Stats) SegsInserted

func (s Stats) SegsInserted() int

SegsInserted returns the amount of inserted segments.

func (Stats) SegsUpdated

func (s Stats) SegsUpdated() int

SegsUpdated returns the amount of updated segments.

type Storage

type Storage interface {
	StoreSegs(context.Context, []*SegWithHP) (SegStats, error)
	StoreRevs(context.Context, []*path_mgmt.SignedRevInfo) error
}

Storage is used to store segments and revocations.

type Verifier

type Verifier interface {
	Verify(context.Context, Segments, net.Addr) (chan segverifier.UnitResult, int)
}

Verifier is used to verify a segment reply.

Directories

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

Jump to

Keyboard shortcuts

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