sm_snapshots

package
v1.0.0-rc.6 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadToFile

func DownloadToFile(
	ctx context.Context,
	filePathNetwork string,
	filePathLocal string,
	timeout time.Duration,
	addProgressReporter func(io.Reader, string, uint64) io.Reader,
) error

Use downloader to download data to file. Temporary file is created while download is in progress and only on finishing the download, the file is renamed to provided name. Progress reporter wrapped in `TeeReader` (or any other reader) can be wrapped around downloader (provided by parameter of the function). If it is not needed, `addProgressReporter` function should return the reader in the parameter.

func NewProgressReporter

func NewProgressReporter(log *logger.Logger, header string, expected uint64) io.Writer

func NewReaderWithClose

func NewReaderWithClose(r io.Reader, closeFun func() error) io.ReadCloser

Adds `Close` method to the `Reader`. This is useful, when `ReadCloser` must be wrapped in some other `Reader`, which does not provide close method. The result is that by calling `Close` to the wrapping `Reader`, the wrapped `ReadCloser` is closed.

Types

type Downloader

type Downloader interface {
	io.Reader
	io.Closer
	GetLength() uint64
}

func NewDownloader

func NewDownloader(
	ctx context.Context,
	filePath string,
	chunkSize ...uint64,
) (Downloader, error)

Downloader is a reader, which reads from network URL in chunks (if webserver supports that). Only request to read the first chunk is made on downloader creation. Requests to read other chunks are made once they are needed by `Read` calls. The user of downloader can use `Read` independently of how many chunks will have to be downloaded to complete the operation.

func NewDownloaderWithTimeout

func NewDownloaderWithTimeout(ctx context.Context,
	filePath string,
	timeout time.Duration,
	chunkSize ...uint64,
) (Downloader, error)

type MockedSnapshotManager

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

func NewMockedSnapshotManager

func NewMockedSnapshotManager(
	t *testing.T,
	createPeriod uint32,
	delayPeriod uint32,
	origStore state.Store,
	nodeStore state.Store,
	snapshotToLoad SnapshotInfo,
	snapshotCommitTime time.Duration,
	timeProvider sm_gpa_utils.TimeProvider,
	log *logger.Logger,
) *MockedSnapshotManager

func (MockedSnapshotManager) BlockCommittedAsync

func (smrT MockedSnapshotManager) BlockCommittedAsync(snapshotInfo SnapshotInfo)

func (MockedSnapshotManager) GetLoadedSnapshotStateIndex

func (smrT MockedSnapshotManager) GetLoadedSnapshotStateIndex() uint32

func (*MockedSnapshotManager) IsSnapshotReady

func (msmT *MockedSnapshotManager) IsSnapshotReady(snapshotInfo SnapshotInfo) bool

func (*MockedSnapshotManager) WaitSnapshotCreateFinalisedCount

func (msmT *MockedSnapshotManager) WaitSnapshotCreateFinalisedCount(count uint32, sleepTime time.Duration, maxSleepCount int) bool

func (*MockedSnapshotManager) WaitSnapshotCreateRequestCount

func (msmT *MockedSnapshotManager) WaitSnapshotCreateRequestCount(count uint32, sleepTime time.Duration, maxSleepCount int) bool

func (*MockedSnapshotManager) WaitSnapshotCreatedCount

func (msmT *MockedSnapshotManager) WaitSnapshotCreatedCount(count uint32, sleepTime time.Duration, maxSleepCount int) bool

type SnapshotInfo

type SnapshotInfo interface {
	StateIndex() uint32
	Commitment() *state.L1Commitment
	TrieRoot() trie.Hash
	BlockHash() state.BlockHash
	String() string
	Equals(SnapshotInfo) bool
}

func NewSnapshotInfo

func NewSnapshotInfo(index uint32, commitment *state.L1Commitment) SnapshotInfo

type SnapshotManager

type SnapshotManager interface {
	GetLoadedSnapshotStateIndex() uint32
	BlockCommittedAsync(SnapshotInfo)
}

SnapshotManager is responsible for servicing snapshot related queries in appropriate manner. Some of the requests are synchronous, but most of them are asynchronous. They can be handled in snapshot manager's thread or in another thread created by snapshot manager. Snapshot manager keeps and updates on request a list of available snapshots. However, only the information that snapshot exists is stored and not the entire snapshot. To store/load the snapshot, snapshot manager depends on `snapshotter`. Snapshot manager is also responsible for deciding if snapshot has to be created.

func NewEmptySnapshotManager

func NewEmptySnapshotManager() SnapshotManager

func NewSnapshotManager

func NewSnapshotManager(
	ctx context.Context,
	shutdownCoordinator *shutdown.Coordinator,
	chainID isc.ChainID,
	snapshotToLoad *state.BlockHash,
	createPeriod uint32,
	delayPeriod uint32,
	baseLocalPath string,
	baseNetworkPaths []string,
	store state.Store,
	metrics *metrics.ChainSnapshotsMetrics,
	log *logger.Logger,
) (SnapshotManager, error)

Jump to

Keyboard shortcuts

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