ledger

package
v0.0.0-...-13e2633 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

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

func SetState

func SetState(next State)

SetState updates the cached snapshot of the ledger state

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) *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

type State struct {
	CoreLatest       int32  `db:"core_latest"`
	HistoryLatest    int32  `db:"history_latest"`
	HistoryElder     int32  `db:"history_elder"`
	ExpHistoryLatest uint32 `db:"exp_history_latest"`
}

State represents a snapshot of both horizon's and stellar-core's view of the ledger.

func CurrentState

func CurrentState() State

CurrentState returns the cached snapshot of ledger state

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.

Jump to

Keyboard shortcuts

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