p2p

package
v0.0.0-...-bc3f6f8 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const MaxCount = 10

MaxCount represents the number of outgoing connections a gossip node should make

Variables

View Source
var ConfigFile = flag.String("config", "", "config file created for the exp.")
View Source
var Ids arrayFlags
View Source
var Master = flag.String("master", "", "master address to synchronize")
View Source
var SyncAddr = flag.String("sync", "", "address to listen for master START")

Functions

func IsIncluded

func IsIncluded(arr []int, v int) bool

IsIncluded returns true if the index is contained in the array

func Run

func Run(a Adaptor)

Run starts the simulation

Types

type Adaptor

type Adaptor interface {
	Make(ctx context.Context, nodes lib.NodeList, ids []int, threshold int, opts Opts) (handel.Registry, []Node)
}

Adaptor is an interface that gives back the registry and nodes from the list of node read from the simulation registry file

type AdaptorFunc

type AdaptorFunc func(ctx context.Context, nodes lib.NodeList, ids []int, threshold int, opts Opts) (handel.Registry, []Node)

AdaptorFunc returns an Adaptor out of a func

func WithConnector

func WithConnector(a AdaptorFunc) AdaptorFunc

WithConnector returns a Adaptor that also connects the nodes according to the connector specified in the opts.

func WithPostFunc

func WithPostFunc(a AdaptorFunc, fn func(reg handel.Registry, ns []Node)) AdaptorFunc

WithPostFunc returns an Adaptor that executes a function after the given Adaptor

func (AdaptorFunc) Make

func (a AdaptorFunc) Make(ctx context.Context, nodes lib.NodeList, ids []int, threshold int, opts Opts) (handel.Registry, []Node)

Make implements the Adaptor interface

type Aggregator

type Aggregator struct {
	sync.Mutex
	Node
	// contains filtered or unexported fields
}

Aggregator is a struct holding the logic to aggregates all signatures gossiped until it gets the final one

func MakeAggregators

func MakeAggregators(ctx context.Context, c lib.Constructor, nodes []Node, reg handel.Registry, threshold int, opts Opts) []*Aggregator

MakeAggregators returns

func NewAggregator

func NewAggregator(ctx context.Context, n Node, r handel.Registry, c handel.Constructor, sig handel.Signature, threshold int, resendPeriod time.Duration, aggAndVerify bool) *Aggregator

NewAggregator returns an aggregator from the P2PNode

func (*Aggregator) FinalMultiSignature

func (a *Aggregator) FinalMultiSignature() chan *handel.MultiSignature

FinalMultiSignature returns a channel that is used to signal the final multisignature is ready

func (*Aggregator) Start

func (a *Aggregator) Start()

Start the aggregation for this node's perspective

type Connector

type Connector interface {
	Connect(node Node, ids handel.Registry, max int) error
}

Connector holds the logic to connect a node to a set of IDs on the overlay network

func ExtractConnector

func ExtractConnector(opts Opts) (Connector, int)

ExtractConnector returns connector

func NewNeighborConnector

func NewNeighborConnector() Connector

NewNeighborConnector returns a connector that connects to its most immediate neighbors - ids.

func NewRandomConnector

func NewRandomConnector() Connector

NewRandomConnector returns a Connector that connects nodes randomly

type ConsFunc

type ConsFunc func(ctx context.Context, nodes []*lib.Node, ids []int, opts map[string]string) (handel.Registry, []Node)

ConsFunc is a type to implement Constructor for a func

func (*ConsFunc) Make

func (c *ConsFunc) Make(ctx context.Context, nodes []*lib.Node, ids []int, opts map[string]string) (handel.Registry, []Node)

Make implements the Constructor interface

type CtxKey

type CtxKey string

CtxKey is the type inserted at key value in context

type Node

type Node interface {
	monitor.Counter
	Identity() handel.Identity
	SecretKey() lib.SecretKey
	Diffuse(*handel.Packet)
	Connect(handel.Identity) error
	Next() chan handel.Packet
}

Node is an interface to be used by an Aggregator

type Opts

type Opts map[string]string

Opts represents generic string like options given in the TOML-encoded config

func (*Opts) Int

func (o *Opts) Int(k string) (int, bool)

Int returns the value stored at the given key converted to an int

func (*Opts) String

func (o *Opts) String(k string) (string, bool)

Directories

Path Synopsis
package udp enforces each node broadcasts to everybody
package udp enforces each node broadcasts to everybody

Jump to

Keyboard shortcuts

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