catchup

package
v0.0.0-...-ff2c966 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: AGPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSyncRoundInvalid = errors.New("requested sync round cannot be less than the latest round")

ErrSyncRoundInvalid is returned when the sync round requested is behind the current ledger round

Functions

This section is empty.

Types

type BlockAuthenticator

type BlockAuthenticator interface {
	Authenticate(*bookkeeping.Block, *agreement.Certificate) error
	Quit()
}

A BlockAuthenticator authenticates blocks given a certificate.

Note that Authenticate does not check if the block contents match their header as it only checks the block header. If the contents have not been checked yet, callers should also call block.ContentsMatchHeader and reject blocks that do not pass this check.

type CatchpointCatchupNodeServices

type CatchpointCatchupNodeServices interface {
	SetCatchpointCatchupMode(bool) (newContextCh <-chan context.Context)
}

CatchpointCatchupNodeServices defines the external node support needed for the catchpoint service to switch the node between "regular" operational mode and catchup mode.

type CatchpointCatchupService

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

CatchpointCatchupService represents the catchpoint catchup service.

func MakeNewCatchpointCatchupService

func MakeNewCatchpointCatchupService(catchpoint string, node CatchpointCatchupNodeServices, log logging.Logger, net network.GossipNode, accessor ledger.CatchpointCatchupAccessor, cfg config.Local) (service *CatchpointCatchupService, err error)

MakeNewCatchpointCatchupService creates a new catchpoint catchup service for a node that is not in catchpoint catchup mode

func MakeResumedCatchpointCatchupService

func MakeResumedCatchpointCatchupService(ctx context.Context, node CatchpointCatchupNodeServices, log logging.Logger, net network.GossipNode, accessor ledger.CatchpointCatchupAccessor, cfg config.Local) (service *CatchpointCatchupService, err error)

MakeResumedCatchpointCatchupService creates a catchpoint catchup service for a node that is already in catchpoint catchup mode

func (*CatchpointCatchupService) Abort

func (cs *CatchpointCatchupService) Abort()

Abort aborts the catchpoint catchup process

func (*CatchpointCatchupService) GetLatestBlockHeader

func (cs *CatchpointCatchupService) GetLatestBlockHeader() bookkeeping.BlockHeader

GetLatestBlockHeader returns the last block header that was available at the time the catchpoint catchup service started

func (*CatchpointCatchupService) GetStatistics

func (cs *CatchpointCatchupService) GetStatistics() (out CatchpointCatchupStats)

GetStatistics returns a copy of the current catchpoint catchup statistics

func (*CatchpointCatchupService) Start

Start starts the catchpoint catchup service ( continue in the process )

func (*CatchpointCatchupService) Stop

func (cs *CatchpointCatchupService) Stop()

Stop stops the catchpoint catchup service - unlike Abort, this is not intended to abort the process but rather to allow cleanup of in-memory resources for the purpose of clean shutdown.

type CatchpointCatchupStats

type CatchpointCatchupStats struct {
	CatchpointLabel    string
	TotalAccounts      uint64
	ProcessedAccounts  uint64
	VerifiedAccounts   uint64
	TotalKVs           uint64
	ProcessedKVs       uint64
	VerifiedKVs        uint64
	TotalBlocks        uint64
	AcquiredBlocks     uint64
	VerifiedBlocks     uint64
	ProcessedBytes     uint64
	TotalAccountHashes uint64
	TotalKVHashes      uint64
	StartTime          time.Time
}

CatchpointCatchupStats is used for querying and reporting the current state of the catchpoint catchup process

type HTTPFetcher

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

HTTPFetcher implements FetcherClient doing an HTTP GET of the block

type Ledger

type Ledger interface {
	agreement.LedgerReader
	AddBlock(bookkeeping.Block, agreement.Certificate) error
	EnsureBlock(block *bookkeeping.Block, c agreement.Certificate)
	LastRound() basics.Round
	Block(basics.Round) (bookkeeping.Block, error)
	BlockHdr(basics.Round) (bookkeeping.BlockHeader, error)
	IsWritingCatchpointDataFile() bool
	IsBehindCommittingDeltas() bool
	Validate(ctx context.Context, blk bookkeeping.Block, executionPool execpool.BacklogPool) (*ledgercore.ValidatedBlock, error)
	AddValidatedBlock(vb ledgercore.ValidatedBlock, cert agreement.Certificate) error
	WaitMem(r basics.Round) chan struct{}
}

Ledger represents the interface of a block database which the catchup server should interact with.

type PendingUnmatchedCertificate

type PendingUnmatchedCertificate struct {
	Cert         agreement.Certificate
	VoteVerifier *agreement.AsyncVoteVerifier
}

PendingUnmatchedCertificate is a single certificate that is being waited upon to have its corresponding block fetched.

type Service

type Service struct {

	// The channel gets closed when the initial sync is complete. This allows for other services to avoid
	// the overhead of starting prematurely (before this node is caught-up and can validate messages for example).
	InitialSyncDone chan struct{}
	// contains filtered or unexported fields
}

Service represents the catchup service. Once started and until it is stopped, it ensures that the ledger is up-to-date with network.

func MakeService

func MakeService(log logging.Logger, config config.Local, net network.GossipNode, ledger Ledger, auth BlockAuthenticator, unmatchedPendingCertificates <-chan PendingUnmatchedCertificate, blockValidationPool execpool.BacklogPool) (s *Service)

MakeService creates a catchup service instance from its constituent components

func (*Service) GetDisableSyncRound

func (s *Service) GetDisableSyncRound() uint64

GetDisableSyncRound returns the disabled sync round

func (*Service) IsSynchronizing

func (s *Service) IsSynchronizing() (synchronizing bool, initialSync bool)

IsSynchronizing returns true if we're currently executing a sync() call - either initial catchup or attempting to catchup after too-long waiting for next block. Also returns a 2nd bool indicating if this is our initial sync

func (*Service) SetDisableSyncRound

func (s *Service) SetDisableSyncRound(rnd uint64) error

SetDisableSyncRound attempts to set the first round we _do_not_ want to fetch from the network Blocks from disableSyncRound or any round after disableSyncRound will not be fetched while this is set

func (*Service) Start

func (s *Service) Start()

Start the catchup service

func (*Service) Stop

func (s *Service) Stop()

Stop informs the catchup service that it should stop, and waits for it to stop (when periodicSync() exits)

func (*Service) SynchronizingTime

func (s *Service) SynchronizingTime() time.Duration

SynchronizingTime returns the time we've been performing a catchup operation (0 if not currently catching up)

func (*Service) UnsetDisableSyncRound

func (s *Service) UnsetDisableSyncRound()

UnsetDisableSyncRound removes any previously set disabled sync round

Jump to

Keyboard shortcuts

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