node

package
v0.0.0-...-07c73bd Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2020 License: BSD-2-Clause Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Message_invalid byte = iota
	Message_not_a_type
	Message_keepalive
	Message_publish
	Message_confirm_req
	Message_confirm_ack
	Message_bulk_pull
	Message_bulk_push
	Message_frontier_req
)

Non-idiomatic constant names to keep consistent with reference implentation

View Source
const (
	BlockType_invalid byte = iota
	BlockType_not_a_block
	BlockType_send
	BlockType_receive
	BlockType_open
	BlockType_change
)
View Source
const VersionMax = 0x05
View Source
const VersionMin = 0x04
View Source
const VersionUsing = 0x05

Variables

View Source
var DefaultPeer = Peer{
	net.ParseIP("::ffff:192.168.0.70"),
	7075,
	nil,
}
View Source
var MagicNumber = [2]byte{'R', 'C'}
View Source
var PeerList = []Peer{DefaultPeer}
View Source
var PeerSet = map[string]bool{DefaultPeer.String(): true}

Functions

func ListenForUdp

func ListenForUdp()

func SendKeepAlive

func SendKeepAlive(peer Peer) error

func SendKeepAlives

func SendKeepAlives(params []interface{})

Types

type Alarm

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

func NewAlarm

func NewAlarm(fn AlarmFn, fnParams []interface{}, d time.Duration) *Alarm

func (*Alarm) Run

func (a *Alarm) Run()

func (*Alarm) Stop

func (a *Alarm) Stop()

type AlarmFn

type AlarmFn func([]interface{})

type Message

type Message interface {
	Write(buf *bytes.Buffer) error
}

type MessageBlock

type MessageBlock struct {
	Type             byte
	SourceOrPrevious [32]byte // Source for open, previous for others
	RepDestOrSource  [32]byte // Rep for open/change, dest for send, source for receive
	Account          [32]byte // Account for open
	Balance          [16]byte // Balance for send
	MessageBlockCommon
}

func (*MessageBlock) Read

func (m *MessageBlock) Read(messageBlockType byte, buf *bytes.Buffer) error

func (*MessageBlock) ToBlock

func (m *MessageBlock) ToBlock() blocks.Block

func (*MessageBlock) Write

func (m *MessageBlock) Write(buf *bytes.Buffer) error

type MessageBlockCommon

type MessageBlockCommon struct {
	Signature [64]byte
	Work      [8]byte
}

func (*MessageBlockCommon) ReadCommon

func (m *MessageBlockCommon) ReadCommon(buf *bytes.Buffer) error

func (*MessageBlockCommon) WriteCommon

func (m *MessageBlockCommon) WriteCommon(buf *bytes.Buffer) error

type MessageConfirmAck

type MessageConfirmAck struct {
	MessageHeader
	MessageVote
}

func (*MessageConfirmAck) Read

func (m *MessageConfirmAck) Read(buf *bytes.Buffer) error

func (*MessageConfirmAck) Write

func (m *MessageConfirmAck) Write(buf *bytes.Buffer) error

type MessageConfirmReq

type MessageConfirmReq struct {
	MessageHeader
	MessageBlock
}

func (*MessageConfirmReq) Read

func (m *MessageConfirmReq) Read(buf *bytes.Buffer) error

func (*MessageConfirmReq) Write

func (m *MessageConfirmReq) Write(buf *bytes.Buffer) error

type MessageHeader

type MessageHeader struct {
	MagicNumber  [2]byte
	VersionMax   byte
	VersionUsing byte
	VersionMin   byte
	MessageType  byte
	Extensions   byte
	BlockType    byte
}

func (*MessageHeader) ReadHeader

func (m *MessageHeader) ReadHeader(buf *bytes.Buffer) error

func (*MessageHeader) WriteHeader

func (m *MessageHeader) WriteHeader(buf *bytes.Buffer) error

type MessageKeepAlive

type MessageKeepAlive struct {
	MessageHeader
	Peers []Peer
}

func CreateKeepAlive

func CreateKeepAlive(peers []Peer) *MessageKeepAlive

func (*MessageKeepAlive) Handle

func (m *MessageKeepAlive) Handle() error

func (*MessageKeepAlive) Read

func (m *MessageKeepAlive) Read(buf *bytes.Buffer) error

func (*MessageKeepAlive) Write

func (m *MessageKeepAlive) Write(buf *bytes.Buffer) error

type MessagePublish

type MessagePublish struct {
	MessageHeader
	MessageBlock
}

func (*MessagePublish) Read

func (m *MessagePublish) Read(buf *bytes.Buffer) error

func (*MessagePublish) Write

func (m *MessagePublish) Write(buf *bytes.Buffer) error

type MessageVote

type MessageVote struct {
	Account   [32]byte
	Signature [64]byte
	Sequence  [8]byte
	MessageBlock
}

func (*MessageVote) Hash

func (m *MessageVote) Hash() []byte

func (*MessageVote) Read

func (m *MessageVote) Read(messageBlockType byte, buf *bytes.Buffer) error

func (*MessageVote) Write

func (m *MessageVote) Write(buf *bytes.Buffer) error

type Peer

type Peer struct {
	IP           net.IP
	Port         uint16
	LastReachout *time.Time
}

func (*Peer) Addr

func (p *Peer) Addr() *net.UDPAddr

func (*Peer) SendMessage

func (p *Peer) SendMessage(m Message) error

func (*Peer) String

func (p *Peer) String() string

Jump to

Keyboard shortcuts

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