zmq

package
v0.0.0-...-e4c499b Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientConnected

type ClientConnected struct{}

ClientConnected is a notification for when a client connection is opened or reestablished to the chain server.

type Consumer

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

Consumer ...

func (*Consumer) Id

func (c *Consumer) Id() uint64

func (*Consumer) Notifications

func (c *Consumer) Notifications() <-chan interface{}

Notifications returns a channel to retrieve notifications from.

NOTE: This is part of the chain.Interface interface.

func (*Consumer) NotifyBlocks

func (c *Consumer) NotifyBlocks() error

NotifyBlocks allows the chain backend to notify the caller whenever a block is connected or disconnected.

NOTE: This is part of the chain.Interface interface.

func (*Consumer) NotifyReceived

func (c *Consumer) NotifyReceived(scripts []string) error

NotifyReceived allows the chain backend to notify the caller whenever a transaction pays to any of the given scripts hex.

NOTE: This is part of the chain.Interface interface.

func (*Consumer) NotifySpent

func (c *Consumer) NotifySpent(outPoints []*elements.OutPoint) error

NotifySpent allows the chain backend to notify the caller whenever a transaction spends any of the given outpoints.

func (*Consumer) NotifyTx

func (c *Consumer) NotifyTx(txids []chainhash.Hash) error

NotifyTx allows the chain backend to notify the caller whenever any of the given transactions confirm within the chain.

func (*Consumer) Start

func (c *Consumer) Start() error

Start initializes the bitcoind rescan client using the backing bitcoind connection and starts all goroutines necessary in order to process rescans and ZMQ notifications.

NOTE: This is part of the chain.Interface interface.

func (*Consumer) Stop

func (c *Consumer) Stop()

Stop stops the bitcoind rescan client from processing rescans and ZMQ notifications.

NOTE: This is part of the chain.Interface interface.

type RelevantTx

type RelevantTx struct {
	TxRecord *elements.TransactionExtended
	Block    *elements.BlockID // nil if unmined
}

RelevantTx is a notification for a transaction which spends wallet inputs or pays to a watched address.

type Subscriber

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

Subscriber ...

func NewSubscriber

func NewSubscriber(chain *network.Network,
	jsonrpcEndpoint, zmqBlockHost, zmqTxHost string,
	zmqPollInterval time.Duration) (*Subscriber, error)

NewSubscriber ...

func (*Subscriber) AddClient

func (s *Subscriber) AddClient(client *Consumer)

AddClient adds a client to the set of active rescan clients of the current chain connection. This allows the connection to include the specified client in its notification delivery.

NOTE: This function is safe for concurrent access.

func (*Subscriber) NewConsumer

func (s *Subscriber) NewConsumer() *Consumer

NewConsumer returns a bitcoind client using the current bitcoind connection. This allows us to share the same connection using multiple clients.

func (*Subscriber) RemoveClient

func (s *Subscriber) RemoveClient(id uint64)

RemoveClient removes the client with the given ID from the set of active rescan clients. Once removed, the client will no longer receive block and transaction notifications from the chain connection.

NOTE: This function is safe for concurrent access.

func (*Subscriber) Start

func (s *Subscriber) Start() error

Start attempts to establish a RPC and ZMQ connection to a elements node. If successful, a goroutine is spawned to read events from the ZMQ connection. It's possible for this function to fail due to a limited number of connection attempts. This is done to prevent waiting forever on the connection to be established in the case that the node is down.

func (*Subscriber) Stop

func (s *Subscriber) Stop()

Stop terminates the RPC and ZMQ connection to a elementsd node and removes any active rescan clients.

Jump to

Keyboard shortcuts

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