zmq

package
v0.0.0-...-910450c Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(endpoint string, topic Topic) *Client

NewClient instantiates a new client that will receive monerod's zmq events.

  • `topic` is a fully-formed zmq topic to subscribe to

  • `endpoint` is the full address where monerod has been configured to publish the messages to, including the network schama. for instance, considering that monerod has been started with

    monerod --zmq-pub tcp://127.0.0.1:18085

    `endpoint` should be 'tcp://127.0.0.1:18085'.

func (*Client) Close

func (c *Client) Close() error

Close closes any established connection, if any.

func (*Client) Listen

func (c *Client) Listen(ctx context.Context) (*Stream, error)

Listen listens for a topic pre-configured for this client (via NewClient).

Clients listen to a single topic at a time - to listen to multiple topics, create new clients and listen on the corresponding stream's channel.

type FullChainMain

type FullChainMain struct {
	MajorVersion int    `json:"major_version"`
	MinorVersion int    `json:"minor_version"`
	Timestamp    int64  `json:"timestamp"`
	PrevID       string `json:"prev_id"`
	Nonce        uint64 `json:"nonce"`
	MinerTx      struct {
		Version    int   `json:"version"`
		UnlockTime int64 `json:"unlock_time"`
		Inputs     []struct {
			Gen struct {
				Height uint64 `json:"height"`
			} `json:"gen"`
		} `json:"inputs"`
		Outputs []struct {
			Amount uint64 `json:"amount"`
			ToKey  struct {
				Key string `json:"key"`
			} `json:"to_key"`
		} `json:"outputs"`
		Extra      string        `json:"extra"`
		Signatures []interface{} `json:"signatures"`
		Ringct     struct {
			Type        int           `json:"type"`
			Encrypted   []interface{} `json:"encrypted"`
			Commitments []interface{} `json:"commitments"`
			Fee         uint64        `json:"fee"`
		} `json:"ringct"`
	} `json:"miner_tx"`
	TxHashes []string `json:"tx_hashes"`
}

type FullTxPoolAdd

type FullTxPoolAdd struct {
	Version    int   `json:"version"`
	UnlockTime int64 `json:"unlock_time"`
	Inputs     []struct {
		ToKey struct {
			Amount     uint64   `json:"amount"`
			KeyOffsets []uint64 `json:"key_offsets"`
			KeyImage   string   `json:"key_image"`
		} `json:"to_key"`
	} `json:"inputs"`
	Outputs []struct {
		Amount int `json:"amount"`
		ToKey  struct {
			Key string `json:"key"`
		} `json:"to_key"`
	} `json:"outputs"`
	Extra      string        `json:"extra"`
	Signatures []interface{} `json:"signatures"`
	Ringct     struct {
		Type      int `json:"type"`
		Encrypted []struct {
			Mask   string `json:"mask"`
			Amount string `json:"amount"`
		} `json:"encrypted"`
		Commitments []string `json:"commitments"`
		Fee         int      `json:"fee"`
		Prunable    struct {
			RangeProofs  []interface{} `json:"range_proofs"`
			Bulletproofs []struct {
				V      []string `json:"V"`
				AUpper string   `json:"A"`
				S      string   `json:"S"`
				T1     string   `json:"T1"`
				T2     string   `json:"T2"`
				Taux   string   `json:"taux"`
				Mu     string   `json:"mu"`
				L      []string `json:"L"`
				R      []string `json:"R"`
				ALower string   `json:"a"`
				B      string   `json:"b"`
				T      string   `json:"t"`
			} `json:"bulletproofs"`
			Mlsags     []interface{} `json:"mlsags"`
			PseudoOuts []string      `json:"pseudo_outs"`
		} `json:"prunable"`
	} `json:"ringct"`
}

type MinimalChainMain

type MinimalChainMain struct {
	FirstHeight uint64   `json:"first_height"`
	FirstPrevID string   `json:"first_prev_id"`
	Ids         []string `json:"ids"`
}

type MinimalTxPoolAdd

type MinimalTxPoolAdd struct {
	ID       string `json:"id"`
	BlobSize uint64 `json:"blob_size"`
}

type Stream

type Stream struct {
	ErrC chan error

	FullChainMainC    chan *FullChainMain
	FullTxPoolAddC    chan *FullTxPoolAdd
	MinimalChainMainC chan *MinimalChainMain
	MinimalTxPoolAddC chan *MinimalTxPoolAdd
}

Stream provides channels where instances of the desired topic object are sent to.

type Topic

type Topic string
const (
	TopicUnknown Topic = "unknown"

	TopicMinimalTxPoolAdd Topic = "json-minimal-txpool_add"
	TopicFullTxPoolAdd    Topic = "json-full-txpool_add"

	TopicMinimalChainMain Topic = "json-minimal-chain_main"
	TopicFullChainMain    Topic = "json-full-chain_main"
)

Jump to

Keyboard shortcuts

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