state

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StateManager

type StateManager interface {
	// ToCosignTreeHead returns the node's to-cosign tree head
	ToCosignTreeHead() *types.SignedTreeHead

	// CosignedTreeHead returns the node's cosigned tree head
	CosignedTreeHead(context.Context) (*types.CosignedTreeHead, error)

	// AddCosignature verifies that a cosignature is valid for the to-cosign
	// tree head before adding it
	AddCosignature(context.Context, *types.PublicKey, *types.Signature) error

	// Run peridically rotates the node's to-cosign and cosigned tree heads
	Run(context.Context)
}

StateManager coordinates access to a nodes tree heads and (co)signatures.

type StateManagerSingle

type StateManagerSingle struct {

	// Lock-protected access to pointers.  A write lock is only obtained once
	// per interval when doing pointer rotation.  All endpoints are readers.
	sync.RWMutex
	// contains filtered or unexported fields
}

StateManagerSingle implements a single-instance StateManagerPrimary for primary nodes

func NewStateManagerSingle

func NewStateManagerSingle(dbcli db.Client, signer crypto.Signer, interval, deadline time.Duration, secondary client.Client, sthFile *os.File) (*StateManagerSingle, error)

NewStateManagerSingle() sets up a new state manager, in particular its signedTreeHead. An optional secondary node can be used to ensure that a newer primary tree is not signed unless it has been replicated.

func (*StateManagerSingle) AddCosignature

func (sm *StateManagerSingle) AddCosignature(ctx context.Context, pub *types.PublicKey, sig *types.Signature) error

func (*StateManagerSingle) CosignedTreeHead

func (sm *StateManagerSingle) CosignedTreeHead(_ context.Context) (*types.CosignedTreeHead, error)

func (*StateManagerSingle) Run

func (sm *StateManagerSingle) Run(ctx context.Context)

func (*StateManagerSingle) ToCosignTreeHead

func (sm *StateManagerSingle) ToCosignTreeHead() *types.SignedTreeHead

Jump to

Keyboard shortcuts

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