certs

package
v0.0.0-...-7eaa6d1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCertNotFound = errors.New("certificate not found")

Functions

This section is empty.

Types

type Cert

type Cert struct {
	Instance uint64
}

func (Cert) MarshalBinary

func (c Cert) MarshalBinary() ([]byte, error)

func (*Cert) UnmarshalBinary

func (c *Cert) UnmarshalBinary(b []byte) error

type Store

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

Store is responsible for storing and relaying information about new finality certificates

func NewStore

func NewStore(ctx context.Context, ds datastore.Datastore) (*Store, error)

NewStore creates a certstore The passed Datastore has to be thread safe.

func (*Store) Get

func (cs *Store) Get(ctx context.Context, instance uint64) (*Cert, error)

func (*Store) GetRange

func (cs *Store) GetRange(ctx context.Context, start uint64, end uint64) ([]Cert, error)

GetRange returns a range of certs from start to end inclusive by instance numbers in the increasing order. Only this order of traversal is supported. If it encounters missing cert, it returns a wrapped ErrCertNotFound and the available certs

func (*Store) Latest

func (cs *Store) Latest() *Cert

Latest returns the newest available certificate

func (*Store) Put

func (cs *Store) Put(ctx context.Context, cert *Cert) error

Put saves a certificate in a store and notifies listeners. It errors if adding a cert would create a gap

func (*Store) SubscribeForNewCerts

func (cs *Store) SubscribeForNewCerts(ch chan<- *Cert) (last *Cert, closer func())

SubscribeForNewCerts is used to subscribe to the broadcast channel. If the passed channel is full at any point, it will be dropped from subscription and closed. To stop subscribing, either the closer function can be used or the channel can be abandoned. Passing a channel multiple times to the Subscribe function will result in a panic. The channel will receive new certificates sequentially.

Jump to

Keyboard shortcuts

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