core

package
v0.0.0-...-88bd931 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const NEW_BLOCKS_TOPIC = "NEW_BLOCKS_TOPIC"
View Source
const PENDING_TX_TOPIC = "PENDING_TX_TOPIC"

Variables

This section is empty.

Functions

func PrettyPrintJSON

func PrettyPrintJSON(messageJSONBytes []byte) (bytes.Buffer, error)

* Pretty print json with indentation

Types

type MessageHandler

type MessageHandler func(data *pubsub.Message)

type MessageTransport

type MessageTransport struct {
	Data []byte
}

type PubSubWrapper

type PubSubWrapper struct {
	// A channel of signed transactions to send new pending transactions to peers
	Data      chan MessageTransport
	TopicName string
	Context   context.Context
	PubSub    *pubsub.PubSub
	Topic     *pubsub.Topic
	Sub       *pubsub.Subscription
	Self      peer.ID
}

PubSubWrapper represents a subscription to a single PubSub topic. Messages can be published to the topic with PubSubWrapper.Publish, and received messages are pushed to the Messages channel. TODO this name is bad... but works for now..

func (*PubSubWrapper) ListPeers

func (cr *PubSubWrapper) ListPeers(ps *pubsub.PubSub) []peer.ID

func (*PubSubWrapper) Publish

func (cr *PubSubWrapper) Publish(ctx context.Context, msgChan chan MessageTransport) error

Publish sends a message to the pubsub topic.

func (*PubSubWrapper) ReadLoop

func (cr *PubSubWrapper) ReadLoop(ctx context.Context, onMessage MessageHandler)

readLoop pulls messages from the pubsub topic and pushes them onto the Messages channel.

type PublishHandler

type PublishHandler func(msg []byte)

Jump to

Keyboard shortcuts

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