fabric: github.com/hyperledger/fabric/common/ledger/snapshot Index | Files

package snapshot

import "github.com/hyperledger/fabric/common/ledger/snapshot"

Index

Package Files

file.go

type FileReader Uses

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 verifies 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 Uses

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 Uses

func (r *FileReader) Close() error

Close closes the file

func (*FileReader) DecodeBytes Uses

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

DecodeBytes reads and decodes bytes

func (*FileReader) DecodeProtoMessage Uses

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

DecodeProtoMessage reads and decodes a protoMessage

func (*FileReader) DecodeString Uses

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

DecodeString reads and decodes a string

func (*FileReader) DecodeUVarInt Uses

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

DecodeUVarInt reads and decodes a number

type FileWriter Uses

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 Uses

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 Uses

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 Uses

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

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

func (*FileWriter) EncodeBytes Uses

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

EncodeBytes encodes and appends bytes to the data stream

func (*FileWriter) EncodeProtoMessage Uses

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

EncodeString encodes and appends a proto message to the data stream

func (*FileWriter) EncodeString Uses

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

EncodeString encodes and appends the string to the data stream

func (*FileWriter) EncodeUVarint Uses

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

EncodeUVarint encodes and appends a number to the data stream

type NewHashFunc Uses

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

Package snapshot imports 8 packages (graph) and is imported by 5 packages. Updated 2020-08-15. Refresh now. Tools for package owners.