Documentation
¶
Index ¶
- Constants
- type BlockfetchEvent
- type BlockfetchRequestRangeFunc
- type ChainsyncEvent
- type ChainsyncState
- type DatabaseOperation
- type DatabaseResult
- type DatabaseWorkerPool
- type DatabaseWorkerPoolConfig
- type LedgerDelta
- type LedgerDeltaBatch
- type LedgerState
- func (ls *LedgerState) Chain() *chain.Chain
- func (ls *LedgerState) Close() error
- func (ls *LedgerState) Datum(hash []byte) (*models.Datum, error)
- func (ls *LedgerState) EvaluateTx(tx lcommon.Transaction) (uint64, lcommon.ExUnits, map[lcommon.RedeemerKey]lcommon.ExUnits, error)
- func (ls *LedgerState) GetBlock(point ocommon.Point) (models.Block, error)
- func (ls *LedgerState) GetChainFromPoint(point ocommon.Point, inclusive bool) (*chain.ChainIterator, error)
- func (ls *LedgerState) GetCurrentPParams() lcommon.ProtocolParameters
- func (ls *LedgerState) GetIntersectPoint(points []ocommon.Point) (*ocommon.Point, error)
- func (ls *LedgerState) Query(query any) (any, error)
- func (ls *LedgerState) RecentChainPoints(count int) ([]ocommon.Point, error)
- func (ls *LedgerState) RecoverCommitTimestampConflict() error
- func (ls *LedgerState) SetMempool(mempool MempoolProvider)
- func (ls *LedgerState) SlotToEpoch(slot uint64) (models.Epoch, error)
- func (ls *LedgerState) SlotToTime(slot uint64) (time.Time, error)
- func (ls *LedgerState) Start() error
- func (ls *LedgerState) SubmitAsyncDBOperation(opFunc func(db *database.Database) error) error
- func (ls *LedgerState) SubmitAsyncDBReadTxn(opFunc func(txn *database.Txn) error) error
- func (ls *LedgerState) SubmitAsyncDBTxn(opFunc func(txn *database.Txn) error, readWrite bool) error
- func (ls *LedgerState) TimeToSlot(t time.Time) (uint64, error)
- func (ls *LedgerState) Tip() ochainsync.Tip
- func (ls *LedgerState) UtxoByRef(txId []byte, outputIdx uint32) (*models.Utxo, error)
- func (ls *LedgerState) UtxosByAddress(addr ledger.Address) ([]models.Utxo, error)
- func (ls *LedgerState) ValidateTx(tx lcommon.Transaction) error
- type LedgerStateConfig
- type LedgerView
- func (lv *LedgerView) CalculateRewards(adaPots lcommon.AdaPots, rewardSnapshot lcommon.RewardSnapshot, ...) (*lcommon.RewardCalculationResult, error)
- func (lv *LedgerView) GetAdaPots() lcommon.AdaPots
- func (lv *LedgerView) GetRewardSnapshot(epoch uint64) (lcommon.RewardSnapshot, error)
- func (lv *LedgerView) NetworkId() uint
- func (lv *LedgerView) PoolCurrentState(pkh lcommon.PoolKeyHash) (*lcommon.PoolRegistrationCertificate, *uint64, error)
- func (lv *LedgerView) PoolRegistration(pkh lcommon.PoolKeyHash) ([]lcommon.PoolRegistrationCertificate, error)
- func (lv *LedgerView) SlotToTime(slot uint64) (time.Time, error)
- func (lv *LedgerView) StakeRegistration(stakingKey []byte) ([]lcommon.StakeRegistrationCertificate, error)
- func (lv *LedgerView) TimeToSlot(t time.Time) (uint64, error)
- func (lv *LedgerView) UpdateAdaPots(adaPots lcommon.AdaPots) error
- func (lv *LedgerView) UtxoById(utxoId lcommon.TransactionInput) (lcommon.Utxo, error)
- type MempoolProvider
- type ScheduledTask
- type Scheduler
- type SchedulerConfig
- type TransactionRecord
Constants ¶
const ( BlockfetchEventType event.EventType = "blockfetch.event" ChainsyncEventType event.EventType = "chainsync.event" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockfetchEvent ¶
type BlockfetchEvent struct {
ConnectionId ouroboros.ConnectionId // Connection ID associated with event
Block ledger.Block
Point ocommon.Point // Chain point for 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 ¶
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
BlockHeader ledger.BlockHeader
Point ocommon.Point // Chain point for roll forward/backward
Tip ochainsync.Tip // Upstream chain tip
BlockNumber uint64
Type uint // Block or header type ID
Rollback bool // Set to true for a Rollback event
}
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 DatabaseOperation ¶ added in v0.19.0
type DatabaseOperation struct {
// Operation function that performs the database work
OpFunc func(db *database.Database) error
// Channel to send the result back. Must be non-nil and buffered to avoid blocking.
// If nil, the operation will be executed but the result will be discarded (fire and forget).
ResultChan chan<- DatabaseResult
}
DatabaseOperation represents an asynchronous database operation
type DatabaseResult ¶ added in v0.19.0
type DatabaseResult struct {
Error error
}
DatabaseResult represents the result of a database operation
type DatabaseWorkerPool ¶ added in v0.19.0
type DatabaseWorkerPool struct {
// contains filtered or unexported fields
}
DatabaseWorkerPool manages a pool of workers for async database operations
func NewDatabaseWorkerPool ¶ added in v0.19.0
func NewDatabaseWorkerPool( db *database.Database, config DatabaseWorkerPoolConfig, ) *DatabaseWorkerPool
NewDatabaseWorkerPool creates a new database worker pool
func (*DatabaseWorkerPool) Shutdown ¶ added in v0.19.0
func (p *DatabaseWorkerPool) Shutdown()
Shutdown gracefully shuts down the worker pool
func (*DatabaseWorkerPool) Submit ¶ added in v0.19.0
func (p *DatabaseWorkerPool) Submit(op DatabaseOperation)
Submit submits a database operation for async execution
type DatabaseWorkerPoolConfig ¶ added in v0.19.0
DatabaseWorkerPoolConfig holds configuration for the database worker pool
func DefaultDatabaseWorkerPoolConfig ¶ added in v0.19.0
func DefaultDatabaseWorkerPoolConfig() DatabaseWorkerPoolConfig
DefaultDatabaseWorkerPoolConfig returns the default configuration for the database worker pool
type LedgerDelta ¶ added in v0.7.0
type LedgerDelta struct {
Point ocommon.Point
BlockEraId uint
Transactions []TransactionRecord
// contains filtered or unexported fields
}
func NewLedgerDelta ¶ added in v0.18.0
func NewLedgerDelta(point ocommon.Point, blockEraId uint) *LedgerDelta
func (*LedgerDelta) Release ¶ added in v0.18.0
func (d *LedgerDelta) Release()
type LedgerDeltaBatch ¶ added in v0.8.0
type LedgerDeltaBatch struct {
// contains filtered or unexported fields
}
func NewLedgerDeltaBatch ¶ added in v0.18.0
func NewLedgerDeltaBatch() *LedgerDeltaBatch
func (*LedgerDeltaBatch) Release ¶ added in v0.18.0
func (b *LedgerDeltaBatch) Release()
type LedgerState ¶
type LedgerState struct {
Scheduler *Scheduler
sync.RWMutex
// 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) Datum ¶ added in v0.18.0
func (ls *LedgerState) Datum(hash []byte) (*models.Datum, error)
Datum looks up a datum by hash & adding this for implementing query.ReadData #741
func (*LedgerState) EvaluateTx ¶ added in v0.16.0
func (ls *LedgerState) EvaluateTx( tx lcommon.Transaction, ) (uint64, lcommon.ExUnits, map[lcommon.RedeemerKey]lcommon.ExUnits, error)
EvaluateTx evaluates the scripts in the provided transaction and returns the calculated fee, per-redeemer ExUnits, and total ExUnits
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 ¶
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) RecoverCommitTimestampConflict ¶ added in v0.11.0
func (ls *LedgerState) RecoverCommitTimestampConflict() error
func (*LedgerState) SetMempool ¶ added in v0.14.0
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) (models.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) SubmitAsyncDBOperation ¶ added in v0.19.0
func (ls *LedgerState) SubmitAsyncDBOperation( opFunc func(db *database.Database) error, ) error
SubmitAsyncDBOperation submits a database operation for execution on the worker pool. This method blocks waiting for the result and must be called after Start() and before Close(). If the worker pool is disabled, it falls back to synchronous execution.
func (*LedgerState) SubmitAsyncDBReadTxn ¶ added in v0.19.0
func (ls *LedgerState) SubmitAsyncDBReadTxn( opFunc func(txn *database.Txn) error, ) error
SubmitAsyncDBReadTxn submits a read-only database transaction operation for execution on the worker pool. This method blocks waiting for the result and must be called after Start() and before Close().
func (*LedgerState) SubmitAsyncDBTxn ¶ added in v0.19.0
func (ls *LedgerState) SubmitAsyncDBTxn( opFunc func(txn *database.Txn) error, readWrite bool, ) error
SubmitAsyncDBTxn submits a database transaction operation for execution on the worker pool. This method blocks waiting for the result and must be called after Start() and before Close().
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) UtxosByAddress ¶
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 {
PromRegistry prometheus.Registerer
Logger *slog.Logger
Database *database.Database
ChainManager *chain.ChainManager
EventBus *event.EventBus
CardanoNodeConfig *cardano.CardanoNodeConfig
BlockfetchRequestRangeFunc BlockfetchRequestRangeFunc
ValidateHistorical bool
ForgeBlocks bool
DatabaseWorkerPoolConfig DatabaseWorkerPoolConfig
}
type LedgerView ¶
type LedgerView struct {
// contains filtered or unexported fields
}
func (*LedgerView) CalculateRewards ¶ added in v0.18.0
func (lv *LedgerView) CalculateRewards( adaPots lcommon.AdaPots, rewardSnapshot lcommon.RewardSnapshot, rewardParams lcommon.RewardParameters, ) (*lcommon.RewardCalculationResult, error)
CalculateRewards calculates rewards for the given stake keys
func (*LedgerView) GetAdaPots ¶ added in v0.18.0
func (lv *LedgerView) GetAdaPots() lcommon.AdaPots
GetAdaPots returns the current Ada pots
func (*LedgerView) GetRewardSnapshot ¶ added in v0.18.0
func (lv *LedgerView) GetRewardSnapshot( epoch uint64, ) (lcommon.RewardSnapshot, error)
GetRewardSnapshot returns the current reward snapshot
func (*LedgerView) NetworkId ¶
func (lv *LedgerView) NetworkId() uint
func (*LedgerView) PoolCurrentState ¶ added in v0.17.0
func (lv *LedgerView) PoolCurrentState( pkh lcommon.PoolKeyHash, ) (*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 lcommon.PoolKeyHash, ) ([]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) UpdateAdaPots ¶ added in v0.18.0
func (lv *LedgerView) UpdateAdaPots(adaPots lcommon.AdaPots) error
UpdateAdaPots updates the Ada pots
func (*LedgerView) UtxoById ¶
func (lv *LedgerView) UtxoById( utxoId lcommon.TransactionInput, ) (lcommon.Utxo, error)
type MempoolProvider ¶ added in v0.14.0
type MempoolProvider interface {
Transactions() []mempool.MempoolTransaction
}
In ledger/state.go or a shared package
type ScheduledTask ¶ added in v0.14.0
type ScheduledTask struct {
// contains filtered or unexported fields
}
type Scheduler ¶ added in v0.14.0
type Scheduler struct {
// contains filtered or unexported fields
}
func NewScheduler ¶ added in v0.14.0
func NewSchedulerWithConfig ¶ added in v0.19.0
func NewSchedulerWithConfig( interval time.Duration, config SchedulerConfig, ) *Scheduler
func (*Scheduler) ChangeInterval ¶ added in v0.14.0
ChangeInterval updates the tick interval of the Scheduler at runtime.
type SchedulerConfig ¶ added in v0.19.0
func DefaultSchedulerConfig ¶ added in v0.19.0
func DefaultSchedulerConfig() SchedulerConfig
type TransactionRecord ¶ added in v0.18.0
type TransactionRecord struct {
Tx lcommon.Transaction
Index int
}