chainsync

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainsyncClientState

type ChainsyncClientState struct {
	ChainIter            *chain.ChainIterator
	Cursor               ocommon.Point
	NeedsInitialRollback bool
}

type State

type State struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewState

func NewState(
	eventBus *event.EventBus,
	ledgerState *ledger.LedgerState,
) *State

func (*State) AddClient

func (s *State) AddClient(
	connId connection.ConnectionId,
	intersectPoint ocommon.Point,
) (*ChainsyncClientState, error)

func (*State) AddClientConnId added in v0.21.0

func (s *State) AddClientConnId(connId ouroboros.ConnectionId)

AddClientConnId adds a connection ID to the set of tracked chainsync clients. If no active client exists, this connection is automatically set as the active client. This ensures there is always an active client when at least one is tracked.

func (*State) ClientConnCount added in v0.21.0

func (s *State) ClientConnCount() int

ClientConnCount returns the number of tracked chainsync clients.

func (*State) GetClientConnId

func (s *State) GetClientConnId() *ouroboros.ConnectionId

GetClientConnId returns the active chainsync client connection ID. This is the connection that should be used for block fetching.

func (*State) GetClientConnIds added in v0.21.0

func (s *State) GetClientConnIds() []ouroboros.ConnectionId

GetClientConnIds returns all tracked chainsync client connection IDs.

func (*State) HasClientConnId added in v0.21.0

func (s *State) HasClientConnId(connId ouroboros.ConnectionId) bool

HasClientConnId returns true if the connection ID is being tracked.

func (*State) RemoveClient

func (s *State) RemoveClient(connId connection.ConnectionId)

func (*State) RemoveClientConnId

func (s *State) RemoveClientConnId(connId ouroboros.ConnectionId)

RemoveClientConnId removes a connection from tracking. If this was the active client, selects a fallback from remaining tracked clients.

func (*State) SetClientConnId

func (s *State) SetClientConnId(connId ouroboros.ConnectionId)

SetClientConnId sets the active chainsync client connection ID. This is used when chain selection determines a new best peer.

func (*State) TryAddClientConnId added in v0.21.0

func (s *State) TryAddClientConnId(
	connId ouroboros.ConnectionId,
	maxClients int,
) bool

TryAddClientConnId atomically checks if a connection can be added (not already tracked and under maxClients limit) and adds it if allowed. Returns true if the connection was added, false otherwise.

Jump to

Keyboard shortcuts

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