Documentation ¶
Index ¶
- Constants
- Variables
- func INXBlockMetadataCaller(handler interface{}, params ...interface{})
- func MilestoneCaller(handler interface{}, params ...interface{})
- func WithTargetNetworkName(targetNetworkName string) options.Option[NodeBridge]
- type BlockSolidCallback
- type Events
- type LedgerUpdate
- type Milestone
- type NodeBridge
- func (n *NodeBridge) Block(ctx context.Context, blockID iotago.BlockID) (*iotago.Block, error)
- func (n *NodeBridge) BlockMetadata(ctx context.Context, blockID iotago.BlockID) (*inx.BlockMetadata, error)
- func (n *NodeBridge) Client() inx.INXClient
- func (n *NodeBridge) ConfirmedMilestone() (*Milestone, error)
- func (n *NodeBridge) ConfirmedMilestoneIndex() uint32
- func (n *NodeBridge) Connect(ctx context.Context, address string, maxConnectionAttempts uint) error
- func (n *NodeBridge) EventAPI(ctx context.Context) (*nodeclient.EventAPIClient, error)
- func (n *NodeBridge) INXNodeClient() *nodeclient.Client
- func (n *NodeBridge) Indexer(ctx context.Context) (nodeclient.IndexerClient, error)
- func (n *NodeBridge) IsNodeAlmostSynced() bool
- func (n *NodeBridge) IsNodeHealthy() bool
- func (n *NodeBridge) IsNodeSynced() bool
- func (n *NodeBridge) LatestMilestone() (*Milestone, error)
- func (n *NodeBridge) LatestMilestoneIndex() uint32
- func (n *NodeBridge) ListenToBlocks(ctx context.Context, cancel context.CancelFunc, ...) error
- func (n *NodeBridge) ListenToLedgerUpdates(ctx context.Context, startIndex uint32, endIndex uint32, ...) error
- func (n *NodeBridge) Milestone(ctx context.Context, index uint32) (*Milestone, error)
- func (n *NodeBridge) MilestoneConeMetadata(ctx context.Context, cancel context.CancelFunc, index uint32, ...) error
- func (n *NodeBridge) NodeStatus() *inx.NodeStatus
- func (n *NodeBridge) ProtocolParameters() *iotago.ProtocolParameters
- func (n *NodeBridge) RegisterAPIRoute(ctx context.Context, route string, bindAddress string) error
- func (n *NodeBridge) RequestTips(ctx context.Context, count uint32, allowSemiLazy bool) (iotago.BlockIDs, error)
- func (n *NodeBridge) Run(ctx context.Context)
- func (n *NodeBridge) SubmitBlock(ctx context.Context, block *iotago.Block) (iotago.BlockID, error)
- func (n *NodeBridge) UnregisterAPIRoute(ctx context.Context, route string) error
- type TangleListener
- func (t *TangleListener) ClearBlockSolidCallbacks()
- func (t *TangleListener) DeregisterBlockSolidCallback(blockID iotago.BlockID)
- func (t *TangleListener) DeregisterBlockSolidEvent(blockID iotago.BlockID)
- func (t *TangleListener) DeregisterMilestoneConfirmedEvent(msIndex uint32)
- func (t *TangleListener) RegisterBlockSolidCallback(ctx context.Context, blockID iotago.BlockID, f BlockSolidCallback) error
- func (t *TangleListener) RegisterBlockSolidEvent(ctx context.Context, blockID iotago.BlockID) (chan struct{}, error)
- func (t *TangleListener) RegisterMilestoneConfirmedEvent(msIndex uint32) chan struct{}
- func (t *TangleListener) Run(ctx context.Context)
- type TangleListenerEvents
- type TipPoolListener
Constants ¶
const (
ListenToNodeStatusCooldownInMilliseconds = 1_000
)
Variables ¶
var ( ErrLedgerUpdateTransactionAlreadyInProgress = errors.New("trying to begin a ledger update transaction with an already active transaction") ErrLedgerUpdateInvalidOperation = errors.New("trying to process a ledger update operation without active transaction") ErrLedgerUpdateEndedAbruptly = errors.New("ledger update transaction ended before receiving all operations") )
var ErrAlreadyRegistered = errors.New("callback for block ID is already registered")
ErrAlreadyRegistered is returned when a callback for the same block ID has already been registered.
Functions ¶
func INXBlockMetadataCaller ¶
func INXBlockMetadataCaller(handler interface{}, params ...interface{})
func MilestoneCaller ¶
func MilestoneCaller(handler interface{}, params ...interface{})
func WithTargetNetworkName ¶
func WithTargetNetworkName(targetNetworkName string) options.Option[NodeBridge]
WithTargetNetworkName checks if the network name of the node is equal to the given targetNetworkName. If targetNetworkName is empty, the check is disabled.
Types ¶
type BlockSolidCallback ¶
type BlockSolidCallback = func(*inx.BlockMetadata)
type LedgerUpdate ¶
type LedgerUpdate struct { MilestoneIndex iotago.MilestoneIndex Consumed []*inx.LedgerSpent Created []*inx.LedgerOutput }
type Milestone ¶
type Milestone struct { MilestoneID iotago.MilestoneID Milestone *iotago.Milestone }
type NodeBridge ¶
type NodeBridge struct { // the logger used to log events. *logger.WrappedLogger Events *Events NodeConfig *inx.NodeConfiguration // contains filtered or unexported fields }
func NewNodeBridge ¶
func NewNodeBridge(log *logger.Logger, opts ...options.Option[NodeBridge]) *NodeBridge
func (*NodeBridge) BlockMetadata ¶
func (n *NodeBridge) BlockMetadata(ctx context.Context, blockID iotago.BlockID) (*inx.BlockMetadata, error)
func (*NodeBridge) Client ¶
func (n *NodeBridge) Client() inx.INXClient
func (*NodeBridge) ConfirmedMilestone ¶
func (n *NodeBridge) ConfirmedMilestone() (*Milestone, error)
func (*NodeBridge) ConfirmedMilestoneIndex ¶
func (n *NodeBridge) ConfirmedMilestoneIndex() uint32
func (*NodeBridge) EventAPI ¶
func (n *NodeBridge) EventAPI(ctx context.Context) (*nodeclient.EventAPIClient, error)
EventAPI returns the EventAPIClient if supported by the node. Returns ErrMQTTPluginNotAvailable if the current node does not support the plugin. It retries every second until the given context is done.
func (*NodeBridge) INXNodeClient ¶
func (n *NodeBridge) INXNodeClient() *nodeclient.Client
func (*NodeBridge) Indexer ¶
func (n *NodeBridge) Indexer(ctx context.Context) (nodeclient.IndexerClient, error)
Indexer returns the IndexerClient. Returns ErrIndexerPluginNotAvailable if the current node does not support the plugin. It retries every second until the given context is done.
func (*NodeBridge) IsNodeAlmostSynced ¶
func (n *NodeBridge) IsNodeAlmostSynced() bool
func (*NodeBridge) IsNodeHealthy ¶
func (n *NodeBridge) IsNodeHealthy() bool
func (*NodeBridge) IsNodeSynced ¶
func (n *NodeBridge) IsNodeSynced() bool
func (*NodeBridge) LatestMilestone ¶
func (n *NodeBridge) LatestMilestone() (*Milestone, error)
func (*NodeBridge) LatestMilestoneIndex ¶
func (n *NodeBridge) LatestMilestoneIndex() uint32
func (*NodeBridge) ListenToBlocks ¶
func (n *NodeBridge) ListenToBlocks(ctx context.Context, cancel context.CancelFunc, consumer func(block *iotago.Block)) error
func (*NodeBridge) ListenToLedgerUpdates ¶
func (n *NodeBridge) ListenToLedgerUpdates(ctx context.Context, startIndex uint32, endIndex uint32, consume func(update *LedgerUpdate) error) error
func (*NodeBridge) MilestoneConeMetadata ¶
func (n *NodeBridge) MilestoneConeMetadata(ctx context.Context, cancel context.CancelFunc, index uint32, consumer func(metadata *inx.BlockMetadata)) error
func (*NodeBridge) NodeStatus ¶
func (n *NodeBridge) NodeStatus() *inx.NodeStatus
func (*NodeBridge) ProtocolParameters ¶
func (n *NodeBridge) ProtocolParameters() *iotago.ProtocolParameters
func (*NodeBridge) RegisterAPIRoute ¶
func (*NodeBridge) RequestTips ¶
func (*NodeBridge) Run ¶
func (n *NodeBridge) Run(ctx context.Context)
func (*NodeBridge) SubmitBlock ¶
func (*NodeBridge) UnregisterAPIRoute ¶
func (n *NodeBridge) UnregisterAPIRoute(ctx context.Context, route string) error
type TangleListener ¶
type TangleListener struct { Events *TangleListenerEvents // contains filtered or unexported fields }
func NewTangleListener ¶
func NewTangleListener(nodeBridge *NodeBridge) *TangleListener
func (*TangleListener) ClearBlockSolidCallbacks ¶
func (t *TangleListener) ClearBlockSolidCallbacks()
ClearBlockSolidCallbacks removes all previously registered blockSolidCallbacks.
func (*TangleListener) DeregisterBlockSolidCallback ¶
func (t *TangleListener) DeregisterBlockSolidCallback(blockID iotago.BlockID)
DeregisterBlockSolidCallback removes a previously registered callback for blockID.
func (*TangleListener) DeregisterBlockSolidEvent ¶
func (t *TangleListener) DeregisterBlockSolidEvent(blockID iotago.BlockID)
DeregisterBlockSolidEvent removes a registered solid block event by triggering it to free memory.
func (*TangleListener) DeregisterMilestoneConfirmedEvent ¶
func (t *TangleListener) DeregisterMilestoneConfirmedEvent(msIndex uint32)
DeregisterMilestoneConfirmedEvent removes a registered confirmed milestone event by triggering it to free memory.
func (*TangleListener) RegisterBlockSolidCallback ¶
func (t *TangleListener) RegisterBlockSolidCallback(ctx context.Context, blockID iotago.BlockID, f BlockSolidCallback) error
RegisterBlockSolidCallback registers a callback for when a block with blockID becomes solid. If another callback for the same ID has already been registered, an error is returned.
func (*TangleListener) RegisterBlockSolidEvent ¶
func (t *TangleListener) RegisterBlockSolidEvent(ctx context.Context, blockID iotago.BlockID) (chan struct{}, error)
RegisterBlockSolidEvent registers an event for when the block with blockID becomes solid. If the block is already solid, the event is triggered imitatively.
func (*TangleListener) RegisterMilestoneConfirmedEvent ¶
func (t *TangleListener) RegisterMilestoneConfirmedEvent(msIndex uint32) chan struct{}
RegisterMilestoneConfirmedEvent registers an event for when the milestone with msIndex gets confirmed. If the milestone is already confirmed, the event is triggered imitatively.
func (*TangleListener) Run ¶
func (t *TangleListener) Run(ctx context.Context)
type TangleListenerEvents ¶
type TipPoolListener ¶
type TipPoolListener struct {
// contains filtered or unexported fields
}
func NewTipPoolListener ¶
func NewTipPoolListener(nodeBridge *NodeBridge, interval time.Duration) *TipPoolListener
func (*TipPoolListener) GetTipsPoolSizes ¶
func (t *TipPoolListener) GetTipsPoolSizes() (uint32, uint32)
func (*TipPoolListener) Run ¶
func (t *TipPoolListener) Run(ctx context.Context)