verify

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2018 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parameters

type Parameters struct {
	// NReplicas is the required number of replicas (in addition to the self peer's replica) of a
	// document to consider it fully verified.
	NReplicas uint

	// ExcludeSelf indicates whether the verify will exclude a replica hosted by the verifier.
	ExcludeSelf bool

	// NClosestResponses is the required number of peers closest to the key we need to receive
	// responses from
	NClosestResponses uint

	// NMaxErrors is the maximum number of errors tolerated when querying peers during the search
	NMaxErrors uint

	// Concurrency is the number of concurrent queries to use in search
	Concurrency uint

	// Timeout for queries to individual peers
	Timeout time.Duration
}

Parameters defines the parameters of the verify.

func NewDefaultParameters

func NewDefaultParameters() *Parameters

NewDefaultParameters returns a default Verify parameters instance.

func (*Parameters) MarshalLogObject

func (p *Parameters) MarshalLogObject(oe zapcore.ObjectEncoder) error

MarshalLogObject converts the Parameters into an object (which will become json) for logging.

type ResponseProcessor

type ResponseProcessor interface {
	// Process handles an api.VerifyResponse, adding newly discovered peers to the unqueried
	// ClosestPeers heap and adding from to the list of replicas when its MAC matches the expected
	// value.
	Process(response *api.VerifyResponse, from peer.Peer, expectedMAC []byte, verify *Verify) error
}

ResponseProcessor handles api.VerifyResponses.

func NewResponseProcessor

func NewResponseProcessor(fromer peer.Fromer, doc comm.Doctor) ResponseProcessor

NewResponseProcessor creates a new ResponseProcessor.

type Result

type Result struct {
	// Replicas gives the peers with verified replicas.
	Replicas map[string]peer.Peer

	// Closest is a heap of the responding peers without a replica found closest to the key
	Closest search.FarthestPeers

	// Unqueried is a heap of peers that were not yet queried
	Unqueried search.ClosestPeers

	// Queried is a set of all peers (keyed by peer.ID().String()) that have been queried (but
	// haven't yet necessarily responded or errored)
	Queried map[string]struct{}

	// Responded is a map of all peers that responded during verification
	Responded map[string]peer.Peer

	// Errored contains the errors received by each peer (via string representation of peer ID)
	Errored map[string]error

	// FatalErr is a fatal error that occurred during the search
	FatalErr error
}

Result holds verify's (intermediate) result during and after execution.

func NewInitialResult

func NewInitialResult(key id.ID, params *Parameters) *Result

NewInitialResult creates a new Result object for the beginning of a search.

func (*Result) MarshalLogObject

func (r *Result) MarshalLogObject(oe zapcore.ObjectEncoder) error

MarshalLogObject converts the Result into an object (which will become json) for logging.

type Verifier

type Verifier interface {
	// Verify executes the verification.
	Verify(verify *Verify, seeds []peer.Peer) error
}

Verifier executes verifications for particular keys.

func NewDefaultVerifier

func NewDefaultVerifier(
	peerSigner client.Signer,
	orgSigner client.Signer,
	rec comm.QueryRecorder,
	doc comm.Doctor,
	clients client.Pool,
) Verifier

NewDefaultVerifier creates a new Verifier with default sub-object instantiations.

func NewVerifier

func NewVerifier(
	peerSigner client.Signer,
	orgSigner client.Signer,
	rec comm.QueryRecorder,
	doc comm.Doctor,
	c client.VerifierCreator,
	rp ResponseProcessor,
) Verifier

NewVerifier returns a new Verifier with the given Querier and ResponseProcessor.

type Verify

type Verify struct {
	// Key of document to verify
	Key id.ID

	Value []byte

	ExpectedMAC []byte

	// CreateRq creates new Verify requests
	CreateRq func() *api.VerifyRequest

	// Result contains the verification result
	Result *Result

	// Params of the verification
	Params *Parameters
	// contains filtered or unexported fields
}

Verify contains things involved in a verification of a document.

func NewVerify

func NewVerify(
	selfID, orgID ecid.ID, key id.ID, value, macKey []byte, params *Parameters,
) *Verify

NewVerify creates a new Verify instance for the given key with the given macKey, expected mac value, and params.

func (*Verify) AddQueried added in v0.2.0

func (v *Verify) AddQueried(p peer.Peer)

AddQueried adds a peer to the queried set.

func (*Verify) Errored

func (v *Verify) Errored() bool

Errored returns whether the verify has encountered too many errors when querying the peers.

func (*Verify) Exhausted

func (v *Verify) Exhausted() bool

Exhausted returns whether the verify has exhausted all unqueried peers close to the key.

func (*Verify) Finished

func (v *Verify) Finished() bool

Finished returns whether the search has finished, either because it has found the target or closest peers or errored or exhausted the list of peers to query. This operation is concurrency safe.

func (*Verify) FullyReplicated

func (v *Verify) FullyReplicated() bool

FullyReplicated returns whether sufficient replicas were found.

func (*Verify) MarshalLogObject

func (v *Verify) MarshalLogObject(oe zapcore.ObjectEncoder) error

MarshalLogObject converts the Search into an object (which will become json) for logging.

func (*Verify) UnderReplicated

func (v *Verify) UnderReplicated() bool

UnderReplicated returns whether some (or no) replicas but all the closest peers were found.

Jump to

Keyboard shortcuts

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