Documentation ¶
Index ¶
- Variables
- func DrainChunks(chunks <-chan io.ReadCloser)
- func IsFormatSupported(snapshotter types.ExtensionSnapshotter, format uint32) bool
- func ValidRestoreHeight(format uint32, height uint64) error
- type ChunkReader
- type ChunkWriter
- type Manager
- func (m *Manager) Create(height uint64) (*types.Snapshot, error)
- func (m *Manager) GetInterval() uint64
- func (m *Manager) GetKeepRecent() uint32
- func (m *Manager) GetSnapshotBlockRetentionHeights() int64
- func (m *Manager) List() ([]*types.Snapshot, error)
- func (m *Manager) LoadChunk(height uint64, format uint32, chunk uint32) ([]byte, error)
- func (m *Manager) Prune(retain uint32) (uint64, error)
- func (m *Manager) RegisterExtensions(extensions ...types.ExtensionSnapshotter) error
- func (m *Manager) Restore(snapshot types.Snapshot) error
- func (m *Manager) RestoreChunk(chunk []byte) (bool, error)
- func (m *Manager) RestoreLocalSnapshot(height uint64, format uint32) error
- func (m *Manager) SnapshotIfApplicable(height int64)
- type Store
- func (s *Store) Delete(height uint64, format uint32) error
- func (s *Store) Get(height uint64, format uint32) (*types.Snapshot, error)
- func (s *Store) GetLatest() (*types.Snapshot, error)
- func (s *Store) List() ([]*types.Snapshot, error)
- func (s *Store) Load(height uint64, format uint32) (*types.Snapshot, <-chan io.ReadCloser, error)
- func (s *Store) LoadChunk(height uint64, format, chunk uint32) (io.ReadCloser, error)
- func (s *Store) PathChunk(height uint64, format, chunk uint32) string
- func (s *Store) Prune(retain uint32) (uint64, error)
- func (s *Store) Save(height uint64, format uint32, chunks <-chan io.ReadCloser) (*types.Snapshot, error)
- type StreamReader
- type StreamWriter
Constants ¶
This section is empty.
Variables ¶
var ErrOptsZeroSnapshotInterval = errors.New("snaphot-interval must not be 0")
Functions ¶
func DrainChunks ¶
func DrainChunks(chunks <-chan io.ReadCloser)
DrainChunks drains and closes all remaining chunks from a chunk channel.
func IsFormatSupported ¶ added in v0.45.2
func IsFormatSupported(snapshotter types.ExtensionSnapshotter, format uint32) bool
IsFormatSupported returns if the snapshotter supports restoration from given format.
func ValidRestoreHeight ¶ added in v0.46.0
ValidRestoreHeight will check height is valid for snapshot restore or not
Types ¶
type ChunkReader ¶
type ChunkReader struct {
// contains filtered or unexported fields
}
ChunkReader reads chunks from a channel of io.ReadClosers and outputs them as an io.Reader
func NewChunkReader ¶
func NewChunkReader(ch <-chan io.ReadCloser) *ChunkReader
NewChunkReader creates a new ChunkReader.
type ChunkWriter ¶
type ChunkWriter struct {
// contains filtered or unexported fields
}
ChunkWriter reads an input stream, splits it into fixed-size chunks, and writes them to a sequence of io.ReadClosers via a channel.
func NewChunkWriter ¶
func NewChunkWriter(ch chan<- io.ReadCloser, chunkSize uint64) *ChunkWriter
NewChunkWriter creates a new ChunkWriter. If chunkSize is 0, no chunking will be done.
func (*ChunkWriter) CloseWithError ¶
func (w *ChunkWriter) CloseWithError(err error)
CloseWithError closes the writer and sends an error to the reader.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages snapshot and restore operations for an app, making sure only a single long-running operation is in progress at any given time, and provides convenience methods mirroring the ABCI interface.
Although the ABCI interface (and this manager) passes chunks as byte slices, the internal snapshot/restore APIs use IO streams (i.e. chan io.ReadCloser), for two reasons:
In the future, ABCI should support streaming. Consider e.g. InitChain during chain upgrades, which currently passes the entire chain state as an in-memory byte slice. https://github.com/tendermint/tendermint/issues/5184
io.ReadCloser streams automatically propagate IO errors, and can pass arbitrary errors via io.Pipe.CloseWithError().
func NewManager ¶
func NewManager(store *Store, opts types.SnapshotOptions, multistore types.Snapshotter, extensions map[string]types.ExtensionSnapshotter, logger log.Logger) *Manager
NewManager creates a new manager.
func (*Manager) GetInterval ¶ added in v0.46.0
GetInterval returns snapshot interval represented in heights.
func (*Manager) GetKeepRecent ¶ added in v0.46.0
GetKeepRecent returns snapshot keep-recent represented in heights.
func (*Manager) GetSnapshotBlockRetentionHeights ¶ added in v0.46.0
GetSnapshotBlockRetentionHeights returns the number of heights needed for block retention. Blocks since the oldest available snapshot must be available for state sync nodes to catch up (oldest because a node may be restoring an old snapshot while a new snapshot was taken).
func (*Manager) List ¶
List lists snapshots, mirroring ABCI ListSnapshots. It can be concurrent with other operations.
func (*Manager) LoadChunk ¶
LoadChunk loads a chunk into a byte slice, mirroring ABCI LoadChunk. It can be called concurrently with other operations. If the chunk does not exist, nil is returned.
func (*Manager) RegisterExtensions ¶ added in v0.45.2
func (m *Manager) RegisterExtensions(extensions ...types.ExtensionSnapshotter) error
RegisterExtensions register extension snapshotters to manager
func (*Manager) Restore ¶
Restore begins an async snapshot restoration, mirroring ABCI OfferSnapshot. Chunks must be fed via RestoreChunk() until the restore is complete or a chunk fails.
func (*Manager) RestoreChunk ¶
RestoreChunk adds a chunk to an active snapshot restoration, mirroring ABCI ApplySnapshotChunk. Chunks must be given until the restore is complete, returning true, or a chunk errors.
func (*Manager) RestoreLocalSnapshot ¶ added in v0.46.13
RestoreLocalSnapshot restores app state from a local snapshot.
func (*Manager) SnapshotIfApplicable ¶ added in v0.46.0
SnapshotIfApplicable takes a snapshot of the current state if we are on a snapshot height. It also prunes any old snapshots.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a snapshot store, containing snapshot metadata and binary chunks.
func (*Store) Load ¶
Load loads a snapshot (both metadata and binary chunks). The chunks must be consumed and closed. Returns nil if the snapshot does not exist.
func (*Store) LoadChunk ¶
LoadChunk loads a chunk from disk, or returns nil if it does not exist. The caller must call Close() on it when done.
type StreamReader ¶ added in v0.45.2
type StreamReader struct {
// contains filtered or unexported fields
}
StreamReader set up a restore stream pipeline chan io.ReadCloser -> chunkReader -> zlib -> delimited Protobuf -> ExportNode
func NewStreamReader ¶ added in v0.45.2
func NewStreamReader(chunks <-chan io.ReadCloser) (*StreamReader, error)
NewStreamReader set up a restore stream pipeline.
func (*StreamReader) Close ¶ added in v0.45.2
func (sr *StreamReader) Close() error
Close implements io.Closer interface
type StreamWriter ¶ added in v0.45.2
type StreamWriter struct {
// contains filtered or unexported fields
}
StreamWriter set up a stream pipeline to serialize snapshot nodes: Exported Items -> delimited Protobuf -> zlib -> buffer -> chunkWriter -> chan io.ReadCloser
func NewStreamWriter ¶ added in v0.45.2
func NewStreamWriter(ch chan<- io.ReadCloser) *StreamWriter
NewStreamWriter set up a stream pipeline to serialize snapshot DB records.
func (*StreamWriter) Close ¶ added in v0.45.2
func (sw *StreamWriter) Close() error
Close implements io.Closer interface
func (*StreamWriter) CloseWithError ¶ added in v0.45.2
func (sw *StreamWriter) CloseWithError(err error)
CloseWithError pass error to chunkWriter