node

package
v0.0.0-...-1aec103 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2022 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptAES

func DecryptAES(key, ciphertext []byte) []byte

func EncryptAES

func EncryptAES(key, plaintext []byte) []byte

Types

type Node

type Node struct {
	Data       map[string]string // The core part of the Key-Value store, a dictionary.
	Neighbours []string          // List of all known nodes/neighbours.
	Timeout    time.Duration     // how long to wait before a TCP request is dropped as a fail
	RTTPeriod  time.Duration     // how long to wait before doing an RTT
	FSCPeriod  time.Duration     // how long to wait before doing a full state copy
	MaxRounds  int

	LANIP string // The local IP for the node
	Port  int    // The port which the node listens on
	// contains filtered or unexported fields
}

The Node encapsulates the information we are interested in replicating. It also communicates with other nodes which it knows of, so as to replicate data with them too.

func NewNode

func NewNode(knownNeighbours []string, IP string, key []byte, timeout, rttperiod, fscperiod time.Duration, portNumber, b, c int) Node

Construct a new Node knownNeighbours is the neighbours is starts of knowing socket is the socket it listens on each period is described in the Rumour structure b is the number of nodes it should send to each round c is the number added to the number of rounds, which should improve probability of consensus

func (*Node) AddNeighbour

func (N *Node) AddNeighbour(neighbour string)

Add a neighbour to a node, first making sure that the neighbour is not already stored

func (*Node) FullStateCopyTimer

func (N *Node) FullStateCopyTimer(period time.Duration)

infinite! method which performs a RequestCopy every period

func (*Node) GetRandomNeighbour

func (N *Node) GetRandomNeighbour() string

func (*Node) Gossip

func (N *Node) Gossip() error

infinite!

func (*Node) Listen

func (N *Node) Listen(socket string, messages chan<- Rumour) error

An infinite! procedure that listens on the socket All values sent are passed onto the messages channel

func (*Node) RTTForward

func (N *Node) RTTForward(RTTTarget, neighbour string) error

func (*Node) RTTTimer

func (N *Node) RTTTimer(period time.Duration, RTTChan chan bool) error

Every `period` amount of time, send an RTT to a random node. Follows up the RTT if Send returns an error.

func (*Node) RemoveNeighbour

func (N *Node) RemoveNeighbour(neighbour string)

func (*Node) RequestCopy

func (N *Node) RequestCopy(neighbour string) error

Request a full state copy from neighbour

func (*Node) Send

func (N *Node) Send(neighbour string, rumour Rumour) error

Given a neighbour and a rumour, send the rumour to that neighbour. Does not select a random neigbour or cycle.

func (*Node) SendNextRound

func (N *Node) SendNextRound(msg Rumour)

func (*Node) UpdateData

func (N *Node) UpdateData(key, newvalue string)

func (*Node) UpdateJson

func (N *Node) UpdateJson()

Update the data present in data.json

Jump to

Keyboard shortcuts

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