ledger

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

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 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 ChainsyncState added in v0.12.0

type ChainsyncState string
const (
	InitChainsyncState     ChainsyncState = "init"
	RollbackChainsyncState ChainsyncState = "rollback"
	SyncingChainsyncState  ChainsyncState = "syncing"
)

type LedgerDelta added in v0.7.0

type LedgerDelta struct {
	Point             ocommon.Point
	Produced          []lcommon.Utxo
	Consumed          []lcommon.TransactionInput
	PParamUpdateEpoch uint64
	PParamUpdates     map[lcommon.Blake2b224]lcommon.ProtocolParameterUpdate
	Certificates      []lcommon.Certificate
}

type LedgerDeltaBatch added in v0.8.0

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

type LedgerState

type LedgerState struct {
	sync.RWMutex

	Scheduler *Scheduler
	// contains filtered or unexported fields
}

func NewLedgerState

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

func (*LedgerState) Chain

func (ls *LedgerState) Chain() *chain.Chain

func (*LedgerState) Close

func (ls *LedgerState) Close() error

func (*LedgerState) EvaluateTx added in v0.16.0

EvaluateTx evaluates the scripts in the provided transaction and returns the calculated fee, per-redeemer ExUnits, and total ExUnits

func (*LedgerState) GetBlock

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

func (*LedgerState) GetChainFromPoint

func (ls *LedgerState) GetChainFromPoint(
	point ocommon.Point,
	inclusive bool,
) (*chain.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

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

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) RecoverCommitTimestampConflict added in v0.11.0

func (ls *LedgerState) RecoverCommitTimestampConflict() error

func (*LedgerState) SetMempool added in v0.14.1

func (ls *LedgerState) SetMempool(mempool MempoolProvider)

Sets the mempool for accessing transactions

func (*LedgerState) SlotToEpoch added in v0.6.0

func (ls *LedgerState) SlotToEpoch(slot uint64) (database.Epoch, error)

SlotToEpoch returns a known epoch by slot number

func (*LedgerState) SlotToTime added in v0.6.0

func (ls *LedgerState) SlotToTime(slot uint64) (time.Time, error)

SlotToTime returns the current time for a given slot based on known epochs

func (*LedgerState) Start added in v0.11.0

func (ls *LedgerState) Start() error

func (*LedgerState) TimeToSlot added in v0.6.0

func (ls *LedgerState) TimeToSlot(t time.Time) (uint64, error)

TimeToSlot returns the slot number for a given time based on known epochs

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,
) (database.Utxo, error)

UtxoByRef returns a single UTxO by reference

func (*LedgerState) UtxosByAddress

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

UtxosByAddress returns all UTxOs that belong to the specified address

func (*LedgerState) ValidateTx

func (ls *LedgerState) ValidateTx(
	tx lcommon.Transaction,
) error

ValidateTx runs ledger validation on the provided transaction

type LedgerStateConfig

type LedgerStateConfig struct {
	Logger             *slog.Logger
	Database           *database.Database
	ChainManager       *chain.ChainManager
	EventBus           *event.EventBus
	CardanoNodeConfig  *cardano.CardanoNodeConfig
	PromRegistry       prometheus.Registerer
	ValidateHistorical bool
	ForgeBlocks        bool
	// Callback(s)
	BlockfetchRequestRangeFunc BlockfetchRequestRangeFunc
}

type LedgerView

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

func (*LedgerView) NetworkId

func (lv *LedgerView) NetworkId() uint

func (*LedgerView) PoolCurrentState added in v0.17.0

func (lv *LedgerView) PoolCurrentState(
	pkh []byte,
) (*lcommon.PoolRegistrationCertificate, *uint64, error)

It returns the most recent active pool registration certificate and the epoch of any pending retirement for the given pool key hash.

func (*LedgerView) PoolRegistration

func (lv *LedgerView) PoolRegistration(
	pkh []byte,
) ([]lcommon.PoolRegistrationCertificate, error)

func (*LedgerView) SlotToTime added in v0.17.0

func (lv *LedgerView) SlotToTime(slot uint64) (time.Time, error)

SlotToTime returns the current time for a given slot based on known epochs

func (*LedgerView) StakeRegistration

func (lv *LedgerView) StakeRegistration(
	stakingKey []byte,
) ([]lcommon.StakeRegistrationCertificate, error)

func (*LedgerView) TimeToSlot added in v0.17.0

func (lv *LedgerView) TimeToSlot(t time.Time) (uint64, error)

TimeToSlot returns the slot number for a given time based on known epochs

func (*LedgerView) UtxoById

func (lv *LedgerView) UtxoById(
	utxoId lcommon.TransactionInput,
) (lcommon.Utxo, error)

type MempoolProvider added in v0.14.1

type MempoolProvider interface {
	Transactions() []mempool.MempoolTransaction
}

In ledger/state.go or a shared package

type ScheduledTask added in v0.14.1

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

type Scheduler added in v0.14.1

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

func NewScheduler added in v0.14.1

func NewScheduler(interval time.Duration) *Scheduler

func (*Scheduler) ChangeInterval added in v0.14.1

func (st *Scheduler) ChangeInterval(newInterval time.Duration)

ChangeInterval updates the tick interval of the Scheduler at runtime.

func (*Scheduler) Register added in v0.14.1

func (st *Scheduler) Register(
	interval int,
	taskFunc func(),
	runFailFunc func(),
)

Adds a new task to be scheduler

func (*Scheduler) Start added in v0.14.1

func (st *Scheduler) Start()

Start the timer (run goroutine once)

func (*Scheduler) Stop added in v0.14.1

func (st *Scheduler) Stop()

Stop the timer (terminates)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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