snapshot

package
v1.4.0-rc1.0...-b8746e1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileReader

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

FileReader reads from a ledger snapshot file. This is expected to be used for loading the ledger snapshot data during bootstrapping a channel from snapshot. The data should be read, using the functions `DecodeXXX`, in the same sequence in which the data was written by the functions `EncodeXXX` in the `FileCreator`. Note that the FileReader does not verify the hash of stream and it is expected that the hash has been verified by the consumer. Later, if we decide to perform this, on-the-side, while loading the snapshot data, the FileRedear, like the FileCreator, would take a `hasher` as an input

func OpenFile

func OpenFile(filePath string, expectDataformat byte) (*FileReader, error)

OpenFile constructs a FileReader. This function returns an error if the format of the file, stored in the first byte, does not match with the expectedDataFormat

func (*FileReader) Close

func (r *FileReader) Close() error

Close closes the file

func (*FileReader) DecodeBytes

func (r *FileReader) DecodeBytes() ([]byte, error)

DecodeBytes reads and decodes bytes

func (*FileReader) DecodeProtoMessage

func (r *FileReader) DecodeProtoMessage(m proto.Message) error

DecodeProtoMessage reads and decodes a protoMessage

func (*FileReader) DecodeString

func (r *FileReader) DecodeString() (string, error)

DecodeString reads and decodes a string

func (*FileReader) DecodeUVarInt

func (r *FileReader) DecodeUVarInt() (uint64, error)

DecodeUVarInt reads and decodes a number

type FileWriter

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

FileWriter creates a new file for ledger snapshot. This is expected to be used by various components of ledger, such as blockstorage and statedb for exporting the relevant snapshot data

func CreateFile

func CreateFile(filePath string, dataformat byte, newHashFunc NewHashFunc) (*FileWriter, error)

CreateFile creates a new file for exporting the ledger snapshot data This function returns an error if the file already exists. The `dataformat` is the first byte written to the file. The function newHash is used to construct an hash.Hash for computing the hash-sum of the data stream

func (*FileWriter) Close

func (c *FileWriter) Close() error

Close closes the underlying file, if not already done. A consumer can invoke this function if the consumer encountered some error and simply wants to abandon the snapshot file creation (typically, intended to be used in a defer statement)

func (*FileWriter) Done

func (c *FileWriter) Done() ([]byte, error)

Done closes the snapshot file and returns the final hash of the data stream

func (*FileWriter) EncodeBytes

func (c *FileWriter) EncodeBytes(b []byte) error

EncodeBytes encodes and appends bytes to the data stream

func (*FileWriter) EncodeProtoMessage

func (c *FileWriter) EncodeProtoMessage(m proto.Message) error

EncodeProtoMessage encodes and appends a proto message to the data stream

func (*FileWriter) EncodeString

func (c *FileWriter) EncodeString(str string) error

EncodeString encodes and appends the string to the data stream

func (*FileWriter) EncodeUVarint

func (c *FileWriter) EncodeUVarint(u uint64) error

EncodeUVarint encodes and appends a number to the data stream

type NewHashFunc

type NewHashFunc func() (hash.Hash, error)

Jump to

Keyboard shortcuts

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