state

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChainBlockEventType    = "ledger.chain-block"
	ChainRollbackEventType = "ledger.chain-rollback"
)
View Source
const (
	BlockfetchEventType event.EventType = "blockfetch.event"
	ChainsyncEventType  event.EventType = "chainsync.event"
)

Variables

View Source
var ErrBlockNotFound = errors.New("block not found")

Functions

This section is empty.

Types

type BlockfetchEvent

type BlockfetchEvent struct {
	ConnectionId ouroboros.ConnectionId // Connection ID associated with event
	Point        ocommon.Point          // Chain point for block
	Block        ledger.Block
	Type         uint // Block type ID
	BatchDone    bool // Set to true for a BatchDone event
}

BlockfetchEvent represents either a Block or BatchDone blockfetch event. We use a single event type for both to make synchronization easier.

type BlockfetchRequestRangeFunc

type BlockfetchRequestRangeFunc func(ouroboros.ConnectionId, ocommon.Point, ocommon.Point) error

BlockfetchRequestRangeFunc describes a callback function used to start a blockfetch request for a range of blocks

type ChainBlockEvent

type ChainBlockEvent struct {
	Point ocommon.Point
	Block models.Block
}

type ChainIterator

type ChainIterator struct {
	// contains filtered or unexported fields
}

func (*ChainIterator) Next

func (ci *ChainIterator) Next(blocking bool) (*ChainIteratorResult, error)

type ChainIteratorResult

type ChainIteratorResult struct {
	Point    ocommon.Point
	Block    models.Block
	Rollback bool
}

type ChainRollbackEvent

type ChainRollbackEvent struct {
	Point ocommon.Point
}

type ChainsyncEvent

type ChainsyncEvent struct {
	ConnectionId ouroboros.ConnectionId // Connection ID associated with event
	Point        ocommon.Point          // Chain point for roll forward/backward
	Tip          ochainsync.Tip         // Upstream chain tip
	BlockNumber  uint64
	BlockHeader  ledger.BlockHeader
	Type         uint // Block or header type ID
	Rollback     bool
}

ChainsyncEvent represents either a RollForward or RollBackward chainsync event. We use a single event type for both to make synchronization easier.

type LedgerState

type LedgerState struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewLedgerState

func NewLedgerState(cfg LedgerStateConfig) (*LedgerState, error)

func (*LedgerState) Close

func (ls *LedgerState) Close() error

func (*LedgerState) GetBlock

func (ls *LedgerState) GetBlock(point ocommon.Point) (*models.Block, error)

func (*LedgerState) GetChainFromPoint

func (ls *LedgerState) GetChainFromPoint(
	point ocommon.Point,
	inclusive bool,
) (*ChainIterator, error)

GetChainFromPoint returns a ChainIterator starting at the specified point. If inclusive is true, the iterator will start at the requested point, otherwise it will start at the next block.

func (*LedgerState) GetCurrentPParams added in v0.3.0

func (ls *LedgerState) GetCurrentPParams() lcommon.ProtocolParameters

GetCurrentPParams returns the currentPParams value

func (*LedgerState) GetIntersectPoint

func (ls *LedgerState) GetIntersectPoint(
	points []ocommon.Point,
) (*ocommon.Point, error)

GetIntersectPoint returns the intersect between the specified points and the current chain

func (*LedgerState) Query added in v0.3.0

func (ls *LedgerState) Query(query any) (any, error)

func (*LedgerState) RecentChainPoints

func (ls *LedgerState) RecentChainPoints(count int) ([]ocommon.Point, error)

RecentChainPoints returns the requested count of recent chain points in descending order. This is used mostly for building a set of intersect points when acting as a chainsync client

func (*LedgerState) Tip

func (ls *LedgerState) Tip() ochainsync.Tip

Tip returns the current chain tip

func (*LedgerState) UtxoByRef

func (ls *LedgerState) UtxoByRef(
	txId []byte,
	outputIdx uint32,
) (models.Utxo, error)

UtxoByRef returns a single UTxO by reference

func (*LedgerState) UtxosByAddress

func (ls *LedgerState) UtxosByAddress(
	addr ledger.Address,
) ([]models.Utxo, error)

UtxosByAddress returns all UTxOs that belong to the specified address

type LedgerStateConfig

type LedgerStateConfig struct {
	Logger            *slog.Logger
	DataDir           string
	EventBus          *event.EventBus
	CardanoNodeConfig *cardano.CardanoNodeConfig
	PromRegistry      prometheus.Registerer
	// Callback(s)
	BlockfetchRequestRangeFunc BlockfetchRequestRangeFunc
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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