msg

package
v0.0.0-...-512bbbe Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2020 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MSG_VERSION = "version"
	MSG_DATA    = "data"
)

Different message types

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	Type    string      `json:"type"`
	Payload interface{} `json:"payload"`
}

A message should be wrapped inside a container

func CreateNewMessage

func CreateNewMessage(t string, payload interface{}) Message

Construct a message

type Msg_Data

type Msg_Data struct {
	Recipient string `json:"recipient"`
	Data      string `json:"data"`
	TTL       uint64 `json:"ttl"`
}

func CreateNewDataMessage

func CreateNewDataMessage(recipient, data string) Msg_Data

Lets create a new data message

type Msg_Version

type Msg_Version struct {
	Version   string `json:"version"`
	Timestamp uint64 `json:"timestamp"`
	AddrRecv  string `json:"addr_recv"` // The network address of the node who is receiving the message
	AddrFrom  string `json:"addr_from"` // The network address of the node who is sending the message
}

func NewVersionMessage

func NewVersionMessage(receivingAddress, fromAddress string) Msg_Version

Lets create a new version message

Jump to

Keyboard shortcuts

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