types

package
v0.0.0-...-a24c2e4 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const CurrentFormat uint32 = 3

CurrentFormat is the currently used format for snapshots. Snapshots using the same format must be identical across all nodes for a given height, so this must be bumped when the binary snapshot output changes.

Variables

View Source
var (
	// ErrUnknownFormat is returned when an unknown format is used.
	ErrUnknownFormat = errors.New("unknown snapshot format")

	// ErrChunkHashMismatch is returned when chunk hash verification failed.
	ErrChunkHashMismatch = errors.New("chunk hash verification failed")

	// ErrInvalidMetadata is returned when the snapshot metadata is invalid.
	ErrInvalidMetadata = errors.New("invalid snapshot metadata")

	// ErrInvalidSnapshotVersion is returned when the snapshot version is invalid
	ErrInvalidSnapshotVersion = errors.New("invalid snapshot version")
)
View Source
var (
	ErrInvalidLengthSnapshot        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowSnapshot          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupSnapshot = fmt.Errorf("proto: unexpected end of group")
)

Functions

func WriteExtensionPayload

func WriteExtensionPayload(protoWriter protoio.Writer, payload []byte) error

WriteExtensionPayload writes an extension payload for current extension snapshotter.

Types

type ExtensionPayloadReader

type ExtensionPayloadReader = func() ([]byte, error)

ExtensionPayloadReader read extension payloads, it returns io.EOF when reached either end of stream or the extension boundaries.

type ExtensionPayloadWriter

type ExtensionPayloadWriter = func([]byte) error

ExtensionPayloadWriter is a helper to write extension payloads to underlying stream.

type ExtensionSnapshotter

type ExtensionSnapshotter interface {
	// SnapshotName returns the name of snapshotter, it should be unique in the manager.
	SnapshotName() string

	// SnapshotFormat returns the default format the extension snapshotter use to encode the
	// payloads when taking a snapshot.
	// It's defined within the extension, different from the global format for the whole state-sync snapshot.
	SnapshotFormat() uint32

	// SupportedFormats returns a list of formats it can restore from.
	SupportedFormats() []uint32

	// SnapshotExtension writes extension payloads into the underlying protobuf stream.
	SnapshotExtension(height uint64, payloadWriter ExtensionPayloadWriter) error

	// RestoreExtension restores an extension state snapshot,
	// the payload reader returns `io.EOF` when reached the extension boundaries.
	RestoreExtension(height uint64, format uint32, payloadReader ExtensionPayloadReader) error
}

ExtensionSnapshotter is an extension Snapshotter that is appended to the snapshot stream. ExtensionSnapshotter has an unique name and manages it's own internal formats.

type Metadata

type Metadata struct {
	ChunkHashes [][]byte `protobuf:"bytes,1,rep,name=chunk_hashes,json=chunkHashes,proto3" json:"chunk_hashes,omitempty"`
}

Metadata contains SDK-specific snapshot metadata.

func (*Metadata) Descriptor

func (*Metadata) Descriptor() ([]byte, []int)

func (*Metadata) GetChunkHashes

func (m *Metadata) GetChunkHashes() [][]byte

func (*Metadata) Marshal

func (m *Metadata) Marshal() (dAtA []byte, err error)

func (*Metadata) MarshalTo

func (m *Metadata) MarshalTo(dAtA []byte) (int, error)

func (*Metadata) MarshalToSizedBuffer

func (m *Metadata) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Metadata) ProtoMessage

func (*Metadata) ProtoMessage()

func (*Metadata) Reset

func (m *Metadata) Reset()

func (*Metadata) Size

func (m *Metadata) Size() (n int)

func (*Metadata) String

func (m *Metadata) String() string

func (*Metadata) Unmarshal

func (m *Metadata) Unmarshal(dAtA []byte) error

func (*Metadata) XXX_DiscardUnknown

func (m *Metadata) XXX_DiscardUnknown()

func (*Metadata) XXX_Marshal

func (m *Metadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Metadata) XXX_Merge

func (m *Metadata) XXX_Merge(src proto.Message)

func (*Metadata) XXX_Size

func (m *Metadata) XXX_Size() int

func (*Metadata) XXX_Unmarshal

func (m *Metadata) XXX_Unmarshal(b []byte) error

type Snapshot

type Snapshot struct {
	Height   uint64   `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"`
	Format   uint32   `protobuf:"varint,2,opt,name=format,proto3" json:"format,omitempty"`
	Chunks   uint32   `protobuf:"varint,3,opt,name=chunks,proto3" json:"chunks,omitempty"`
	Hash     []byte   `protobuf:"bytes,4,opt,name=hash,proto3" json:"hash,omitempty"`
	Metadata Metadata `protobuf:"bytes,5,opt,name=metadata,proto3" json:"metadata"`
}

Snapshot contains Tendermint state sync snapshot info.

func SnapshotFromABCI

func SnapshotFromABCI(in *abci.Snapshot) (Snapshot, error)

Converts an ABCI snapshot to a snapshot. Mainly to decode the SDK metadata.

func (*Snapshot) Descriptor

func (*Snapshot) Descriptor() ([]byte, []int)

func (*Snapshot) GetChunks

func (m *Snapshot) GetChunks() uint32

func (*Snapshot) GetFormat

func (m *Snapshot) GetFormat() uint32

func (*Snapshot) GetHash

func (m *Snapshot) GetHash() []byte

func (*Snapshot) GetHeight

func (m *Snapshot) GetHeight() uint64

func (*Snapshot) GetMetadata

func (m *Snapshot) GetMetadata() Metadata

func (*Snapshot) Marshal

func (m *Snapshot) Marshal() (dAtA []byte, err error)

func (*Snapshot) MarshalTo

func (m *Snapshot) MarshalTo(dAtA []byte) (int, error)

func (*Snapshot) MarshalToSizedBuffer

func (m *Snapshot) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Snapshot) ProtoMessage

func (*Snapshot) ProtoMessage()

func (*Snapshot) Reset

func (m *Snapshot) Reset()

func (*Snapshot) Size

func (m *Snapshot) Size() (n int)

func (*Snapshot) String

func (m *Snapshot) String() string

func (Snapshot) ToABCI

func (s Snapshot) ToABCI() (abci.Snapshot, error)

Converts a Snapshot to its ABCI representation. Mainly to encode the SDK metadata.

func (*Snapshot) Unmarshal

func (m *Snapshot) Unmarshal(dAtA []byte) error

func (*Snapshot) XXX_DiscardUnknown

func (m *Snapshot) XXX_DiscardUnknown()

func (*Snapshot) XXX_Marshal

func (m *Snapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Snapshot) XXX_Merge

func (m *Snapshot) XXX_Merge(src proto.Message)

func (*Snapshot) XXX_Size

func (m *Snapshot) XXX_Size() int

func (*Snapshot) XXX_Unmarshal

func (m *Snapshot) XXX_Unmarshal(b []byte) error

type SnapshotExtensionMeta

type SnapshotExtensionMeta struct {
	Name   string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Format uint32 `protobuf:"varint,2,opt,name=format,proto3" json:"format,omitempty"`
}

SnapshotExtensionMeta contains metadata about an external snapshotter.

Since: cosmos-sdk 0.46

func (*SnapshotExtensionMeta) Descriptor

func (*SnapshotExtensionMeta) Descriptor() ([]byte, []int)

func (*SnapshotExtensionMeta) GetFormat

func (m *SnapshotExtensionMeta) GetFormat() uint32

func (*SnapshotExtensionMeta) GetName

func (m *SnapshotExtensionMeta) GetName() string

func (*SnapshotExtensionMeta) Marshal

func (m *SnapshotExtensionMeta) Marshal() (dAtA []byte, err error)

func (*SnapshotExtensionMeta) MarshalTo

func (m *SnapshotExtensionMeta) MarshalTo(dAtA []byte) (int, error)

func (*SnapshotExtensionMeta) MarshalToSizedBuffer

func (m *SnapshotExtensionMeta) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SnapshotExtensionMeta) ProtoMessage

func (*SnapshotExtensionMeta) ProtoMessage()

func (*SnapshotExtensionMeta) Reset

func (m *SnapshotExtensionMeta) Reset()

func (*SnapshotExtensionMeta) Size

func (m *SnapshotExtensionMeta) Size() (n int)

func (*SnapshotExtensionMeta) String

func (m *SnapshotExtensionMeta) String() string

func (*SnapshotExtensionMeta) Unmarshal

func (m *SnapshotExtensionMeta) Unmarshal(dAtA []byte) error

func (*SnapshotExtensionMeta) XXX_DiscardUnknown

func (m *SnapshotExtensionMeta) XXX_DiscardUnknown()

func (*SnapshotExtensionMeta) XXX_Marshal

func (m *SnapshotExtensionMeta) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SnapshotExtensionMeta) XXX_Merge

func (m *SnapshotExtensionMeta) XXX_Merge(src proto.Message)

func (*SnapshotExtensionMeta) XXX_Size

func (m *SnapshotExtensionMeta) XXX_Size() int

func (*SnapshotExtensionMeta) XXX_Unmarshal

func (m *SnapshotExtensionMeta) XXX_Unmarshal(b []byte) error

type SnapshotExtensionPayload

type SnapshotExtensionPayload struct {
	Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"`
}

SnapshotExtensionPayload contains payloads of an external snapshotter.

Since: cosmos-sdk 0.46

func (*SnapshotExtensionPayload) Descriptor

func (*SnapshotExtensionPayload) Descriptor() ([]byte, []int)

func (*SnapshotExtensionPayload) GetPayload

func (m *SnapshotExtensionPayload) GetPayload() []byte

func (*SnapshotExtensionPayload) Marshal

func (m *SnapshotExtensionPayload) Marshal() (dAtA []byte, err error)

func (*SnapshotExtensionPayload) MarshalTo

func (m *SnapshotExtensionPayload) MarshalTo(dAtA []byte) (int, error)

func (*SnapshotExtensionPayload) MarshalToSizedBuffer

func (m *SnapshotExtensionPayload) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SnapshotExtensionPayload) ProtoMessage

func (*SnapshotExtensionPayload) ProtoMessage()

func (*SnapshotExtensionPayload) Reset

func (m *SnapshotExtensionPayload) Reset()

func (*SnapshotExtensionPayload) Size

func (m *SnapshotExtensionPayload) Size() (n int)

func (*SnapshotExtensionPayload) String

func (m *SnapshotExtensionPayload) String() string

func (*SnapshotExtensionPayload) Unmarshal

func (m *SnapshotExtensionPayload) Unmarshal(dAtA []byte) error

func (*SnapshotExtensionPayload) XXX_DiscardUnknown

func (m *SnapshotExtensionPayload) XXX_DiscardUnknown()

func (*SnapshotExtensionPayload) XXX_Marshal

func (m *SnapshotExtensionPayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SnapshotExtensionPayload) XXX_Merge

func (m *SnapshotExtensionPayload) XXX_Merge(src proto.Message)

func (*SnapshotExtensionPayload) XXX_Size

func (m *SnapshotExtensionPayload) XXX_Size() int

func (*SnapshotExtensionPayload) XXX_Unmarshal

func (m *SnapshotExtensionPayload) XXX_Unmarshal(b []byte) error

type SnapshotIAVLItem

type SnapshotIAVLItem struct {
	Key   []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
	// version is block height
	Version int64 `protobuf:"varint,3,opt,name=version,proto3" json:"version,omitempty"`
	// height is depth of the tree.
	Height int32 `protobuf:"varint,4,opt,name=height,proto3" json:"height,omitempty"`
}

SnapshotIAVLItem is an exported IAVL node.

Since: cosmos-sdk 0.46

func (*SnapshotIAVLItem) Descriptor

func (*SnapshotIAVLItem) Descriptor() ([]byte, []int)

func (*SnapshotIAVLItem) GetHeight

func (m *SnapshotIAVLItem) GetHeight() int32

func (*SnapshotIAVLItem) GetKey

func (m *SnapshotIAVLItem) GetKey() []byte

func (*SnapshotIAVLItem) GetValue

func (m *SnapshotIAVLItem) GetValue() []byte

func (*SnapshotIAVLItem) GetVersion

func (m *SnapshotIAVLItem) GetVersion() int64

func (*SnapshotIAVLItem) Marshal

func (m *SnapshotIAVLItem) Marshal() (dAtA []byte, err error)

func (*SnapshotIAVLItem) MarshalTo

func (m *SnapshotIAVLItem) MarshalTo(dAtA []byte) (int, error)

func (*SnapshotIAVLItem) MarshalToSizedBuffer

func (m *SnapshotIAVLItem) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SnapshotIAVLItem) ProtoMessage

func (*SnapshotIAVLItem) ProtoMessage()

func (*SnapshotIAVLItem) Reset

func (m *SnapshotIAVLItem) Reset()

func (*SnapshotIAVLItem) Size

func (m *SnapshotIAVLItem) Size() (n int)

func (*SnapshotIAVLItem) String

func (m *SnapshotIAVLItem) String() string

func (*SnapshotIAVLItem) Unmarshal

func (m *SnapshotIAVLItem) Unmarshal(dAtA []byte) error

func (*SnapshotIAVLItem) XXX_DiscardUnknown

func (m *SnapshotIAVLItem) XXX_DiscardUnknown()

func (*SnapshotIAVLItem) XXX_Marshal

func (m *SnapshotIAVLItem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SnapshotIAVLItem) XXX_Merge

func (m *SnapshotIAVLItem) XXX_Merge(src proto.Message)

func (*SnapshotIAVLItem) XXX_Size

func (m *SnapshotIAVLItem) XXX_Size() int

func (*SnapshotIAVLItem) XXX_Unmarshal

func (m *SnapshotIAVLItem) XXX_Unmarshal(b []byte) error

type SnapshotItem

type SnapshotItem struct {
	// item is the specific type of snapshot item.
	//
	// Types that are valid to be assigned to Item:
	//
	//	*SnapshotItem_Store
	//	*SnapshotItem_IAVL
	//	*SnapshotItem_Extension
	//	*SnapshotItem_ExtensionPayload
	Item isSnapshotItem_Item `protobuf_oneof:"item"`
}

SnapshotItem is an item contained in a rootmulti.Store snapshot.

Since: cosmos-sdk 0.46

func (*SnapshotItem) Descriptor

func (*SnapshotItem) Descriptor() ([]byte, []int)

func (*SnapshotItem) GetExtension

func (m *SnapshotItem) GetExtension() *SnapshotExtensionMeta

func (*SnapshotItem) GetExtensionPayload

func (m *SnapshotItem) GetExtensionPayload() *SnapshotExtensionPayload

func (*SnapshotItem) GetIAVL

func (m *SnapshotItem) GetIAVL() *SnapshotIAVLItem

func (*SnapshotItem) GetItem

func (m *SnapshotItem) GetItem() isSnapshotItem_Item

func (*SnapshotItem) GetStore

func (m *SnapshotItem) GetStore() *SnapshotStoreItem

func (*SnapshotItem) Marshal

func (m *SnapshotItem) Marshal() (dAtA []byte, err error)

func (*SnapshotItem) MarshalTo

func (m *SnapshotItem) MarshalTo(dAtA []byte) (int, error)

func (*SnapshotItem) MarshalToSizedBuffer

func (m *SnapshotItem) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SnapshotItem) ProtoMessage

func (*SnapshotItem) ProtoMessage()

func (*SnapshotItem) Reset

func (m *SnapshotItem) Reset()

func (*SnapshotItem) Size

func (m *SnapshotItem) Size() (n int)

func (*SnapshotItem) String

func (m *SnapshotItem) String() string

func (*SnapshotItem) Unmarshal

func (m *SnapshotItem) Unmarshal(dAtA []byte) error

func (*SnapshotItem) XXX_DiscardUnknown

func (m *SnapshotItem) XXX_DiscardUnknown()

func (*SnapshotItem) XXX_Marshal

func (m *SnapshotItem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SnapshotItem) XXX_Merge

func (m *SnapshotItem) XXX_Merge(src proto.Message)

func (*SnapshotItem) XXX_OneofWrappers

func (*SnapshotItem) XXX_OneofWrappers() []interface{}

XXX_OneofWrappers is for the internal use of the proto package.

func (*SnapshotItem) XXX_Size

func (m *SnapshotItem) XXX_Size() int

func (*SnapshotItem) XXX_Unmarshal

func (m *SnapshotItem) XXX_Unmarshal(b []byte) error

type SnapshotItem_Extension

type SnapshotItem_Extension struct {
	Extension *SnapshotExtensionMeta `protobuf:"bytes,3,opt,name=extension,proto3,oneof" json:"extension,omitempty"`
}

func (*SnapshotItem_Extension) MarshalTo

func (m *SnapshotItem_Extension) MarshalTo(dAtA []byte) (int, error)

func (*SnapshotItem_Extension) MarshalToSizedBuffer

func (m *SnapshotItem_Extension) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SnapshotItem_Extension) Size

func (m *SnapshotItem_Extension) Size() (n int)

type SnapshotItem_ExtensionPayload

type SnapshotItem_ExtensionPayload struct {
	ExtensionPayload *SnapshotExtensionPayload `protobuf:"bytes,4,opt,name=extension_payload,json=extensionPayload,proto3,oneof" json:"extension_payload,omitempty"`
}

func (*SnapshotItem_ExtensionPayload) MarshalTo

func (m *SnapshotItem_ExtensionPayload) MarshalTo(dAtA []byte) (int, error)

func (*SnapshotItem_ExtensionPayload) MarshalToSizedBuffer

func (m *SnapshotItem_ExtensionPayload) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SnapshotItem_ExtensionPayload) Size

func (m *SnapshotItem_ExtensionPayload) Size() (n int)

type SnapshotItem_IAVL

type SnapshotItem_IAVL struct {
	IAVL *SnapshotIAVLItem `protobuf:"bytes,2,opt,name=iavl,proto3,oneof" json:"iavl,omitempty"`
}

func (*SnapshotItem_IAVL) MarshalTo

func (m *SnapshotItem_IAVL) MarshalTo(dAtA []byte) (int, error)

func (*SnapshotItem_IAVL) MarshalToSizedBuffer

func (m *SnapshotItem_IAVL) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SnapshotItem_IAVL) Size

func (m *SnapshotItem_IAVL) Size() (n int)

type SnapshotItem_Store

type SnapshotItem_Store struct {
	Store *SnapshotStoreItem `protobuf:"bytes,1,opt,name=store,proto3,oneof" json:"store,omitempty"`
}

func (*SnapshotItem_Store) MarshalTo

func (m *SnapshotItem_Store) MarshalTo(dAtA []byte) (int, error)

func (*SnapshotItem_Store) MarshalToSizedBuffer

func (m *SnapshotItem_Store) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SnapshotItem_Store) Size

func (m *SnapshotItem_Store) Size() (n int)

type SnapshotOptions

type SnapshotOptions struct {
	// Interval defines at which heights the snapshot is taken.
	Interval uint64

	// KeepRecent defines how many snapshots to keep in heights.
	KeepRecent uint32
}

SnapshotOptions defines the snapshot strategy used when determining which heights are snapshotted for state sync.

func NewSnapshotOptions

func NewSnapshotOptions(interval uint64, keepRecent uint32) SnapshotOptions

type SnapshotStoreItem

type SnapshotStoreItem struct {
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
}

SnapshotStoreItem contains metadata about a snapshotted store.

Since: cosmos-sdk 0.46

func (*SnapshotStoreItem) Descriptor

func (*SnapshotStoreItem) Descriptor() ([]byte, []int)

func (*SnapshotStoreItem) GetName

func (m *SnapshotStoreItem) GetName() string

func (*SnapshotStoreItem) Marshal

func (m *SnapshotStoreItem) Marshal() (dAtA []byte, err error)

func (*SnapshotStoreItem) MarshalTo

func (m *SnapshotStoreItem) MarshalTo(dAtA []byte) (int, error)

func (*SnapshotStoreItem) MarshalToSizedBuffer

func (m *SnapshotStoreItem) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SnapshotStoreItem) ProtoMessage

func (*SnapshotStoreItem) ProtoMessage()

func (*SnapshotStoreItem) Reset

func (m *SnapshotStoreItem) Reset()

func (*SnapshotStoreItem) Size

func (m *SnapshotStoreItem) Size() (n int)

func (*SnapshotStoreItem) String

func (m *SnapshotStoreItem) String() string

func (*SnapshotStoreItem) Unmarshal

func (m *SnapshotStoreItem) Unmarshal(dAtA []byte) error

func (*SnapshotStoreItem) XXX_DiscardUnknown

func (m *SnapshotStoreItem) XXX_DiscardUnknown()

func (*SnapshotStoreItem) XXX_Marshal

func (m *SnapshotStoreItem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SnapshotStoreItem) XXX_Merge

func (m *SnapshotStoreItem) XXX_Merge(src proto.Message)

func (*SnapshotStoreItem) XXX_Size

func (m *SnapshotStoreItem) XXX_Size() int

func (*SnapshotStoreItem) XXX_Unmarshal

func (m *SnapshotStoreItem) XXX_Unmarshal(b []byte) error

type Snapshotter

type Snapshotter interface {
	// Snapshot writes snapshot items into the protobuf writer.
	Snapshot(height uint64, protoWriter protoio.Writer) error

	// PruneSnapshotHeight prunes the given height according to the prune strategy.
	// If PruneNothing, this is a no-op.
	// If other strategy, this height is persisted until it is
	// less than <current height> - KeepRecent and <current height> % Interval == 0
	PruneSnapshotHeight(height int64)

	// SetSnapshotInterval sets the interval at which the snapshots are taken.
	// It is used by the store that implements the Snapshotter interface
	// to determine which heights to retain until after the snapshot is complete.
	SetSnapshotInterval(snapshotInterval uint64)

	// Restore restores a state snapshot, taking the reader of protobuf message stream as input.
	Restore(height uint64, format uint32, protoReader protoio.Reader) (SnapshotItem, error)
}

Snapshotter is something that can create and restore snapshots, consisting of streamed binary chunks - all of which must be read from the channel and closed. If an unsupported format is given, it must return ErrUnknownFormat (possibly wrapped with fmt.Errorf).

Jump to

Keyboard shortcuts

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