chainsync

package
v0.32.5 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: Apache-2.0 Imports: 28 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractAssetDetailsFromMatch added in v0.24.0

func ExtractAssetDetailsFromMatch(
	match kugo.Match,
) (common.MultiAsset[uint64], uint64, error)

func NewFromCmdlineOptions

func NewFromCmdlineOptions() plugin.Plugin

func NewResolvedTransactionOutput added in v0.24.0

func NewResolvedTransactionOutput(
	match kugo.Match,
) (ledger.TransactionOutput, error)

Types

type BlockContext

type BlockContext struct {
	BlockNumber  uint64 `json:"blockNumber"`
	SlotNumber   uint64 `json:"slotNumber"`
	NetworkMagic uint32 `json:"networkMagic"`
	Era          string `json:"era"`
}

func NewBlockContext

func NewBlockContext(block ledger.Block, networkMagic uint32) BlockContext

func NewBlockHeaderContext

func NewBlockHeaderContext(block ledger.BlockHeader) BlockContext

type BlockEvent

type BlockEvent struct {
	Block            ledger.Block     `json:"-"`
	BlockBodySize    uint64           `json:"blockBodySize"`
	IssuerVkey       string           `json:"issuerVkey"`
	BlockHash        string           `json:"blockHash"`
	BlockCbor        byteSliceJsonHex `json:"blockCbor,omitempty"`
	TransactionCount uint64           `json:"transactionCount"`
}

func NewBlockEvent

func NewBlockEvent(block ledger.Block, includeCbor bool) BlockEvent

type ChainSync

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

func New

func New(options ...ChainSyncOptionFunc) *ChainSync

New returns a new ChainSync object with the specified options applied

func (*ChainSync) ErrorChan

func (c *ChainSync) ErrorChan() chan error

ErrorChan returns the input error channel

func (*ChainSync) InputChan

func (c *ChainSync) InputChan() chan<- event.Event

InputChan always returns nil

func (*ChainSync) OutputChan

func (c *ChainSync) OutputChan() <-chan event.Event

OutputChan returns the output event channel

func (*ChainSync) Start

func (c *ChainSync) Start() error

Start the chain sync input

func (*ChainSync) Stop

func (c *ChainSync) Stop() error

Stop the chain sync input

type ChainSyncOptionFunc

type ChainSyncOptionFunc func(*ChainSync)

func WithAddress

func WithAddress(address string) ChainSyncOptionFunc

WithAddress specifies the TCP address of the node to connect to in the form "host:port"

func WithAutoReconnect

func WithAutoReconnect(autoReconnect bool) ChainSyncOptionFunc

WithAutoReconnect specified whether to automatically reconnect if the connection is broken

func WithBulkMode deprecated

func WithBulkMode(bulkMode bool) ChainSyncOptionFunc

WithBulkMode specifies whether to use the "bulk" sync mode with NtN (node-to-node). This should only be used against your own nodes for resource usage reasons

Deprecated: this flag no longer does anything useful, as bulk mode is now the default (and only) mode of operation

func WithDelayConfirmations added in v0.30.0

func WithDelayConfirmations(count uint) ChainSyncOptionFunc

WithDelayConfirmationCount specifies the number of confirmations (subsequent blocks) are required before an event will be emitted

func WithIncludeCbor

func WithIncludeCbor(includeCbor bool) ChainSyncOptionFunc

WithIncludeCbor specifies whether to include the original CBOR for a block or transaction with the event

func WithIntersectPoints

func WithIntersectPoints(points []ocommon.Point) ChainSyncOptionFunc

WithIntersectPoints specifies the point(s) to use when starting the ChainSync operation. The default is to start at the genesis of the blockchain

func WithIntersectTip

func WithIntersectTip(intersectTip bool) ChainSyncOptionFunc

WithInterceptTip specifies whether to start the ChainSync operation from the chain tip. The default is to start at the genesis of the blockchain

func WithLogger

func WithLogger(logger plugin.Logger) ChainSyncOptionFunc

WithLogger specifies the logger object to use for logging messages

func WithNetwork

func WithNetwork(network string) ChainSyncOptionFunc

WithNetwork specifies the network

func WithNetworkMagic

func WithNetworkMagic(networkMagic uint32) ChainSyncOptionFunc

WithNetworkMagic specifies the network magic value

func WithNtcTcp

func WithNtcTcp(ntcTcp bool) ChainSyncOptionFunc

WithNtcTcp specifies whether to use the NtC (node-to-client) protocol over TCP. This is useful when exposing a node's UNIX socket via socat or similar. The default is to use the NtN (node-to-node) protocol over TCP

func WithSocketPath

func WithSocketPath(socketPath string) ChainSyncOptionFunc

WithSocketPath specifies the socket path of the node to connect to

func WithStatusUpdateFunc

func WithStatusUpdateFunc(
	statusUpdateFunc StatusUpdateFunc,
) ChainSyncOptionFunc

WithStatusUpdateFunc specifies a callback function for status updates. This is useful for tracking the chain-sync status to be able to resume a sync at a later time, especially when any filtering could prevent you from getting all block update events

type ChainSyncStatus

type ChainSyncStatus struct {
	SlotNumber    uint64
	BlockNumber   uint64
	BlockHash     string
	TipSlotNumber uint64
	TipBlockHash  string
	TipReached    bool
}

type ResolvedTransactionOutput added in v0.24.0

type ResolvedTransactionOutput struct {
	AddressField common.Address             `json:"address"`
	AmountField  uint64                     `json:"amount"`
	AssetsField  *common.MultiAsset[uint64] `json:"assets,omitempty"`
}

ResolvedTransactionOutput represents a concrete implementation of the TransactionOutput interface

func (ResolvedTransactionOutput) Address added in v0.24.0

func (txOut ResolvedTransactionOutput) Address() common.Address

func (ResolvedTransactionOutput) Amount added in v0.24.0

func (txOut ResolvedTransactionOutput) Amount() uint64

func (ResolvedTransactionOutput) Assets added in v0.24.0

func (ResolvedTransactionOutput) Cbor added in v0.24.0

func (txOut ResolvedTransactionOutput) Cbor() []byte

func (ResolvedTransactionOutput) Datum added in v0.24.0

func (txOut ResolvedTransactionOutput) Datum() *common.Datum

func (ResolvedTransactionOutput) DatumHash added in v0.24.0

func (txOut ResolvedTransactionOutput) DatumHash() *common.Blake2b256

func (ResolvedTransactionOutput) ScriptRef added in v0.30.4

func (txOut ResolvedTransactionOutput) ScriptRef() common.Script

func (ResolvedTransactionOutput) String added in v0.32.4

func (txOut ResolvedTransactionOutput) String() string

func (ResolvedTransactionOutput) ToPlutusData added in v0.31.0

func (txOut ResolvedTransactionOutput) ToPlutusData() data.PlutusData

func (ResolvedTransactionOutput) Utxorpc added in v0.24.0

func (txOut ResolvedTransactionOutput) Utxorpc() (*utxorpc.TxOutput, error)

type RollbackEvent

type RollbackEvent struct {
	BlockHash  string `json:"blockHash"`
	SlotNumber uint64 `json:"slotNumber"`
}

func NewRollbackEvent

func NewRollbackEvent(point ocommon.Point) RollbackEvent

type StatusUpdateFunc

type StatusUpdateFunc func(ChainSyncStatus)

type TransactionContext

type TransactionContext struct {
	BlockNumber     uint64 `json:"blockNumber"`
	SlotNumber      uint64 `json:"slotNumber"`
	TransactionHash string `json:"transactionHash"`
	TransactionIdx  uint32 `json:"transactionIdx"`
	NetworkMagic    uint32 `json:"networkMagic"`
}

func NewTransactionContext

func NewTransactionContext(
	block ledger.Block,
	tx ledger.Transaction,
	index uint32,
	networkMagic uint32,
) TransactionContext

type TransactionEvent

type TransactionEvent struct {
	Transaction     ledger.Transaction            `json:"-"`
	BlockHash       string                        `json:"blockHash"`
	TransactionCbor byteSliceJsonHex              `json:"transactionCbor,omitempty"`
	Inputs          []ledger.TransactionInput     `json:"inputs"`
	Outputs         []ledger.TransactionOutput    `json:"outputs"`
	Certificates    []ledger.Certificate          `json:"certificates,omitempty"`
	ReferenceInputs []ledger.TransactionInput     `json:"referenceInputs,omitempty"`
	Metadata        *cbor.LazyValue               `json:"metadata,omitempty"`
	Fee             uint64                        `json:"fee"`
	TTL             uint64                        `json:"ttl,omitempty"`
	ResolvedInputs  []ledger.TransactionOutput    `json:"resolvedInputs,omitempty"`
	Withdrawals     map[string]uint64             `json:"withdrawals,omitempty"`
	Witnesses       lcommon.TransactionWitnessSet `json:"witnesses,omitempty"`
}

func NewTransactionEvent

func NewTransactionEvent(
	block ledger.Block,
	tx ledger.Transaction,
	includeCbor bool,
	resolvedInputs []ledger.TransactionOutput,
) TransactionEvent

Jump to

Keyboard shortcuts

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