replication

package
v0.0.0-...-d1fccd7 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2019 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Broadcaster

func Broadcaster(sync *Sync, frame *network.Frame, outputConn net.PacketConn, input chan *network.Blobs)

Broadcaster thread is responsible for broadcasting blocks from producer to signers

func New

func New(bm *books.Accounts, blobsReceiver <-chan *network.Blobs)

New runs goroutine which in infinite loop replicates blocks

func SyncGenerator

func SyncGenerator(sync *Sync, sleep time.Duration) <-chan *network.Blob

SyncGenerator thread sends sync request to the random node in every 100 millisecond

func SyncListener

func SyncListener(sync *Sync, input <-chan *network.Blobs) <-chan *network.Blobs

SyncListener is a thread responsible for receiving updates from sync channel TODO optimize: there should be pointers in Blobs

func Transporter

func Transporter(sync *Sync, input <-chan *network.Blobs, outputConn net.PacketConn)

Transporter thread is responsible for transporting producer blocks to other signers

Types

type Addresses

type Addresses struct {
	Sync        net.UDPAddr
	Replication net.UDPAddr
	Message     net.UDPAddr
	Transaction net.UDPAddr
	Repair      net.UDPAddr
}

Addresses represents network addresses for different pipelines

func (*Addresses) Equals

func (a *Addresses) Equals(other *Addresses) bool

Equals comapres two Addresses

type GetUpdates

type GetUpdates struct {
	LastUpdateIndex uint64
	MyInfo          *NodeData
}

GetUpdates is struct for requesting updates for Sync

func (*GetUpdates) Deserialize

func (req *GetUpdates) Deserialize(blob *network.Blob)

Deserialize method is for turning Blobs into GetUpdates

func (*GetUpdates) Serialize

func (req *GetUpdates) Serialize() *network.Blob

Serialize method is for turning GetUpdates into blobs

type Node

type Node struct {
	Data    *NodeData
	Sockets Sockets
}

Node saves the data of a user node

func NewNode

func NewNode(nodeType string, name string) Node

NewNode creates new Node

func NewProducerNode

func NewProducerNode(nodeType string, name string) Node

type NodeData

type NodeData struct {
	Self          ed25519.PublicKey
	Version       uint64
	Addresses     Addresses
	Producer      ed25519.PublicKey
	ValidVDFValue block.VDFValue
	NodeType      string
	NodeName      string
}

NodeData represents structure for replication through sync

func NewNodeData

func NewNodeData(self ed25519.PublicKey, nodeType string, name string, sync net.UDPAddr, replication net.UDPAddr,
	request net.UDPAddr, transaction net.UDPAddr, repair net.UDPAddr) *NodeData

NewNodeData returns new NodeIno struct

func (*NodeData) Copy

func (n *NodeData) Copy() *NodeData

Copy copies NodeData object TODO maybe should be changed to deep copy

func (*NodeData) Equals

func (n *NodeData) Equals(other *NodeData) bool

Equals compares two NodeData

func (*NodeData) String

func (n *NodeData) String() string

String method returns identity of NodeData.Self for debuging purposes

type Sockets

type Sockets struct {
	Sync        net.PacketConn
	SyncSend    net.PacketConn
	Messages    net.PacketConn
	Replicate   net.PacketConn
	Transaction net.PacketConn
	Respond     net.PacketConn
	Broadcast   net.PacketConn
	Repair      net.PacketConn
	Transport   net.PacketConn
}

Sockets struct saves all sockets of the node

type Sync

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

Sync struct is responsible for replication

func NewSync

func NewSync(me *NodeData) (*Sync, error)

NewSync returns new Sync struct

func (*Sync) AllNodesExceptMe

func (c *Sync) AllNodesExceptMe(me ed25519.PublicKey) []*NodeData

AllNodesExceptMe returns all nodes from sync except me node

func (*Sync) ChangeProducer

func (c *Sync) ChangeProducer(key ed25519.PublicKey)

ChangeProducer updates producer with new one

func (*Sync) ConnectedNodes

func (c *Sync) ConnectedNodes() uint64

ConnectedNodes is responsible to calculate number of remote nodes

func (*Sync) Insert

func (c *Sync) Insert(info *NodeData)

Insert method will insert new NodeData into the table

func (*Sync) MyCopy

func (c *Sync) MyCopy() *NodeData

MyCopy returns a copy of my NodeData saved in the table

func (*Sync) MyNodeData

func (c *Sync) MyNodeData() *NodeData

MyNodeData returns my NodeData saved in the table

func (*Sync) ProducerNodeData

func (c *Sync) ProducerNodeData() *NodeData

ProducerNodeData returns producer's NodeData saved in the table

func (*Sync) RandomNode

func (c *Sync) RandomNode() (*NodeData, error)

func (*Sync) RemoteTableCopy

func (c *Sync) RemoteTableCopy() map[string]*NodeData

RemoteTableCopy returns a copy of the remote nodes

func (*Sync) String

func (c *Sync) String() string

String method returns identity of me for debuging purposes

func (*Sync) TableCopy

func (c *Sync) TableCopy() map[string]*NodeData

TableCopy returns a copy of a Sync table

type Updates

type Updates struct {
	From            ed25519.PublicKey
	LastUpdateIndex uint64
	Updates         []*NodeData
}

Updates is a struct for receiving updates for Sync

func (*Updates) Deserialize

func (rec *Updates) Deserialize(blob *network.Blob)

Deserialize method is for turning Blobs into Updates

func (*Updates) Serialize

func (rec *Updates) Serialize() *network.Blob

Serialize method is for turning Updates into blobs

Jump to

Keyboard shortcuts

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