state

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

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

Variables

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

Functions

This section is empty.

Types

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
	Point        ocommon.Point
	BlockNumber  uint64
	Block        ledger.Block
	BlockHeader  ledger.BlockHeader
	Type         uint
	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) 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) 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) 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
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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