broadcast

package
v1.1.1-0...-7cefdf7 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() *block

New sets up and returns a new Broadcast block instance.

func Send

func Send(node *noise.Node, from kad.ID, code byte, data []byte, minBucketID int, maxBucketID int, seqNum byte, incrementSeqNum bool)

Send starts broadcasting data to the network.

Types

type Message

type Message struct {
	From      kad.ID
	PrefixLen uint16
	Hash      [hashSize]byte
	// Code is a single byte that indicates the type of Data so that Data can be properly deserialized.
	Code byte
	Data []byte
	// SeqNum is an incrementing sequence number (which wraps around 255, since it is of type byte). Messages with identical Code and Data but different SeqNums will hash differently.
	SeqNum byte
}

Message is a message with typed payload (Code and Data) to be broadcasted. Unlike relay messages, broadcast messages do not have SeenPeers because the number of seen peers could be much larger.

func NewMessage

func NewMessage(from kad.ID, prefixlen uint16, code byte, data []byte) Message

NewMessage creates a new Message instance.

func (*Message) ChangeSeqNum

func (msg *Message) ChangeSeqNum(newSeqNum byte)

ChangeSeqNum changes the message sequence number and rehashes the message.

func (Message) Read

func (msg Message) Read(reader payload.Reader) (noise.Message, error)

func (Message) Write

func (msg Message) Write() []byte

Jump to

Keyboard shortcuts

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