node

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: MIT Imports: 11 Imported by: 3

Documentation

Overview

Package Node contains node logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mode

type Mode int

Mode represents the synchronization mode.

const (
	INTERACTIVE Mode = iota
	BATCH
)

type Node

type Node struct {
	ID state.PeerID
	// contains filtered or unexported fields
}

Node represents an MVDS node, it runs all the logic like sending and receiving protocol messages.

func NewNode

func NewNode(
	ms store.MessageStore,
	st transport.Transport,
	ss state.SyncState,
	nextEpoch calculateNextEpoch,
	currentEpoch int64,
	id state.PeerID,
	mode Mode,
) *Node

NewNode returns a new node.

func (*Node) AddPeer

func (n *Node) AddPeer(group state.GroupID, id state.PeerID)

AddPeer adds a peer to a specific group making it a recipient of messages.

func (*Node) AppendMessage

func (n *Node) AppendMessage(group state.GroupID, data []byte) (state.MessageID, error)

AppendMessage sends a message to a given group.

func (Node) IsPeerInGroup

func (n Node) IsPeerInGroup(g state.GroupID, p state.PeerID) bool

IsPeerInGroup checks whether a peer is in the specified group.

func (*Node) Start added in v0.0.14

func (n *Node) Start()

Start listens for new messages received by the node and sends out those required every epoch.

func (*Node) Stop added in v0.0.14

func (n *Node) Stop()

Stop message reading and epoch processing

Jump to

Keyboard shortcuts

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