gpa

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: Apache-2.0, BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Overview

package gpa stands for generic pure (distributed) algorithm.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AckHandler

type AckHandler interface {
	GPA
	MakeTickMsg(time.Time) Message
	NestedMessage(msg Message) OutMessages
	NestedCall(c func(GPA) OutMessages) OutMessages
}

func NewAckHandler

func NewAckHandler(me NodeID, nested GPA, resendPeriod time.Duration) AckHandler

type GPA

type GPA interface {
	Input(inp Input) OutMessages     // Can return nil for NoMessages.
	Message(msg Message) OutMessages // Can return nil for NoMessages.
	Output() Output
	StatusString() string // Status of the protocol as a string.
	UnmarshalMessage(data []byte) (Message, error)
}

Generic interface for functional style distributed algorithms. GPA stands for Generic Pure Algorithm.

func MakeTestSilentNode

func MakeTestSilentNode() GPA

func NewOwnHandler

func NewOwnHandler(me NodeID, target GPA) GPA

func NewTestRound

func NewTestRound(nodeIDs []NodeID, me NodeID) GPA

type Input

type Input interface{}

type Message

type Message interface {
	encoding.BinaryMarshaler
	Recipient() NodeID // The sender should indicate the recipient.
	SetSender(NodeID)  // The transport later will set a validated sender for a message.
}

type MsgWrapper

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

MsgWrapper can be used to compose an algorithm out of other abstractions. These messages are meant to wrap and route the messages of the sub-algorithms.

func NewMsgWrapper

func NewMsgWrapper(msgType byte, subsystemFunc func(subsystem byte, index int) (GPA, error)) *MsgWrapper

func (*MsgWrapper) UnmarshalMessage

func (w *MsgWrapper) UnmarshalMessage(data []byte) (Message, error)

func (*MsgWrapper) WrapMessage

func (w *MsgWrapper) WrapMessage(subsystem byte, index int, msg Message) Message

func (*MsgWrapper) WrapMessages

func (w *MsgWrapper) WrapMessages(subsystem byte, index int, msgs OutMessages) OutMessages

type NodeID

type NodeID string

func CopyNodeIDs

func CopyNodeIDs(nodeIDs []NodeID) []NodeID

func MakeTestNodeIDs

func MakeTestNodeIDs(prefix string, n int) []NodeID

func ShuffleNodeIDs

func ShuffleNodeIDs(nodeIDs []NodeID) []NodeID

type OutMessages

type OutMessages interface {
	//
	// Add single message to the out messages.
	Add(msg Message) OutMessages
	//
	// Add several messages.
	AddMany(msgs []Message) OutMessages
	//
	// Add all the messages collected to other OutMessages.
	// The added OutMsgs object is marked done here.
	AddAll(msgs OutMessages) OutMessages
	//
	// Mark this instance as freezed, after this it cannot be appended.
	Done() OutMessages
	//
	// Returns a number of elements in the collection.
	Count() int
	//
	// Iterates over the collection, stops on first error.
	// Collection can be appended while iterating.
	Iterate(callback func(msg Message) error) error
	//
	// Iterated over the collection.
	// Collection can be appended while iterating.
	MustIterate(callback func(msg Message))
	//
	// Returns contents of the collection as an array of messages.
	AsArray() []Message
}

A buffer for collecting out messages. It is used to decrease array reallocations, if a slice would be used directly. Additionally, you can safely append to the OutMessages while you iterate over it. It should be implemented as a deep-list, allowing efficient appends and iterations.

func NoMessages

func NoMessages() OutMessages

A convenience function to return from the Input or Message functions in GPA.

type Output

type Output interface{}

type OwnHandler

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

OwnHandler is a GPA instance handling own messages immediately.

The idea is instead of checking if a message for myself in the actual protocols, one just send a message, and this handler passes it back as an ordinary message.

func (*OwnHandler) Input

func (o *OwnHandler) Input(input Input) OutMessages

func (*OwnHandler) Message

func (o *OwnHandler) Message(msg Message) OutMessages

func (*OwnHandler) Output

func (o *OwnHandler) Output() Output

func (*OwnHandler) StatusString

func (o *OwnHandler) StatusString() string

func (*OwnHandler) UnmarshalMessage

func (o *OwnHandler) UnmarshalMessage(data []byte) (Message, error)

type TestContext

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

Imitates a cluster of nodes and the medium performing the message exchange.

func NewTestContext

func NewTestContext(nodes map[NodeID]GPA) *TestContext

func (*TestContext) AddInputs

func (tc *TestContext) AddInputs(inputs map[NodeID]Input)

Will add new inputs to the existing set. The inputs will be overridden, if exist for the same nodes.

func (*TestContext) NumberOfOutputs

func (tc *TestContext) NumberOfOutputs() int

Returns a number of non-nil outputs.

func (*TestContext) NumberOfOutputsPredicate

func (tc *TestContext) NumberOfOutputsPredicate(outNum int) func() bool

Will run until there will be at least outNum of non-nil outputs generated.

func (*TestContext) OutOfMessagesPredicate

func (tc *TestContext) OutOfMessagesPredicate() func() bool

Will run until all the messages will be processed.

func (*TestContext) RunAll

func (tc *TestContext) RunAll()

func (*TestContext) RunUntil

func (tc *TestContext) RunUntil(predicate func() bool)

func (*TestContext) WithCall

func (tc *TestContext) WithCall(call func() []Message) *TestContext

func (*TestContext) WithInputProbability

func (tc *TestContext) WithInputProbability(inputProb float64) *TestContext

func (*TestContext) WithInputs

func (tc *TestContext) WithInputs(inputs map[NodeID]Input) *TestContext

func (*TestContext) WithMessageDeliveryProbability

func (tc *TestContext) WithMessageDeliveryProbability(msgDeliveryProb float64) *TestContext

func (*TestContext) WithMessages

func (tc *TestContext) WithMessages(msgs []Message) *TestContext

type TestMessage

type TestMessage struct {
	ID int
	// contains filtered or unexported fields
}

Just a message for test cases.

func (*TestMessage) MarshalBinary

func (m *TestMessage) MarshalBinary() ([]byte, error)

func (*TestMessage) Recipient

func (m *TestMessage) Recipient() NodeID

func (*TestMessage) SetSender

func (m *TestMessage) SetSender(sender NodeID)

type WrappingMsg

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

The message that contains another, and its routing info.

func (*WrappingMsg) Index

func (m *WrappingMsg) Index() int

func (*WrappingMsg) MarshalBinary

func (m *WrappingMsg) MarshalBinary() ([]byte, error)

func (*WrappingMsg) Recipient

func (m *WrappingMsg) Recipient() NodeID

func (*WrappingMsg) SetSender

func (m *WrappingMsg) SetSender(sender NodeID)

func (*WrappingMsg) Subsystem

func (m *WrappingMsg) Subsystem() byte

func (*WrappingMsg) Wrapped

func (m *WrappingMsg) Wrapped() Message

Directories

Path Synopsis
aba
craig
TODO: That's Craig's "Good-Case-Coin-Free" ABA consensus.
TODO: That's Craig's "Good-Case-Coin-Free" ABA consensus.
mostefaoui
TODO: That's Mostefaoui ABA.
TODO: That's Mostefaoui ABA.
package acss implements "Asynchronous Complete Secret Sharing" as described in
package acss implements "Asynchronous Complete Secret Sharing" as described in
crypto
This package is a copy of <https://github.com/Wollac/async.go/tree/main/pkg/acss/crypto>
This package is a copy of <https://github.com/Wollac/async.go/tree/main/pkg/acss/crypto>
nonce
nonce package implements NonceDKG as described in <https://github.com/iotaledger/crypto-tss/>.
nonce package implements NonceDKG as described in <https://github.com/iotaledger/crypto-tss/>.
cc
blssig
blssig package implements a Common Coin (CC) based on a BLS Threshold signatures as described in the Appendix C of
blssig package implements a Common Coin (CC) based on a BLS Threshold signatures as described in the Appendix C of
semi
semi package implements a Common Coin (CC) that produces deterministic values only for some of the rounds.
semi package implements a Common Coin (CC) that produces deterministic values only for some of the rounds.
rbc
bracha
package bracha implements Bracha's Reliable Broadcast.
package bracha implements Bracha's Reliable Broadcast.

Jump to

Keyboard shortcuts

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