Documentation ¶
Index ¶
- Constants
- Variables
- func CollectAnchors(w *Writer, batch *database.Batch, network *config.Describe) error
- func FullCollect(batch *database.Batch, file io.WriteSeeker, network *config.Describe) 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 (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 (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 (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 (c *Chain) Restore(account *database.Account) error
- func (v *Chain) UnmarshalBinary(data []byte) error
- func (v *Chain) UnmarshalBinaryFrom(rd io.Reader) error
- func (v *Chain) UnmarshalJSON(data []byte) error
- type ChainState
- 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 Reader
- type ReaderSection
- type RestoreVisitor
- type SectionType
- type SectionVisitor
- type SectionWriter
- 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(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(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, ...) error
- func (w *Writer) CollectSignatures(batch *database.Batch, hashes [][32]byte, visit func(*Signature) error) error
- func (w *Writer) CollectTransactions(batch *database.Batch, hashes [][32]byte, visit func(*Transaction) error) error
- func (w *Writer) Open(typ SectionType) (*SectionWriter, error)
- func (w *Writer) WriteTransactions(txns []*Transaction, gz bool) error
Constants ¶
const Version1 = 1
Variables ¶
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 ¶
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"` // Chains is the state of the account's chains. Chains []*ChainState `json:"chains,omitempty" form:"chains" query:"chains" 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"` // contains filtered or unexported fields }
func CollectAccount ¶
func (*Account) CopyAsInterface ¶
func (v *Account) CopyAsInterface() interface{}
func (*Account) MarshalBinary ¶
func (*Account) MarshalJSON ¶
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 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 (*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) UnmarshalBinary ¶ added in v1.1.0
func (*Chain) UnmarshalBinaryFrom ¶ added in v1.1.0
func (*Chain) UnmarshalJSON ¶ added in v1.1.0
type ChainState ¶
type ChainState = Chain
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"` // 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 Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
func NewReader ¶
func NewReader(file ioutil2.SectionReader) *Reader
type ReaderSection ¶
type ReaderSection struct {
// contains filtered or unexported fields
}
func (*ReaderSection) Offset ¶
func (s *ReaderSection) Offset() int64
func (*ReaderSection) Open ¶
func (s *ReaderSection) Open() (ioutil2.SectionReader, error)
func (*ReaderSection) Size ¶
func (s *ReaderSection) Size() int64
func (*ReaderSection) Type ¶
func (s *ReaderSection) Type() 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) 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 uint64
const SectionTypeAccounts SectionType = 2
SectionTypeAccounts .
const SectionTypeGzTransactions SectionType = 5
SectionTypeGzTransactions .
const SectionTypeHeader SectionType = 1
SectionTypeHeader .
const SectionTypeSignatures SectionType = 4
SectionTypeSignatures .
const SectionTypeTransactions SectionType = 3
SectionTypeTransactions .
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 SectionVisitor ¶
type SectionVisitor interface{ VisitSection(*ReaderSection) error }
type SectionWriter ¶
type SectionWriter struct {
// contains filtered or unexported fields
}
func (*SectionWriter) Close ¶
func (w *SectionWriter) Close() 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 CollectSignature(record *database.Transaction) (*Signature, error)
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(record *database.Transaction) (*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) 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 {
// contains filtered or unexported fields
}
func NewWriter ¶
func NewWriter(w io.WriteSeeker) *Writer
func (*Writer) CollectAccounts ¶
func (*Writer) CollectSignatures ¶
func (*Writer) CollectTransactions ¶
func (*Writer) Open ¶
func (w *Writer) Open(typ SectionType) (*SectionWriter, error)
Open opens a section.
func (*Writer) WriteTransactions ¶
func (w *Writer) WriteTransactions(txns []*Transaction, gz bool) error