network

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const MINIMUM_NUMBER_OF_NODES_FOR_CONSENSUS = 4

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	ElectionTrigger     interfaces.ElectionTrigger
	BlockUtils          *mocks.MockBlockUtils
	KeyManager          *mocks.MockKeyManager
	Storage             interfaces.Storage
	Communication       *mocks.CommunicationMock
	Membership          interfaces.Membership
	MemberId            primitives.MemberId
	NodeStateChannel    chan *NodeState
	WriteToStateChannel bool
	// contains filtered or unexported fields
}

func ADummyNode

func ADummyNode() *Node

func NewNode

func NewNode(
	instanceId primitives.InstanceId,
	membership interfaces.Membership,
	communication *mocks.CommunicationMock,
	blockUtils *mocks.MockBlockUtils,
	electionTrigger interfaces.ElectionTrigger,
	logger interfaces.Logger) *Node

func (*Node) BuildConfig

func (node *Node) BuildConfig(logger interfaces.Logger) *interfaces.Config

func (*Node) GetBlockProofAt

func (node *Node) GetBlockProofAt(height primitives.BlockHeight) []byte

func (*Node) GetKeyManager

func (node *Node) GetKeyManager() interfaces.KeyManager

func (*Node) GetLatestBlock

func (node *Node) GetLatestBlock() interfaces.Block

func (*Node) GetLatestBlockProof

func (node *Node) GetLatestBlockProof() []byte

func (*Node) GetMemberId

func (node *Node) GetMemberId() primitives.MemberId

func (*Node) StartConsensus

func (node *Node) StartConsensus(ctx context.Context)

func (*Node) StartConsensusSync

func (node *Node) StartConsensusSync(ctx context.Context)

func (*Node) Sync

func (node *Node) Sync(ctx context.Context, prevBlock interfaces.Block, blockProofBytes []byte, prevBlockProofBytes []byte)

func (*Node) TriggerElection

func (node *Node) TriggerElection(ctx context.Context)

func (*Node) ValidateBlockConsensus

func (node *Node) ValidateBlockConsensus(ctx context.Context, block interfaces.Block, blockProof []byte, prevBlockProof []byte) error

type NodeBuilder

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

func NewNodeBuilder

func NewNodeBuilder() *NodeBuilder

func (*NodeBuilder) AsInstanceId

func (builder *NodeBuilder) AsInstanceId(instanceId primitives.InstanceId) *NodeBuilder

func (*NodeBuilder) Build

func (builder *NodeBuilder) Build() *Node

func (*NodeBuilder) CommunicatesVia

func (builder *NodeBuilder) CommunicatesVia(communication *mocks.CommunicationMock) *NodeBuilder

func (*NodeBuilder) ThatIsPartOf

func (builder *NodeBuilder) ThatIsPartOf(membership interfaces.Membership) *NodeBuilder

func (*NodeBuilder) ThatLogsToConsole

func (builder *NodeBuilder) ThatLogsToConsole() *NodeBuilder

func (*NodeBuilder) WithBlocksPool

func (builder *NodeBuilder) WithBlocksPool(blocksPool *mocks.BlocksPool) *NodeBuilder

func (*NodeBuilder) WithElectionTrigger

func (builder *NodeBuilder) WithElectionTrigger(electionTrigger interfaces.ElectionTrigger) *NodeBuilder

func (*NodeBuilder) WithMemberId

func (builder *NodeBuilder) WithMemberId(memberId primitives.MemberId) *NodeBuilder

type NodeState

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

type TestNetwork

type TestNetwork struct {
	InstanceId primitives.InstanceId
	Nodes      []*Node
	Discovery  *mocks.Discovery
}

func ABasicTestNetwork

func ABasicTestNetwork() *TestNetwork

func ATestNetwork

func ATestNetwork(countOfNodes int, blocksPool ...interfaces.Block) *TestNetwork

func NewTestNetwork

func NewTestNetwork(instanceId primitives.InstanceId, discovery *mocks.Discovery) *TestNetwork

func (*TestNetwork) AllNodesChainEndsWithABlock

func (net *TestNetwork) AllNodesChainEndsWithABlock(block interfaces.Block) bool

func (*TestNetwork) AllNodesValidatedNoMoreThanOnceBeforeCommit

func (net *TestNetwork) AllNodesValidatedNoMoreThanOnceBeforeCommit(ctx context.Context) bool

func (*TestNetwork) GetNodeCommunication

func (net *TestNetwork) GetNodeCommunication(memberId primitives.MemberId) *mocks.CommunicationMock

func (*TestNetwork) NodesPauseOnValidate

func (net *TestNetwork) NodesPauseOnValidate(nodes ...*Node)

func (*TestNetwork) RegisterNode

func (net *TestNetwork) RegisterNode(node *Node)

func (*TestNetwork) RegisterNodes

func (net *TestNetwork) RegisterNodes(nodes []*Node)

func (*TestNetwork) ResumeNodeRequestNewBlock

func (net *TestNetwork) ResumeNodeRequestNewBlock(ctx context.Context, node *Node)

func (*TestNetwork) ResumeNodesValidation

func (net *TestNetwork) ResumeNodesValidation(ctx context.Context, nodes ...*Node)

func (*TestNetwork) SetNodesToPauseOnRequestNewBlock

func (net *TestNetwork) SetNodesToPauseOnRequestNewBlock(nodes ...*Node)

func (*TestNetwork) StartConsensus

func (net *TestNetwork) StartConsensus(ctx context.Context) *TestNetwork

func (*TestNetwork) StartConsensusSync

func (net *TestNetwork) StartConsensusSync(ctx context.Context) *TestNetwork

func (*TestNetwork) TriggerElection

func (net *TestNetwork) TriggerElection(ctx context.Context)

func (*TestNetwork) WaitForAllNodesToCommitBlock

func (net *TestNetwork) WaitForAllNodesToCommitBlock(ctx context.Context, block interfaces.Block) bool

func (*TestNetwork) WaitForAllNodesToCommitTheSameBlock

func (net *TestNetwork) WaitForAllNodesToCommitTheSameBlock(ctx context.Context) bool

func (*TestNetwork) WaitForConsensus

func (net *TestNetwork) WaitForConsensus(ctx context.Context)

func (*TestNetwork) WaitForNodeToRequestNewBlock

func (net *TestNetwork) WaitForNodeToRequestNewBlock(ctx context.Context, node *Node)

func (*TestNetwork) WaitForNodesToCommitABlock

func (net *TestNetwork) WaitForNodesToCommitABlock(ctx context.Context, nodes ...*Node)

func (*TestNetwork) WaitForNodesToCommitASpecificBlock

func (net *TestNetwork) WaitForNodesToCommitASpecificBlock(ctx context.Context, block interfaces.Block, nodes ...*Node) bool

func (*TestNetwork) WaitForNodesToValidate

func (net *TestNetwork) WaitForNodesToValidate(ctx context.Context, nodes ...*Node)

type TestNetworkBuilder

type TestNetworkBuilder struct {
	NodeCount int
	// contains filtered or unexported fields
}

func NewTestNetworkBuilder

func NewTestNetworkBuilder() *TestNetworkBuilder

func (*TestNetworkBuilder) Build

func (tb *TestNetworkBuilder) Build() *TestNetwork

func (*TestNetworkBuilder) GossipMessagesMaxDelay

func (tb *TestNetworkBuilder) GossipMessagesMaxDelay(duration time.Duration) *TestNetworkBuilder

func (*TestNetworkBuilder) InNetwork

func (builder *TestNetworkBuilder) InNetwork(instanceId primitives.InstanceId) *TestNetworkBuilder

func (*TestNetworkBuilder) LogToConsole

func (tb *TestNetworkBuilder) LogToConsole() *TestNetworkBuilder

func (*TestNetworkBuilder) OrderCommitteeByHeight

func (tb *TestNetworkBuilder) OrderCommitteeByHeight() *TestNetworkBuilder

func (*TestNetworkBuilder) WithBlockUtils

func (tb *TestNetworkBuilder) WithBlockUtils(utils interfaces.BlockUtils) *TestNetworkBuilder

func (*TestNetworkBuilder) WithBlocks

func (tb *TestNetworkBuilder) WithBlocks(upcomingBlocks []interfaces.Block) *TestNetworkBuilder

func (*TestNetworkBuilder) WithCommunication

func (tb *TestNetworkBuilder) WithCommunication(communication interfaces.Communication) *TestNetworkBuilder

func (*TestNetworkBuilder) WithCustomNodeBuilder

func (tb *TestNetworkBuilder) WithCustomNodeBuilder(nodeBuilder *NodeBuilder) *TestNetworkBuilder

func (*TestNetworkBuilder) WithKeyManager

func (*TestNetworkBuilder) WithNodeCount

func (tb *TestNetworkBuilder) WithNodeCount(nodeCount int) *TestNetworkBuilder

func (*TestNetworkBuilder) WithTimeBasedElectionTrigger

func (tb *TestNetworkBuilder) WithTimeBasedElectionTrigger(timeout time.Duration) *TestNetworkBuilder

Jump to

Keyboard shortcuts

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