github.com/Finschia/finschia-sdk@v0.48.1/snapshots/types/snapshotter.go (about) 1 package types 2 3 import ( 4 protoio "github.com/gogo/protobuf/io" 5 ) 6 7 // Snapshotter is something that can create and restore snapshots, consisting of streamed binary 8 // chunks - all of which must be read from the channel and closed. If an unsupported format is 9 // given, it must return ErrUnknownFormat (possibly wrapped with fmt.Errorf). 10 type Snapshotter interface { 11 // Snapshot writes snapshot items into the protobuf writer. 12 Snapshot(height uint64, protoWriter protoio.Writer) error 13 14 // Restore restores a state snapshot from the protobuf items read from the reader. 15 // If the ready channel is non-nil, it returns a ready signal (by being closed) once the 16 // restorer is ready to accept chunks. 17 Restore(height uint64, format uint32, protoReader protoio.Reader) (SnapshotItem, error) 18 } 19 20 // ExtensionSnapshotter is an extension Snapshotter that is appended to the snapshot stream. 21 // ExtensionSnapshotter has an unique name and manages it's own internal formats. 22 type ExtensionSnapshotter interface { 23 Snapshotter 24 25 // SnapshotName returns the name of snapshotter, it should be unique in the manager. 26 SnapshotName() string 27 28 // SnapshotFormat returns the default format the extension snapshotter use to encode the 29 // payloads when taking a snapshot. 30 // It's defined within the extension, different from the global format for the whole state-sync snapshot. 31 SnapshotFormat() uint32 32 33 // SupportedFormats returns a list of formats it can restore from. 34 SupportedFormats() []uint32 35 }