collector

package
v0.0.0-...-0dcfdb9 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// GreenAssessment is the overall assessment when everything checks out
	GreenAssessment = "ok"
	// YellowAssessment is the overall assessment for a warning
	YellowAssessment = "warning"
	// RedAssessment is the overall assessment when Steady detects something bad
	RedAssessment = "evil"
)

Variables

This section is empty.

Functions

func WriteCollectorConfig

func WriteCollectorConfig(c *Config, filename string) error

Types

type Assessment

type Assessment struct {
	// ID is the identifier of the assessment, linked to by all events.
	ID uint64
	// Overall is the overall assessment, see constants above.
	Overall string
	// Finding is one or more findings.
	Finding []Finding

	// Relay is the URL of the queried relay.
	Relay string
	// Time is the local time when performing the query.
	Time uint64
	// RequestIndex is the requested starting index in the query.
	RequestIndex uint64

	// TotalBlocks is the total number of blocks returned by the relay, where
	// TotalBlocks = ValidBlocks + InvalidBlocks + DuplicateBlocks.
	TotalBlocks uint64
	// ValidBlocks is the number of blocks with a valid signature and index.
	ValidBlocks uint64
	// InvalidBlocks is the number of blocks with an invalid signature and/or index.
	InvalidBlocks uint64
	// DuplicateBlocks is the number of duplicate (by index) blocks.
	DuplicateBlocks uint64

	// MissedBlocks is the number of missed blocks (see Description for details).
	MissedBlocks uint64

	// Blockheads is a map index->blockhead with the signed root of each block and
	// associated data needed to verify the signature on the root. Use together with
	// the path of each event from a valid block as a publicly verifiable proof of
	// event origin.
	Blockheads map[uint64]BlockHead
}

Assessment is the assessment made by Steady for each run of the collector loop.

type Block

type Block struct {
	BlockHeader steady.BlockHeader
	Payload     []byte
}

type BlockHead

type BlockHead struct {
	PayloadHash, RootHash, Root, IV, Signature []byte
	BlockID, Time, TreeSize                    uint64
}

BlockHead is the minimal representation of a block for use with proofs.

type Collector

type Collector struct {
	Config Config
	State  State
	// contains filtered or unexported fields
}

Collector is a Steady collector.

func NewCollector

func NewCollector(address string,
	config Config,
	frequency time.Duration,
	delta uint64) (*Collector, error)

NewCollector attempts to create a new collector connected to a relay.

func (*Collector) Close

func (c *Collector) Close()

Close closes the underlying connection to the relay.

func (*Collector) CollectLoop

func (c *Collector) CollectLoop(state State, close chan struct{}, out Output)

CollectLoop is the main collect loop of the collector

type Config

type Config struct {
	Pub, Priv, Vk []byte
	Policy        steady.Policy
}

func ReadCollectorConfig

func ReadCollectorConfig(filename string) (*Config, error)

type Finding

type Finding struct {
	Label, Description string
}

Finding describes a finding as part of an assessment. The description is a freetext description (see formatstrings above) while the label is one of three possible assessments.

type Output

type Output func(label string, meta interface{}, format string, args ...interface{})

Output is the output function for the collector. Possible labels: evil, warning, unverified, and verified. Evil = network/relay bad, warning unclear who is doing what and potentially evil, unverified is data we got but cannot verify, and verified is verified data.

type Proof

type Proof struct {
	AssessmentID uint64
	EventIndex   int
	Path         [][]byte
}

Proof is an audit path that proves membership to a root in a block, and the head of the block is part of the assessment.

type State

type State struct {
	Time, Index uint64
}

State is the state kept by the collector.

type Unverified

type Unverified struct {
	AssessmentID uint64
	Description  string
}

Unverified is the meta output description for unverifiable blocks and events.

Jump to

Keyboard shortcuts

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