zmq

package
v0.10.6 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2021 License: ISC Imports: 4 Imported by: 0

README

Block and Transaction Broadcasting with ZeroMQ

ZeroMQ is a lightweight wrapper around TCP connections, inter-process communication, and shared-memory, providing various message-oriented semantics such as publish/subscribe, request/reply, and push/pull.

The Qitmeer daemon can be configured to act as a trusted "border router", implementing the Qitmeer protocol and relay, making consensus decisions, maintaining the local blockchain database, broadcasting locally generated transactions into the network, and providing a queryable RPC interface to interact on a polled basis for requesting blockchain related data. However, there exists only a limited service to notify external software of events like the arrival of new blocks or transactions.

The ZeroMQ facility implements a notification interface through a set of specific notifiers. Currently there are notifiers that publish blocks and transactions. This read-only facility requires only the connection of a corresponding ZeroMQ subscriber port in receiving software; it is not authenticated nor is there any two-way protocol involvement. Therefore, subscribers should validate the received data since it may be out of date, incomplete or even invalid.

ZeroMQ sockets are self-connecting and self-healing; that is, connections made between two endpoints will be automatically restored after an outage, and either end may be freely started or stopped in any order.

Because ZeroMQ is message oriented, subscribers receive transactions and blocks all-at-once and do not need to implement any sort of buffering or reassembly.

Prerequisites

If you want to open it, you must install some dependency libraries:

  • Mac:
    brew install czmq libsodium
  • Ubuntu:
    apt install czmq libsodium

Enabling

By default, the ZeroMQ is disable. To enable, use ZMQ=TRUE during go building qitmmer:

$ make ZMQ=TRUE

To actually enable operation, one must set the appropriate options on the command line or in the configuration file.

Usage

Currently, the default configuration is as follows:

    --zmqpubhashtx=*
    --zmqpubhashblock=*
    --zmqpubrawblock=*
    --zmqpubrawtx=*

or:

    --zmqpubhashtx=default
    --zmqpubhashblock=default
    --zmqpubrawblock=default
    --zmqpubrawtx=default

The default detailed address can be found in the log. Of course, if you need a special address, you can configure it as follows:

    --zmqpubhashtx=address
    --zmqpubhashblock=address
    --zmqpubrawblock=address
    --zmqpubrawtx=address

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UseLogger

func UseLogger(logger l.Logger)

UseLogger uses a specified Logger to output package logging info.

Types

type IZMQNotification

type IZMQNotification interface {
	// init
	Init(cfg *config.Config)

	// is enable
	IsEnable() bool

	// block accepted
	BlockAccepted(block *types.SerializedBlock)

	// block connected
	BlockConnected(block *types.SerializedBlock)

	// block connected
	BlockDisconnected(block *types.SerializedBlock)

	// Shutdown
	Shutdown()
}

The interface for ZeroMQ notificaion

func NewZMQNotification

func NewZMQNotification(cfg *config.Config) IZMQNotification

New ZMQ Notification

type ZMQNotification

type ZMQNotification struct {
}

This ZeroMQ notification is default for Qitmeer If you want to enable ZMQ for Qitmeer, you must use 'zmq' tags when go building

func (*ZMQNotification) BlockAccepted

func (zn *ZMQNotification) BlockAccepted(block *types.SerializedBlock)

block accepted

func (*ZMQNotification) BlockConnected

func (zn *ZMQNotification) BlockConnected(block *types.SerializedBlock)

block connected

func (*ZMQNotification) BlockDisconnected

func (zn *ZMQNotification) BlockDisconnected(block *types.SerializedBlock)

block connected

func (*ZMQNotification) Init

func (zn *ZMQNotification) Init(cfg *config.Config)

Initialization notification

func (*ZMQNotification) IsEnable

func (zn *ZMQNotification) IsEnable() bool

func (*ZMQNotification) Shutdown

func (zn *ZMQNotification) Shutdown()

Shutdown

Jump to

Keyboard shortcuts

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