Documentation ¶
Index ¶
- Variables
- type ArchiveLedgerReader
- type Change
- type DBLedgerReader
- type LedgerReader
- type LedgerTransaction
- type LedgerWriter
- type MemoryTempSet
- type MockLedgerReader
- type MockLedgerWriter
- type MockStateReader
- type MockStateWriter
- type PostgresTempSet
- type SingleLedgerStateReader
- type StateReader
- type StateWriter
- type TempSet
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("not found")
Functions ¶
This section is empty.
Types ¶
type ArchiveLedgerReader ¶
type ArchiveLedgerReader interface { GetSequence() uint32 Read() (bool, xdr.Transaction, xdr.TransactionResult, error) }
ArchiveLedgerReader placeholder
type Change ¶
type Change struct { Type xdr.LedgerEntryType Pre *xdr.LedgerEntryData Post *xdr.LedgerEntryData }
Change is a developer friendly representation of LedgerEntryChanges. It also provides some helper functions to quickly check if a given change has occured in an entry.
If an entry is created: Pre is nil and Post is not nil. If an entry is updated: Pre is not nil and Post is not nil. If an entry is removed: Pre is not nil and Post is nil.
func (*Change) AccountSignersChanged ¶
AccountSignersChanged returns true if account signers have changed. Notice: this will return true on master key changes too!
type DBLedgerReader ¶
type DBLedgerReader struct {
// contains filtered or unexported fields
}
DBLedgerReader is a database-backed implementation of the io.LedgerReader interface.
func NewDBLedgerReader ¶
func NewDBLedgerReader(sequence uint32, backend ledgerbackend.LedgerBackend) (*DBLedgerReader, error)
NewDBLedgerReader is a factory method for LedgerReader.
func (*DBLedgerReader) Close ¶
func (dblrc *DBLedgerReader) Close() error
Close moves the read pointer so that subsequent calls to Read() will return EOF.
func (*DBLedgerReader) GetHeader ¶
func (dblrc *DBLedgerReader) GetHeader() xdr.LedgerHeaderHistoryEntry
GetHeader returns the XDR Header data associated with the stored ledger.
func (*DBLedgerReader) GetSequence ¶
func (dblrc *DBLedgerReader) GetSequence() uint32
GetSequence returns the sequence number of the ledger data stored by this object.
func (*DBLedgerReader) Read ¶
func (dblrc *DBLedgerReader) Read() (LedgerTransaction, error)
Read returns the next transaction in the ledger, ordered by tx number, each time it is called. When there are no more transactions to return, an EOF error is returned.
type LedgerReader ¶
type LedgerReader interface { GetSequence() uint32 GetHeader() xdr.LedgerHeaderHistoryEntry // Read should return the next transaction. If there are no more // transactions it should return `io.EOF` error. Read() (LedgerTransaction, error) // Close should be called when reading is finished. This is especially // helpful when there are still some transactions available so reader can stop // streaming them. Close() error }
LedgerReader provides convenient, streaming access to the transactions within a ledger.
type LedgerTransaction ¶
type LedgerTransaction struct { Index uint32 Envelope xdr.TransactionEnvelope Result xdr.TransactionResultPair Meta xdr.TransactionMeta FeeChanges xdr.LedgerEntryChanges }
LedgerTransaction represents the data for a single transaction within a ledger.
func (*LedgerTransaction) GetChanges ¶
func (t *LedgerTransaction) GetChanges() []Change
GetChanges returns a developer friendly representation of LedgerEntryChanges. It contains fee changes, transaction changes and operation changes in that order.
type LedgerWriter ¶
type LedgerWriter interface { // Write is used to pass a transaction to the next processor. It can return // `io.ErrClosedPipe` when the pipe between processors has been closed meaning // that next processor does not need more data. In such situation the current // processor can terminate as sending more transactions to a `LedgerWriter` // does not make sense (will not be read). Write(LedgerTransaction) error // Close should be called when reading is finished. This is especially // helpful when there are still some transactions available so the reader can stop // streaming them. Close() error }
LedgerWriter provides convenient, streaming access to the transactions within a ledger.
type MemoryTempSet ¶
type MemoryTempSet struct {
// contains filtered or unexported fields
}
MemoryTempSet is an in-memory implementation of TempSet interface. As of July 2019 this requires up to ~4GB of memory for pubnet ledger state processing. The internal structure is dereferenced after the store is closed.
func (*MemoryTempSet) Add ¶
func (s *MemoryTempSet) Add(key string) error
Add adds a key to TempSet.
func (*MemoryTempSet) Close ¶
func (s *MemoryTempSet) Close() error
Close removes reference to internal data structure.
func (*MemoryTempSet) Exist ¶
func (s *MemoryTempSet) Exist(key string) (bool, error)
Exist check if the key exists in a TempSet.
func (*MemoryTempSet) Open ¶
func (s *MemoryTempSet) Open() error
Open initialize internals data structure.
func (*MemoryTempSet) Preload ¶
func (s *MemoryTempSet) Preload(keys []string) error
Preload does not do anything. This TempSet keeps everything in memory so no preloading needed.
type MockLedgerReader ¶
func (*MockLedgerReader) Close ¶
func (m *MockLedgerReader) Close() error
func (*MockLedgerReader) GetHeader ¶
func (m *MockLedgerReader) GetHeader() xdr.LedgerHeaderHistoryEntry
func (*MockLedgerReader) GetSequence ¶
func (m *MockLedgerReader) GetSequence() uint32
func (*MockLedgerReader) Read ¶
func (m *MockLedgerReader) Read() (LedgerTransaction, error)
type MockLedgerWriter ¶
func (*MockLedgerWriter) Close ¶
func (m *MockLedgerWriter) Close() error
func (*MockLedgerWriter) Write ¶
func (m *MockLedgerWriter) Write(tx LedgerTransaction) error
type MockStateReader ¶
func (*MockStateReader) Close ¶
func (m *MockStateReader) Close() error
func (*MockStateReader) GetSequence ¶
func (m *MockStateReader) GetSequence() uint32
func (*MockStateReader) Read ¶
func (m *MockStateReader) Read() (xdr.LedgerEntryChange, error)
type MockStateWriter ¶
func (*MockStateWriter) Close ¶
func (m *MockStateWriter) Close() error
func (*MockStateWriter) Write ¶
func (m *MockStateWriter) Write(entryChange xdr.LedgerEntryChange) error
type PostgresTempSet ¶
type PostgresTempSet struct { DSN string Session *db.Session // contains filtered or unexported fields }
PostgresTempSet is a postgres implementation of TempSet interface. It's around 4x slower than MemoryStateReaderTempStore but has much lower memory requirements. `postgresTempSetCacheSize` can be changed to achieve better speed at the cost of higher memory usage. If `DSN` is passed, a new `db.Session` will be created. If `Session` is passed, it will be cloned.
func (*PostgresTempSet) Add ¶
func (s *PostgresTempSet) Add(key string) error
Add adds a key to TempSet.
func (*PostgresTempSet) Close ¶
func (s *PostgresTempSet) Close() error
Close closes a database connection what also removes a temporary table.
func (*PostgresTempSet) Exist ¶
func (s *PostgresTempSet) Exist(key string) (bool, error)
Exist check if the key exists in a TempSet.
func (*PostgresTempSet) Open ¶
func (s *PostgresTempSet) Open() error
Open connects to a DB and creates a temporary table and data structures.
func (*PostgresTempSet) Preload ¶
func (s *PostgresTempSet) Preload(keys []string) error
Preload preloads `keys` from a database. It ignores the keys that are already in cache because these are the most recent values.
type SingleLedgerStateReader ¶
type SingleLedgerStateReader struct {
// contains filtered or unexported fields
}
SingleLedgerStateReader is a streaming implementation that reads ledger entries from buckets for a given HistoryArchiveState (single ledger/checkpoint). SingleLedgerStateReader hides internal structure of buckets from the user so entries returned by `Read()` are exactly the ledger entries present at the given ledger.
func MakeSingleLedgerStateReader ¶
func MakeSingleLedgerStateReader( archive historyarchive.ArchiveInterface, tempStore TempSet, sequence uint32, bufferSize uint16, ) (*SingleLedgerStateReader, error)
MakeSingleLedgerStateReader is a factory method for SingleLedgerStateReader
func (*SingleLedgerStateReader) Close ¶
func (msr *SingleLedgerStateReader) Close() error
Close should be called when reading is finished.
func (*SingleLedgerStateReader) GetSequence ¶
func (msr *SingleLedgerStateReader) GetSequence() uint32
GetSequence impl.
func (*SingleLedgerStateReader) Read ¶
func (msr *SingleLedgerStateReader) Read() (xdr.LedgerEntryChange, error)
Read returns a new ledger entry change on each call, returning io.EOF when the stream ends.
type StateReader ¶
type StateReader interface { // GetSequence returns the checkpoint ledger sequence this reader is // reading. GetSequence() uint32 // Read should return next ledger entry. If there are no more // entries it should return `io.EOF` error. Read() (xdr.LedgerEntryChange, error) // Close should be called when reading is finished. This is especially // helpful when there are still some entries available so reader can stop // streaming them. Close() error }
StateReader reads state data from history archive buckets for a single checkpoint ledger / HAS.
type StateWriter ¶
type StateWriter interface { // Write is used to pass ledger entry change to the next processor. It can return // `ErrClosedPipe` when the pipe between processors has been closed meaning // that next processor does not need more data. In such situation the current // processor can terminate as sending more entries to a `StateWriter` // does not make sense (will not be read). Write(xdr.LedgerEntryChange) error // Close should be called when there are no more entries // to write. Close() error }
StateWriter interface placeholder
type TempSet ¶
type TempSet interface { Open() error // Preload batch-loads keys into internal cache (if a store has any) to // improve execution time by removing many round-trips. Preload(keys []string) error // Add adds key to the store. Add(key string) error // Exist returns value true if the value is found in the store. // If the value has not been set, it should return false. Exist(key string) (bool, error) Close() error }
TempSet is an interface that must be implemented by stores that hold temporary set of objects for state reader. The implementation does not need to be thread-safe.