Documentation ¶
Index ¶
- Constants
- Variables
- type BlockfetchEvent
- type BlockfetchRequestRangeFunc
- type ChainBlockEvent
- type ChainIterator
- type ChainIteratorResult
- type ChainRollbackEvent
- type ChainsyncEvent
- type LedgerState
- func (ls *LedgerState) Close() error
- func (ls *LedgerState) GetBlock(point ocommon.Point) (*models.Block, error)
- func (ls *LedgerState) GetChainFromPoint(point ocommon.Point, inclusive bool) (*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) Tip() ochainsync.Tip
- func (ls *LedgerState) UtxoByRef(txId []byte, outputIdx uint32) (models.Utxo, error)
- func (ls *LedgerState) UtxosByAddress(addr ledger.Address) ([]models.Utxo, error)
- type LedgerStateConfig
Constants ¶
const ( ChainBlockEventType = "ledger.chain-block" ChainRollbackEventType = "ledger.chain-rollback" )
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 ChainIterator ¶
type ChainIterator struct {
// contains filtered or unexported fields
}
func (*ChainIterator) Next ¶
func (ci *ChainIterator) Next(blocking bool) (*ChainIteratorResult, error)
type ChainIteratorResult ¶
type ChainRollbackEvent ¶
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 ¶
func NewLedgerState ¶
func NewLedgerState(cfg LedgerStateConfig) (*LedgerState, error)
func (*LedgerState) Close ¶
func (ls *LedgerState) Close() 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 ¶
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) UtxosByAddress ¶
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 }