Documentation ¶
Index ¶
- func DecryptAES(key, ciphertext []byte) []byte
- func EncryptAES(key, plaintext []byte) []byte
- type Node
- func (N *Node) AddNeighbour(neighbour string)
- func (N *Node) FullStateCopyTimer(period time.Duration)
- func (N *Node) GetRandomNeighbour() string
- func (N *Node) Gossip() error
- func (N *Node) Listen(socket string, messages chan<- Rumour) error
- func (N *Node) RTTForward(RTTTarget, neighbour string) error
- func (N *Node) RTTTimer(period time.Duration, RTTChan chan bool) error
- func (N *Node) RemoveNeighbour(neighbour string)
- func (N *Node) RequestCopy(neighbour string) error
- func (N *Node) Send(neighbour string, rumour Rumour) error
- func (N *Node) SendNextRound(msg Rumour)
- func (N *Node) UpdateData(key, newvalue string)
- func (N *Node) UpdateJson()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecryptAES ¶
func EncryptAES ¶
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 ¶
Add a neighbour to a node, first making sure that the neighbour is not already stored
func (*Node) FullStateCopyTimer ¶
infinite! method which performs a RequestCopy every period
func (*Node) GetRandomNeighbour ¶
func (*Node) Listen ¶
An infinite! procedure that listens on the socket All values sent are passed onto the messages channel
func (*Node) RTTForward ¶
func (*Node) RTTTimer ¶
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 (*Node) RequestCopy ¶
Request a full state copy from neighbour
func (*Node) Send ¶
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)