Documentation ¶
Index ¶
- Constants
- Variables
- func CollectAnchors(w *Writer, batch *database.Batch, network config.NetworkUrl) error
- func FullCollect(batch *database.Batch, file io.WriteSeeker, network config.NetworkUrl, ...) error
- func FullRestore(db database.Beginner, file ioutil2.SectionReader, logger log.Logger, ...) error
- func Open(file ioutil2.SectionReader) (*Header, *Reader, error)
- func Restore(db database.Beginner, file ioutil2.SectionReader, logger log.Logger) error
- func Visit(file ioutil2.SectionReader, visitor interface{}) error
- type Account
- func (a *Account) ConvertOldChains(markPower int64)
- func (v *Account) Copy() *Account
- func (v *Account) CopyAsInterface() interface{}
- func (v *Account) Equal(u *Account) bool
- func (v *Account) IsValid() error
- func (v *Account) MarshalBinary() ([]byte, error)
- func (v *Account) MarshalJSON() ([]byte, error)
- func (a *Account) Restore(batch *database.Batch) error
- func (a *Account) RestoreChainHead(batch *database.Batch, c *Chain) (*database.Chain2, error)
- func (v *Account) UnmarshalBinary(data []byte) error
- func (v *Account) UnmarshalBinaryFrom(rd io.Reader) error
- func (v *Account) UnmarshalJSON(data []byte) error
- type AccountVisitor
- type Chain
- func (c *Chain) AddEntry(hash []byte)
- func (v *Chain) Copy() *Chain
- func (v *Chain) CopyAsInterface() interface{}
- func (v *Chain) Equal(u *Chain) bool
- func (v *Chain) IsValid() error
- func (v *Chain) MarshalBinary() ([]byte, error)
- func (v *Chain) MarshalJSON() ([]byte, error)
- func (s *Chain) RestoreElementIndexFromHead(c *database.MerkleManager) error
- func (s *Chain) RestoreElementIndexFromMarkPoints(c *database.MerkleManager, start, end int) error
- func (s *Chain) RestoreHead(c *database.MerkleManager) error
- func (s *Chain) RestoreMarkPointRange(c *database.MerkleManager, start, end int) error
- func (c *Chain) RestoreSnapshot(s *database.MerkleManager) error
- func (v *Chain) UnmarshalBinary(data []byte) error
- func (v *Chain) UnmarshalBinaryFrom(rd io.Reader) error
- func (v *Chain) UnmarshalJSON(data []byte) error
- type CollectOptions
- type HashSet
- type Header
- func (v *Header) Copy() *Header
- func (v *Header) CopyAsInterface() interface{}
- func (v *Header) Equal(u *Header) bool
- func (v *Header) IsValid() error
- func (v *Header) MarshalBinary() ([]byte, error)
- func (v *Header) MarshalJSON() ([]byte, error)
- func (h *Header) ReadFrom(rd io.Reader) (int64, error)
- func (v *Header) UnmarshalBinary(data []byte) error
- func (v *Header) UnmarshalBinaryFrom(rd io.Reader) error
- func (v *Header) UnmarshalJSON(data []byte) error
- func (h *Header) WriteTo(wr io.Writer) (int64, error)
- type HeaderVisitor
- type OldChain
- func (v *OldChain) Copy() *OldChain
- func (v *OldChain) CopyAsInterface() interface{}
- func (v *OldChain) Equal(u *OldChain) bool
- func (v *OldChain) IsValid() error
- func (v *OldChain) MarshalBinary() ([]byte, error)
- func (v *OldChain) MarshalJSON() ([]byte, error)
- func (v *OldChain) UnmarshalBinary(data []byte) error
- func (v *OldChain) UnmarshalBinaryFrom(rd io.Reader) error
- func (v *OldChain) UnmarshalJSON(data []byte) error
- type Reader
- type ReaderSection
- type RestoreVisitor
- type SectionType
- type SectionVisitor
- type Signature
- func (v *Signature) Copy() *Signature
- func (v *Signature) CopyAsInterface() interface{}
- func (v *Signature) Equal(u *Signature) bool
- func (v *Signature) IsValid() error
- func (v *Signature) MarshalBinary() ([]byte, error)
- func (v *Signature) MarshalJSON() ([]byte, error)
- func (s *Signature) Restore(header *Header, batch *database.Batch) error
- func (v *Signature) UnmarshalBinary(data []byte) error
- func (v *Signature) UnmarshalBinaryFrom(rd io.Reader) error
- func (v *Signature) UnmarshalJSON(data []byte) error
- type SignatureVisitor
- type Transaction
- func (v *Transaction) Copy() *Transaction
- func (v *Transaction) CopyAsInterface() interface{}
- func (v *Transaction) Equal(u *Transaction) bool
- func (v *Transaction) IsValid() error
- func (v *Transaction) MarshalBinary() ([]byte, error)
- func (v *Transaction) MarshalJSON() ([]byte, error)
- func (t *Transaction) Restore(header *Header, batch *database.Batch) error
- func (v *Transaction) UnmarshalBinary(data []byte) error
- func (v *Transaction) UnmarshalBinaryFrom(rd io.Reader) error
- func (v *Transaction) UnmarshalJSON(data []byte) error
- type TransactionVisitor
- type TxnSigSet
- func (v *TxnSigSet) Copy() *TxnSigSet
- func (v *TxnSigSet) CopyAsInterface() interface{}
- func (v *TxnSigSet) Equal(u *TxnSigSet) bool
- func (v *TxnSigSet) IsValid() error
- func (v *TxnSigSet) MarshalBinary() ([]byte, error)
- func (v *TxnSigSet) MarshalJSON() ([]byte, error)
- func (v *TxnSigSet) UnmarshalBinary(data []byte) error
- func (v *TxnSigSet) UnmarshalBinaryFrom(rd io.Reader) error
- func (v *TxnSigSet) UnmarshalJSON(data []byte) error
- type Writer
- func (w *Writer) CollectAccounts(batch *database.Batch, opts CollectOptions) error
- func (w *Writer) CollectSignatures(batch *database.Batch, hashes [][32]byte, opts CollectOptions) error
- func (w *Writer) CollectTransactions(batch *database.Batch, hashes [][32]byte, opts CollectOptions) error
- func (w *Writer) WriteTransactions(txns []*Transaction, gz bool) error
Constants ¶
View Source
const ( SectionTypeHeader = snapshot.SectionTypeHeader SectionTypeAccounts = snapshot.SectionTypeAccountsV1 SectionTypeTransactions = snapshot.SectionTypeTransactionsV1 SectionTypeSignatures = snapshot.SectionTypeSignaturesV1 SectionTypeGzTransactions = snapshot.SectionTypeGzTransactionsV1 SectionTypeSnapshot = snapshot.SectionTypeSnapshot )
View Source
const Version1 = 1
Variables ¶
View Source
var ErrSkip = stderrs.New("skip")
ErrSkip is returned by SectionVisitor.VisitSection to skip a section.
Functions ¶
func CollectAnchors ¶
CollectAnchors collects anchors from the anchor ledger's anchor sequence chain.
func FullCollect ¶
func FullCollect(batch *database.Batch, file io.WriteSeeker, network config.NetworkUrl, logger log.Logger, preserve bool) error
FullCollect collects a snapshot including additional records required for a fully-functioning node.
func FullRestore ¶
func FullRestore(db database.Beginner, file ioutil2.SectionReader, logger log.Logger, network *config.Describe) error
FullRestore restores the snapshot and rebuilds indices.
func Open ¶
func Open(file ioutil2.SectionReader) (*Header, *Reader, error)
Open reads a snapshot file, returning the header values and a reader.
func Visit ¶
func Visit(file ioutil2.SectionReader, visitor interface{}) error
Types ¶
type Account ¶
type Account struct { Hash [32]byte // Main is the main state of the account. Main protocol.Account `json:"main,omitempty" form:"main" query:"main" validate:"required"` // OldChains is deprecated. Use Chains instead. OldChains []*OldChain `json:"oldChains,omitempty" form:"oldChains" query:"oldChains" validate:"required"` // Pending is the state of the account's pending transactions. Pending []*url.TxID `json:"pending,omitempty" form:"pending" query:"pending" validate:"required"` // Directory lists the account's sub-accounts. Directory []*url.URL `json:"directory,omitempty" form:"directory" query:"directory" validate:"required"` // Url is the URL of the account. Url *url.URL `json:"url,omitempty" form:"url" query:"url" validate:"required"` // Chains is the state of the account's chains. Chains []*Chain `json:"chains,omitempty" form:"chains" query:"chains" validate:"required"` // contains filtered or unexported fields }
func CollectAccount ¶
func (*Account) ConvertOldChains ¶
ConvertOldChains converts OldChains to Chains.
func (*Account) CopyAsInterface ¶
func (v *Account) CopyAsInterface() interface{}
func (*Account) MarshalBinary ¶
func (*Account) MarshalJSON ¶
func (*Account) RestoreChainHead ¶
func (*Account) UnmarshalBinary ¶
func (*Account) UnmarshalJSON ¶
type AccountVisitor ¶
type Chain ¶ added in v1.1.0
type Chain struct { Name string `json:"name,omitempty" form:"name" query:"name" validate:"required"` Type merkle.ChainType `json:"type,omitempty" form:"type" query:"type" validate:"required"` MarkPower uint64 `json:"markPower,omitempty" form:"markPower" query:"markPower" validate:"required"` Head *merkle.State `json:"head,omitempty" form:"head" query:"head" validate:"required"` MarkPoints []*merkle.State `json:"markPoints,omitempty" form:"markPoints" query:"markPoints" validate:"required"` // contains filtered or unexported fields }
func CollectChain ¶ added in v1.1.0
func CollectChain(c *database.MerkleManager) (*Chain, error)
func (*Chain) AddEntry ¶ added in v1.1.0
AddEntry adds an entry to the snapshot as if it were added to the chain. AddEntry's logic must mirror MerkleManager.AddHash.
func (*Chain) CopyAsInterface ¶ added in v1.1.0
func (v *Chain) CopyAsInterface() interface{}
func (*Chain) MarshalBinary ¶ added in v1.1.0
func (*Chain) MarshalJSON ¶ added in v1.1.0
func (*Chain) RestoreElementIndexFromHead ¶ added in v1.1.0
func (s *Chain) RestoreElementIndexFromHead(c *database.MerkleManager) error
func (*Chain) RestoreElementIndexFromMarkPoints ¶ added in v1.1.0
func (s *Chain) RestoreElementIndexFromMarkPoints(c *database.MerkleManager, start, end int) error
func (*Chain) RestoreHead ¶ added in v1.1.0
func (s *Chain) RestoreHead(c *database.MerkleManager) error
func (*Chain) RestoreMarkPointRange ¶ added in v1.1.0
func (s *Chain) RestoreMarkPointRange(c *database.MerkleManager, start, end int) error
func (*Chain) RestoreSnapshot ¶ added in v1.1.0
func (c *Chain) RestoreSnapshot(s *database.MerkleManager) error
func (*Chain) UnmarshalBinary ¶ added in v1.1.0
func (*Chain) UnmarshalBinaryFrom ¶ added in v1.1.0
func (*Chain) UnmarshalJSON ¶ added in v1.1.0
type CollectOptions ¶ added in v1.1.0
type CollectOptions struct { Logger log.Logger VisitAccount func(acct *Account) error VisitTransaction func(txn *Transaction) error VisitSignature func(sig *Signature) error // PreserveAccountHistory is called for each account to test if the // account's transaction history should be preserved. If // PreserveAccountHistory is unspecified, all account history is preserved. PreserveAccountHistory func(account *database.Account) (bool, error) }
type Header ¶
type Header struct { // Version is the snapshot format version. Version uint64 `json:"version,omitempty" form:"version" query:"version" validate:"required"` // Height is the snapshot's block height. Height uint64 `json:"height,omitempty" form:"height" query:"height" validate:"required"` // RootHash is the snapshot's root hash. RootHash [32]byte `json:"rootHash,omitempty" form:"rootHash" query:"rootHash" validate:"required"` // Timestamp is the snapshot's block time. Timestamp time.Time `json:"timestamp,omitempty" form:"timestamp" query:"timestamp" validate:"required"` // ExecutorVersion is the snapshot's executor version. ExecutorVersion protocol.ExecutorVersion `json:"executorVersion,omitempty" form:"executorVersion" query:"executorVersion" validate:"required"` // PartitionSnapshotIDs is the ID of the parttions of sub-snapshots. PartitionSnapshotIDs []string `json:"partitionSnapshotIDs,omitempty" form:"partitionSnapshotIDs" query:"partitionSnapshotIDs" validate:"required"` // contains filtered or unexported fields }
func (*Header) CopyAsInterface ¶
func (v *Header) CopyAsInterface() interface{}
func (*Header) MarshalBinary ¶
func (*Header) MarshalJSON ¶
func (*Header) UnmarshalBinary ¶
func (*Header) UnmarshalJSON ¶
type HeaderVisitor ¶ added in v1.1.0
type OldChain ¶
type OldChain struct { Name string `json:"name,omitempty" form:"name" query:"name" validate:"required"` Type protocol.ChainType `json:"type,omitempty" form:"type" query:"type" validate:"required"` Count uint64 `json:"count,omitempty" form:"count" query:"count" validate:"required"` Pending [][]byte `json:"pending,omitempty" form:"pending" query:"pending" validate:"required"` Entries [][]byte `json:"entries,omitempty" form:"entries" query:"entries" validate:"required"` // contains filtered or unexported fields }
func (*OldChain) CopyAsInterface ¶
func (v *OldChain) CopyAsInterface() interface{}
func (*OldChain) MarshalBinary ¶
func (*OldChain) MarshalJSON ¶
func (*OldChain) UnmarshalBinary ¶
func (*OldChain) UnmarshalJSON ¶
type Reader ¶
type Reader struct { ioutil.SegmentedReader[SectionType, *SectionType] }
func NewReader ¶
func NewReader(file ioutil2.SectionReader) *Reader
type ReaderSection ¶
type ReaderSection = ioutil.Segment[SectionType, *SectionType]
type RestoreVisitor ¶
type RestoreVisitor struct { DisableWriteBatching bool CompressChains bool // contains filtered or unexported fields }
RestoreVisitor is a visitor that restores accounts, transactions, and signatures.
func NewRestoreVisitor ¶
func NewRestoreVisitor(db database.Beginner, logger log.Logger) *RestoreVisitor
func (*RestoreVisitor) VisitAccount ¶
func (v *RestoreVisitor) VisitAccount(acct *Account, i int) error
func (*RestoreVisitor) VisitHeader ¶ added in v1.1.0
func (v *RestoreVisitor) VisitHeader(h *Header) error
func (*RestoreVisitor) VisitSignature ¶
func (v *RestoreVisitor) VisitSignature(sig *Signature, i int) error
func (*RestoreVisitor) VisitTransaction ¶
func (v *RestoreVisitor) VisitTransaction(txn *Transaction, i int) error
type SectionType ¶
type SectionType = snapshot.SectionType
type SectionVisitor ¶
type SectionVisitor interface{ VisitSection(*ReaderSection) error }
type Signature ¶
type Signature struct { Txid *url.TxID `json:"txid,omitempty" form:"txid" query:"txid" validate:"required"` Signature protocol.Signature `json:"signature,omitempty" form:"signature" query:"signature" validate:"required"` // contains filtered or unexported fields }
func CollectSignature ¶
func (*Signature) CopyAsInterface ¶
func (v *Signature) CopyAsInterface() interface{}
func (*Signature) MarshalBinary ¶
func (*Signature) MarshalJSON ¶
func (*Signature) UnmarshalBinary ¶
func (*Signature) UnmarshalJSON ¶
type SignatureVisitor ¶
type Transaction ¶
type Transaction struct { Transaction *protocol.Transaction `json:"transaction,omitempty" form:"transaction" query:"transaction" validate:"required"` Status *protocol.TransactionStatus `json:"status,omitempty" form:"status" query:"status" validate:"required"` SignatureSets []*TxnSigSet `json:"signatureSets,omitempty" form:"signatureSets" query:"signatureSets" validate:"required"` // contains filtered or unexported fields }
func CollectTransaction ¶
func CollectTransaction(batch *database.Batch, hash [32]byte) (*Transaction, error)
func (*Transaction) Copy ¶
func (v *Transaction) Copy() *Transaction
func (*Transaction) CopyAsInterface ¶
func (v *Transaction) CopyAsInterface() interface{}
func (*Transaction) Equal ¶
func (v *Transaction) Equal(u *Transaction) bool
func (*Transaction) IsValid ¶
func (v *Transaction) IsValid() error
func (*Transaction) MarshalBinary ¶
func (v *Transaction) MarshalBinary() ([]byte, error)
func (*Transaction) MarshalJSON ¶
func (v *Transaction) MarshalJSON() ([]byte, error)
func (*Transaction) Restore ¶
func (t *Transaction) Restore(header *Header, batch *database.Batch) error
func (*Transaction) UnmarshalBinary ¶
func (v *Transaction) UnmarshalBinary(data []byte) error
func (*Transaction) UnmarshalBinaryFrom ¶
func (v *Transaction) UnmarshalBinaryFrom(rd io.Reader) error
func (*Transaction) UnmarshalJSON ¶
func (v *Transaction) UnmarshalJSON(data []byte) error
type TransactionVisitor ¶
type TransactionVisitor interface{ VisitTransaction(*Transaction, int) error }
type TxnSigSet ¶
type TxnSigSet struct { Signer *url.URL `json:"signer,omitempty" form:"signer" query:"signer" validate:"required"` Version uint64 `json:"version,omitempty" form:"version" query:"version" validate:"required"` Entries []database.SigSetEntry `json:"entries,omitempty" form:"entries" query:"entries" validate:"required"` // contains filtered or unexported fields }
func (*TxnSigSet) CopyAsInterface ¶
func (v *TxnSigSet) CopyAsInterface() interface{}
func (*TxnSigSet) MarshalBinary ¶
func (*TxnSigSet) MarshalJSON ¶
func (*TxnSigSet) UnmarshalBinary ¶
func (*TxnSigSet) UnmarshalJSON ¶
type Writer ¶
type Writer struct { Logger logging.OptionalLogger ioutil.SegmentedWriter[SectionType, *SectionType] }
func Collect ¶
func Collect(batch *database.Batch, header *Header, file io.WriteSeeker, opts CollectOptions) (*Writer, error)
func NewWriter ¶
func NewWriter(w io.WriteSeeker) *Writer
func (*Writer) CollectAccounts ¶
func (w *Writer) CollectAccounts(batch *database.Batch, opts CollectOptions) error
func (*Writer) CollectSignatures ¶
func (*Writer) CollectTransactions ¶
func (*Writer) WriteTransactions ¶
func (w *Writer) WriteTransactions(txns []*Transaction, gz bool) error
Click to show internal directories.
Click to hide internal directories.