chainsync

package
v0.47.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 32 Imported by: 8 modules, 7 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EpochFromSlot added in v0.34.0

func EpochFromSlot(slot uint64) uint64

EpochFromSlot derives an epoch using the process-wide genesis configuration. ChainSync status uses the instance's configured era history instead.

func ExtractAssetDetailsFromMatch added in v0.24.0

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

func NewResolvedTransactionOutput added in v0.24.0

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

Types

type ChainSync

type ChainSync struct {
	plugin.Base
	// 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) Connected added in v0.47.0

func (c *ChainSync) Connected() bool

Connected reports whether this run currently owns a node connection. It does not assert that the remote node is healthy or synchronized.

func (*ChainSync) Role added in v0.46.0

func (c *ChainSync) Role() plugin.PluginType

Role identifies this plugin as a pipeline input.

func (*ChainSync) Start

func (c *ChainSync) Start() error

Start the chain sync input.

The first connection is dialled synchronously, so a node that is down is reported to the caller rather than retried behind its back. Every later reconnect belongs to the supervisor.

Reconnects use connect within the existing run and preserve its channels.

func (*ChainSync) StartContext added in v0.46.0

func (c *ChainSync) StartContext(ctx context.Context) error

StartContext starts the plugin with ctx governing setup and run operations. Call Stop to wait for workers and release resources, including after cancellation.

func (*ChainSync) Stop

func (c *ChainSync) Stop() error

Stop the chain sync input.

The connection is closed twice over, because two different orderings can leave one open:

  • BeforeWait catches the settled case, and has to run there: closing the connection is what unblocks the supervisor's read of the connection error channel, so the wait would not end without it.
  • AfterWait catches a dial that was in flight when Stop ran. There, BeforeWait finds no connection to take, and the dial installs one afterwards. By AfterWait the supervisor has exited and nothing can call setConn again, so whatever is installed then is the last word.

Without the second close, Stop returns nil while the node connection and its goroutines are still live, and those goroutines call back into a plugin whose channels are closing.

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 WithEraHistory added in v0.46.0

func WithEraHistory(history EraHistory) ChainSyncOptionFunc

WithEraHistory specifies slot-to-epoch boundaries for a custom network. It overrides history inferred from WithNetwork or WithNetworkMagic.

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 WithKupoUrl added in v0.24.0

func WithKupoUrl(
	url string,
) ChainSyncOptionFunc

WithKupoUrl specifies the optional Kupo endpoint for resolving transaction inputs.

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 WithReconnectCallback added in v0.38.0

func WithReconnectCallback(callback func()) ChainSyncOptionFunc

WithReconnectCallback specifies a function to call after a successful auto-reconnect. This allows consumers to detect reconnection events and take action (e.g., logging, re-syncing state, resetting watchdogs).

func WithSocketPath

func WithSocketPath(socketPath string) ChainSyncOptionFunc

WithSocketPath specifies the socket path of the node to connect to

func WithStateKey added in v0.47.0

func WithStateKey(key string) ChainSyncOptionFunc

WithStateKey overrides the key used to store the chainsync cursor in the configured state.Store. This allows multiple ChainSync instances to share a single store without their cursors colliding. Defaults to "chainsync-cursor".

func WithStateStore added in v0.47.0

func WithStateStore(store state.Store) ChainSyncOptionFunc

WithStateStore specifies a state.Store used to persist the chainsync cursor across restarts. When set and the store already holds a cursor, it is used as the sole intersect point and overrides whatever WithIntersectTip or WithIntersectPoints configured, so the sync resumes from the last confirmed block instead of restarting from either.

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 {
	BlockHash     string
	TipBlockHash  string
	SlotNumber    uint64
	BlockNumber   uint64
	EpochNumber   uint64
	TipSlotNumber uint64
	TipReached    bool
}

type EraHistory added in v0.46.0

type EraHistory struct {
	ByronEpochLength   uint64
	ShelleyStartSlot   uint64
	ShelleyStartEpoch  uint64
	ShelleyEpochLength uint64
}

EraHistory contains the slot boundaries needed to derive an epoch number. ShelleyStartSlot is zero for networks that began in Shelley. A zero epoch length returns the corresponding era's starting epoch instead of dividing.

func (EraHistory) EpochFromSlot added in v0.46.0

func (h EraHistory) EpochFromSlot(slot uint64) uint64

EpochFromSlot returns the epoch containing slot.

type ResolvedTransactionOutput added in v0.24.0

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

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() *big.Int

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 StatusUpdateFunc

type StatusUpdateFunc func(ChainSyncStatus)

Jump to

Keyboard shortcuts

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