Documentation
¶
Index ¶
- Constants
- Variables
- type BlockfetchEvent
- type BlockfetchRequestRangeFunc
- type ChainsyncEvent
- type ChainsyncState
- type LedgerDelta
- type LedgerDeltaBatch
- type LedgerState
- func (ls *LedgerState) Chain() *chain.Chain
- func (ls *LedgerState) Close() error
- func (ls *LedgerState) EvaluateTx(tx lcommon.Transaction) (uint64, lcommon.ExUnits, map[lcommon.RedeemerKey]lcommon.ExUnits, error)
- func (ls *LedgerState) GetBlock(point ocommon.Point) (*database.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) (database.Epoch, error)
- func (ls *LedgerState) SlotToTime(slot uint64) (time.Time, error)
- func (ls *LedgerState) Start() error
- func (ls *LedgerState) TimeToSlot(t time.Time) (uint64, error)
- func (ls *LedgerState) Tip() ochainsync.Tip
- func (ls *LedgerState) UtxoByRef(txId []byte, outputIdx uint32) (database.Utxo, error)
- func (ls *LedgerState) UtxosByAddress(addr ledger.Address) ([]database.Utxo, error)
- func (ls *LedgerState) ValidateTx(tx lcommon.Transaction) error
- type LedgerStateConfig
- type LedgerView
- func (lv *LedgerView) NetworkId() uint
- func (lv *LedgerView) PoolCurrentState(pkh []byte) (*lcommon.PoolRegistrationCertificate, *uint64, error)
- func (lv *LedgerView) PoolRegistration(pkh []byte) ([]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) UtxoById(utxoId lcommon.TransactionInput) (lcommon.Utxo, error)
- type MempoolProvider
- type ScheduledTask
- type Scheduler
Constants ¶
const ( BlockfetchEventType event.EventType = "blockfetch.event" ChainsyncEventType event.EventType = "chainsync.event" )
Variables ¶
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 ¶
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
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.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) 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 { 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 (*Scheduler) ChangeInterval ¶ added in v0.14.1
ChangeInterval updates the tick interval of the Scheduler at runtime.