topics

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const Size = 15

Size is the size of a topic field in bytes

Variables

This section is empty.

Functions

func TopicToByteArray

func TopicToByteArray(cmd Topic) [Size]byte

TopicToByteArray turns a Topic to a byte array of size 15, to prepare it for sending over the wire protocol.

func Write

func Write(r io.Writer, topic Topic) error

Types

type Topic

type Topic string

Topic defines a topic

const (
	// Standard topics
	Version Topic = "version"
	VerAck  Topic = "verack"
	Ping    Topic = "ping"
	Pong    Topic = "pong"

	// Data exchange topics
	Addr          Topic = "addr"
	GetAddr       Topic = "getaddr"
	GetData       Topic = "getdata"
	GetBlocks     Topic = "getblocks"
	GetHeaders    Topic = "getheaders"
	Tx            Topic = "tx"
	Block         Topic = "block"
	AcceptedBlock Topic = "acceptedblock"
	Headers       Topic = "headers"
	MemPool       Topic = "mempool"
	Inv           Topic = "inv"
	Certificate   Topic = "certificate"

	// Consensus topics
	Candidate      Topic = "candidate"
	Score          Topic = "score"
	Reduction      Topic = "blockreduction"
	Agreement      Topic = "blockagreement"
	StartConsensus Topic = "startconsensus"

	// Peer topics
	Gossip Topic = "gossip"

	// Blockchain topics
	ChainInfo Topic = "chaininfo"

	// RPC topics
	RPCChainInfo Topic = "rpcchaininfo"

	// Error topics
	NotFound Topic = "notfound"
	Reject   Topic = "reject"
)

A list of all valid topics

func ByteArrayToTopic

func ByteArrayToTopic(cmd [Size]byte) Topic

ByteArrayToTopic turns a byte array of size 15 into a Topic, for populating a received message header.

func Extract

func Extract(p io.Reader) (Topic, error)

Extract the topic by reading the first `topic.Size` bytes

func Peek

func Peek(p io.Reader) (Topic, error)

Peek the topic without advancing the reader Deprecated: Peek is several order of magnitude slower than Extract. Even if having to Tee read the whole buffer, Extract should be used

Jump to

Keyboard shortcuts

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