consensus

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package consensus provides BFT-like algorithm to distribute list of records between participants

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Communicator

type Communicator interface {
	// ExchangeData used in first consensus step to exchange data between participants
	ExchangeData(ctx context.Context, p Participant, data []*core.ActiveNode) ([]*core.ActiveNode, error)

	// ExchangeHash used in second consensus step to exchange only hashes of merged data vectors
	ExchangeHash(ctx context.Context, p Participant, data []byte) ([]byte, error)
}

Communicator interface is used to exchange messages between participants

type Consensus

type Consensus interface {
	// DoConsensus is sync method, it make all consensus steps and returns boolean result
	// method should be executed in goroutine
	DoConsensus(ctx context.Context, self Participant, allParticipants []*Participant) (bool, error)
}

Consensus interface provides method to make consensus between participants

func NewConsensus

func NewConsensus(provider DataProvider, communicator Communicator) (Consensus, error)

NewConsensus creates consensus

type DataProvider

type DataProvider interface {
	GetDataList() []*core.ActiveNode
	MergeDataList([]*core.ActiveNode) error
}

DataProvider for data manipulation

type Participant

type Participant interface {
	GetActiveNode() *core.ActiveNode
}

Participant describes one consensus participant

Jump to

Keyboard shortcuts

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