Documentation ¶
Index ¶
- func DownloadToFile(ctx context.Context, filePathNetwork string, filePathLocal string, ...) (string, error)
- func NewProgressReporter(log *logger.Logger, header string, expected uint64) io.Writer
- func NewReaderWithClose(r io.Reader, closeFun func() error) io.ReadCloser
- type Downloader
- type MockedSnapshotManager
- func (smrT MockedSnapshotManager) BlockCommittedAsync(snapshotInfo SnapshotInfo)
- func (msmT *MockedSnapshotManager) IsSnapshotReady(snapshotInfo SnapshotInfo) bool
- func (smrT MockedSnapshotManager) LoadSnapshotAsync(snapshotInfo SnapshotInfo) <-chan error
- func (msmT *MockedSnapshotManager) SetAfterSnapshotCreated(fun func(SnapshotInfo))
- func (msmT *MockedSnapshotManager) SnapshotExists(stateIndex uint32, commitment *state.L1Commitment) bool
- func (msmT *MockedSnapshotManager) SnapshotReady(snapshotInfo SnapshotInfo)
- func (smrT MockedSnapshotManager) UpdateAsync()
- func (msmT *MockedSnapshotManager) WaitNodeUpdateCount(count uint32, sleepTime time.Duration, maxSleepCount int) bool
- func (msmT *MockedSnapshotManager) WaitSnapshotCreateFinalisedCount(count uint32, sleepTime time.Duration, maxSleepCount int) bool
- func (msmT *MockedSnapshotManager) WaitSnapshotCreateRequestCount(count uint32, sleepTime time.Duration, maxSleepCount int) bool
- func (msmT *MockedSnapshotManager) WaitSnapshotCreatedCount(count uint32, sleepTime time.Duration, maxSleepCount int) bool
- func (msmT *MockedSnapshotManager) WaitSnapshotLoadRequestCount(count uint32, sleepTime time.Duration, maxSleepCount int) bool
- func (msmT *MockedSnapshotManager) WaitSnapshotLoadedCount(count uint32, sleepTime time.Duration, maxSleepCount int) bool
- type SnapshotInfo
- type SnapshotManager
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, ) (string, 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 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 ¶
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.
type MockedSnapshotManager ¶
type MockedSnapshotManager struct {
// contains filtered or unexported fields
}
func (MockedSnapshotManager) BlockCommittedAsync ¶
func (smrT MockedSnapshotManager) BlockCommittedAsync(snapshotInfo SnapshotInfo)
func (*MockedSnapshotManager) IsSnapshotReady ¶
func (msmT *MockedSnapshotManager) IsSnapshotReady(snapshotInfo SnapshotInfo) bool
func (MockedSnapshotManager) LoadSnapshotAsync ¶
func (smrT MockedSnapshotManager) LoadSnapshotAsync(snapshotInfo SnapshotInfo) <-chan error
func (*MockedSnapshotManager) SetAfterSnapshotCreated ¶
func (msmT *MockedSnapshotManager) SetAfterSnapshotCreated(fun func(SnapshotInfo))
func (*MockedSnapshotManager) SnapshotExists ¶
func (msmT *MockedSnapshotManager) SnapshotExists(stateIndex uint32, commitment *state.L1Commitment) bool
func (*MockedSnapshotManager) SnapshotReady ¶
func (msmT *MockedSnapshotManager) SnapshotReady(snapshotInfo SnapshotInfo)
func (MockedSnapshotManager) UpdateAsync ¶
func (smrT MockedSnapshotManager) UpdateAsync()
func (*MockedSnapshotManager) WaitNodeUpdateCount ¶
func (*MockedSnapshotManager) WaitSnapshotCreateFinalisedCount ¶
func (*MockedSnapshotManager) WaitSnapshotCreateRequestCount ¶
func (*MockedSnapshotManager) WaitSnapshotCreatedCount ¶
func (*MockedSnapshotManager) WaitSnapshotLoadRequestCount ¶
func (*MockedSnapshotManager) WaitSnapshotLoadedCount ¶
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 { UpdateAsync() BlockCommittedAsync(SnapshotInfo) SnapshotExists(uint32, *state.L1Commitment) bool LoadSnapshotAsync(SnapshotInfo) <-chan error }
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