polling

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0, MIT Imports: 23 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PollResult

type PollResult struct {
	Status  PollStatus
	Latency time.Duration
	Error   error

	// NewCertificates certificates we didn't yet have. Excludes certificates we received through some other
	// channel while polling.
	NewCertificates uint64
	// Total certificates received.
	ReceivedCertificates uint64
}

type PollStatus

type PollStatus int
const (
	PollMiss PollStatus = iota
	PollHit
	PollFailed
	PollIllegal
)

func (PollStatus) GoString

func (p PollStatus) GoString() string

func (PollStatus) String

func (i PollStatus) String() string

type Poller

type Poller struct {
	*certexchange.Client

	Store             *certstore.Store
	SignatureVerifier gpbft.Verifier
	PowerTable        gpbft.PowerEntries
	NextInstance      uint64
	// contains filtered or unexported fields
}

A Poller will poll specific peers on-demand to try to advance the current GPBFT instance.

func NewPoller

func NewPoller(ctx context.Context, client *certexchange.Client, store *certstore.Store, verifier gpbft.Verifier) (*Poller, error)

NewPoller constructs a new certificate poller and initializes it from the passed certificate store.

func (*Poller) CatchUp

func (p *Poller) CatchUp(ctx context.Context) (uint64, error)

CatchUp attempts to advance to the latest instance from the certificate store without making any network requests. It returns the number of instances we advanced.

func (*Poller) Poll

func (p *Poller) Poll(ctx context.Context, peer peer.ID) (*PollResult, error)

Poll polls a specific peer, possibly multiple times, in order to advance the instance as much as possible. It returns:

1. A PollResult indicating the outcome: miss, hit, failed, illegal. 2. An error if something went wrong internally (e.g., the certificate store returned an error).

type Subscriber

type Subscriber struct {
	certexchange.Client

	Store               *certstore.Store
	SignatureVerifier   gpbft.Verifier
	InitialPollInterval time.Duration
	MaximumPollInterval time.Duration
	MinimumPollInterval time.Duration
	// contains filtered or unexported fields
}

A polling Subscriber will continuously poll the network for new finality certificates.

func (*Subscriber) Start

func (s *Subscriber) Start(startCtx context.Context) error

func (*Subscriber) Stop

func (s *Subscriber) Stop(stopCtx context.Context) error

Jump to

Keyboard shortcuts

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