snapshot

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const Version2 = 2

Variables

This section is empty.

Functions

func GetVersion added in v1.2.0

func GetVersion(file ioutil.SectionReader) (uint64, error)

Types

type CollectOptions added in v1.2.0

type CollectOptions struct {
	Walk       database.WalkOptions
	Predicate  func(database.Record) (bool, error)
	DidCollect func(value database.Value, section, offset uint64) error
}

type Collector

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

func (*Collector) Close

func (c *Collector) Close() error

func (*Collector) Collect

func (c *Collector) Collect(r database.Record, opts CollectOptions) error
type Header struct {

	// Version is the snapshot format version.
	Version uint64 `json:"version,omitempty" form:"version" query:"version" validate:"required"`
	// RootHash is the snapshot's root hash.
	RootHash [32]byte `json:"rootHash,omitempty" form:"rootHash" query:"rootHash" validate:"required"`
	// SystemLedger is the partition's system ledger.
	SystemLedger *protocol.SystemLedger `json:"systemLedger,omitempty" form:"systemLedger" query:"systemLedger" validate:"required"`
	// contains filtered or unexported fields
}

func (*Header) Copy

func (v *Header) Copy() *Header

func (*Header) CopyAsInterface

func (v *Header) CopyAsInterface() interface{}

func (*Header) Equal

func (v *Header) Equal(u *Header) bool

func (*Header) IsValid

func (v *Header) IsValid() error

func (*Header) MarshalBinary

func (v *Header) MarshalBinary() ([]byte, error)

func (*Header) MarshalJSON

func (v *Header) MarshalJSON() ([]byte, error)

func (*Header) UnmarshalBinary

func (v *Header) UnmarshalBinary(data []byte) error

func (*Header) UnmarshalBinaryFrom

func (v *Header) UnmarshalBinaryFrom(rd io.Reader) error

func (*Header) UnmarshalJSON

func (v *Header) UnmarshalJSON(data []byte) error

type IndexReader

type IndexReader struct {
	Count int
	// contains filtered or unexported fields
}

func (*IndexReader) Read

func (i *IndexReader) Read(n int) (*RecordIndexEntry, error)

type Indexer added in v1.2.0

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

func (*Indexer) Close added in v1.2.0

func (i *Indexer) Close() error

func (*Indexer) Write added in v1.2.0

func (i *Indexer) Write(e RecordIndexEntry) error

type Reader

type Reader struct {
	Sections []*sectionReader
	Header   *Header
}

func Open

func Open(file ioutil.SectionReader) (*Reader, error)

Open opens a snapshot file for reading.

func (*Reader) AsStore

func (r *Reader) AsStore() (*Store, error)

func (*Reader) Open added in v1.2.10

func (r *Reader) Open(typ ...SectionType) (ioutil.SectionReader, error)

Open opens the first section of the given type

func (*Reader) OpenBPT added in v1.2.10

func (r *Reader) OpenBPT(i int) (RecordReader, error)

func (*Reader) OpenIndex

func (r *Reader) OpenIndex(i int) (*IndexReader, error)

func (*Reader) OpenRecords

func (r *Reader) OpenRecords(i int) (RecordReader, error)

type RecordEntry

type RecordEntry struct {
	Key     *record.Key     `json:"key,omitempty" form:"key" query:"key" validate:"required"`
	Value   []byte          `json:"value,omitempty" form:"value" query:"value" validate:"required"`
	Receipt *merkle.Receipt `json:"receipt,omitempty" form:"receipt" query:"receipt" validate:"required"`
	// contains filtered or unexported fields
}

func (*RecordEntry) Copy

func (v *RecordEntry) Copy() *RecordEntry

func (*RecordEntry) CopyAsInterface

func (v *RecordEntry) CopyAsInterface() interface{}

func (*RecordEntry) Equal

func (v *RecordEntry) Equal(u *RecordEntry) bool

func (*RecordEntry) IsValid

func (v *RecordEntry) IsValid() error

func (*RecordEntry) MarshalBinary

func (v *RecordEntry) MarshalBinary() ([]byte, error)

func (*RecordEntry) MarshalJSON

func (v *RecordEntry) MarshalJSON() ([]byte, error)

func (*RecordEntry) UnmarshalBinary

func (v *RecordEntry) UnmarshalBinary(data []byte) error

func (*RecordEntry) UnmarshalBinaryFrom

func (v *RecordEntry) UnmarshalBinaryFrom(rd io.Reader) error

func (*RecordEntry) UnmarshalJSON

func (v *RecordEntry) UnmarshalJSON(data []byte) error

type RecordIndexEntry

type RecordIndexEntry struct {
	Key     record.KeyHash
	Section int
	Offset  uint64
}

type RecordReader

type RecordReader interface {
	io.Seeker
	Read() (*RecordEntry, error)
	ReadAt(offset int64) (*RecordEntry, error)
}

type SectionType

type SectionType uint64

SectionType is the type of a snapshot section.

const SectionTypeAccountsV1 SectionType = 2

SectionTypeAccountsV1 contains accounts (v1).

const SectionTypeBPT SectionType = 11

SectionTypeBPT contains the BPT, as records.

const SectionTypeConsensus SectionType = 10

SectionTypeConsensus contains consensus parameters.

const SectionTypeGzTransactionsV1 SectionType = 5

SectionTypeGzTransactionsV1 contains gzipped transactions (v1).

const SectionTypeHeader SectionType = 1

SectionTypeHeader is the snapshot's header.

const SectionTypeRawBPT SectionType = 9

SectionTypeRawBPT contains the BPT, as raw (key hash, value) pairs.

const SectionTypeRecordIndex SectionType = 8

SectionTypeRecordIndex indexes record keys, including the offset and section number.

const SectionTypeRecords SectionType = 7

SectionTypeRecords contains records stored as (key, record) pairs.

const SectionTypeSignaturesV1 SectionType = 4

SectionTypeSignaturesV1 contains signatures (v1).

const SectionTypeSnapshot SectionType = 6

SectionTypeSnapshot contains another snapshot.

const SectionTypeTransactionsV1 SectionType = 3

SectionTypeTransactionsV1 contains transactions (v1).

func SectionTypeByName

func SectionTypeByName(name string) (SectionType, bool)

SectionTypeByName returns the named Section Type.

func (SectionType) GetEnumValue

func (v SectionType) GetEnumValue() uint64

GetEnumValue returns the value of the Section Type

func (SectionType) MarshalJSON

func (v SectionType) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Section Type to JSON as a string.

func (*SectionType) SetEnumValue

func (v *SectionType) SetEnumValue(id uint64) bool

SetEnumValue sets the value. SetEnumValue returns false if the value is invalid.

func (SectionType) String

func (v SectionType) String() string

String returns the name of the Section Type.

func (*SectionType) UnmarshalJSON

func (v *SectionType) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the Section Type from JSON as a string.

type SectionWriter added in v1.2.10

type SectionWriter struct {
	ioutil.SegmentWriter[SectionType, *SectionType]
	// contains filtered or unexported fields
}

func (*SectionWriter) SectionNumber added in v1.2.10

func (c *SectionWriter) SectionNumber() int

func (*SectionWriter) WriteValue added in v1.2.10

func (c *SectionWriter) WriteValue(r encoding.BinaryValue) error

type Store

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

func (*Store) Delete

func (s *Store) Delete(*record.Key) error

func (*Store) Get

func (s *Store) Get(key *record.Key) ([]byte, error)

func (*Store) Put

func (s *Store) Put(*record.Key, []byte) error

type Writer

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

func Create

func Create(file io.WriteSeeker) (*Writer, error)

Create opens a snapshot file for writing.

func (*Writer) OpenIndex added in v1.2.0

func (w *Writer) OpenIndex() (*Indexer, error)

func (*Writer) OpenRaw

func (w *Writer) OpenRaw(typ SectionType) (*SectionWriter, error)

func (*Writer) OpenRecords

func (w *Writer) OpenRecords() (*Collector, error)

func (*Writer) WriteHeader

func (w *Writer) WriteHeader(header *Header) error

Jump to

Keyboard shortcuts

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