Documentation ¶
Overview ¶
Package ledger provides useful utilities concerning ledgers within stellar, specifically as a central location to store a cached snapshot of the state of both horizon's and stellar-core's views of the ledger. This package is intended to be at the lowest levels of horizon's dependency tree, please keep it free of dependencies to other horizon packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HistoryDBSource ¶
type HistoryDBSource struct {
// contains filtered or unexported fields
}
HistoryDBSource utility struct to pass the SSE update frequency and a function to get the current ledger state.
func NewHistoryDBSource ¶
func NewHistoryDBSource(updateFrequency time.Duration, state *State) *HistoryDBSource
NewHistoryDBSource constructs a new instance of HistoryDBSource
func (*HistoryDBSource) Close ¶
func (source *HistoryDBSource) Close()
Close closes the internal go routines.
func (*HistoryDBSource) CurrentLedger ¶
func (source *HistoryDBSource) CurrentLedger() uint32
CurrentLedger returns the current ledger.
func (*HistoryDBSource) NextLedger ¶
func (source *HistoryDBSource) NextLedger(currentSequence uint32) chan uint32
NextLedger returns a channel which yields every time there is a new ledger with a sequence number larger than currentSequence.
type Source ¶
type Source interface { CurrentLedger() uint32 NextLedger(currentSequence uint32) chan uint32 Close() }
Source exposes two helpers methods to help you find out the current ledger and yield every time there is a new ledger. Call `Close` when source is no longer used.
type State ¶
State is an in-memory data structure which holds a snapshot of both horizon's and stellar-core's view of the the network
func (*State) CurrentStatus ¶
CurrentStatus returns the cached snapshot of ledger state
type Status ¶
type Status struct { CoreLatest int32 `db:"core_latest"` HistoryLatest int32 `db:"history_latest"` HistoryLatestClosedAt time.Time `db:"history_latest_closed_at"` HistoryElder int32 `db:"history_elder"` ExpHistoryLatest uint32 `db:"exp_history_latest"` }
Status represents a snapshot of both horizon's and stellar-core's view of the ledger.
type TestingSource ¶
type TestingSource struct {
// contains filtered or unexported fields
}
TestingSource is helper struct which implements the LedgerSource interface.
func NewTestingSource ¶
func NewTestingSource(currentLedger uint32) *TestingSource
NewTestingSource returns a TestingSource.
func (*TestingSource) AddLedger ¶
func (source *TestingSource) AddLedger(nextSequence uint32)
AddLedger adds a new sequence to the newLedgers channel. AddLedger() will block until the new sequence is read
func (*TestingSource) Close ¶
func (source *TestingSource) Close()
func (*TestingSource) CurrentLedger ¶
func (source *TestingSource) CurrentLedger() uint32
CurrentLedger returns the current ledger.
func (*TestingSource) NextLedger ¶
func (source *TestingSource) NextLedger(currentSequence uint32) chan uint32
NextLedger returns a channel which yields every time there is a new ledger.