sender

package
v0.0.0-...-3fa05c8 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Overview

Package sender is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(
	ctx *snow.ConsensusContext,
	msgCreator message.OutboundMsgBuilder,
	externalSender ExternalSender,
	router router.Router,
	timeouts timeout.Manager,
	engineType p2p.EngineType,
	subnet subnets.Subnet,
) (common.Sender, error)

func Trace

func Trace(sender common.Sender, tracer trace.Tracer) common.Sender

Types

type ExternalSender

type ExternalSender interface {
	// Send a message to a specific set of nodes
	Send(
		msg message.OutboundMessage,
		nodeIDs set.Set[ids.NodeID],
		subnetID ids.ID,
		allower subnets.Allower,
	) set.Set[ids.NodeID]

	// Send a message to a random group of nodes in a subnet.
	// Nodes are sampled based on their validator status.
	Gossip(
		msg message.OutboundMessage,
		subnetID ids.ID,
		numValidatorsToSend int,
		numNonValidatorsToSend int,
		numPeersToSend int,
		allower subnets.Allower,
	) set.Set[ids.NodeID]
}

ExternalSender sends consensus messages to other validators Right now this is implemented in the networking package

type ExternalSenderTest

type ExternalSenderTest struct {
	TB testing.TB

	CantSend, CantGossip bool

	SendF   func(msg message.OutboundMessage, nodeIDs set.Set[ids.NodeID], subnetID ids.ID, allower subnets.Allower) set.Set[ids.NodeID]
	GossipF func(msg message.OutboundMessage, subnetID ids.ID, numValidatorsToSend, numNonValidatorsToSend, numPeersToSend int, allower subnets.Allower) set.Set[ids.NodeID]
}

ExternalSenderTest is a test sender

func (*ExternalSenderTest) Default

func (s *ExternalSenderTest) Default(cant bool)

Default set the default callable value to [cant]

func (*ExternalSenderTest) Gossip

func (s *ExternalSenderTest) Gossip(
	msg message.OutboundMessage,
	subnetID ids.ID,
	numValidatorsToSend int,
	numNonValidatorsToSend int,
	numPeersToSend int,
	allower subnets.Allower,
) set.Set[ids.NodeID]

Given a msg type, the corresponding mock function is called if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*ExternalSenderTest) Send

func (s *ExternalSenderTest) Send(
	msg message.OutboundMessage,
	nodeIDs set.Set[ids.NodeID],
	subnetID ids.ID,
	allower subnets.Allower,
) set.Set[ids.NodeID]

type MockExternalSender

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

MockExternalSender is a mock of ExternalSender interface.

func NewMockExternalSender

func NewMockExternalSender(ctrl *gomock.Controller) *MockExternalSender

NewMockExternalSender creates a new mock instance.

func (*MockExternalSender) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockExternalSender) Gossip

func (m *MockExternalSender) Gossip(arg0 message.OutboundMessage, arg1 ids.ID, arg2, arg3, arg4 int, arg5 subnets.Allower) set.Set[ids.NodeID]

Gossip mocks base method.

func (*MockExternalSender) Send

Send mocks base method.

type MockExternalSenderMockRecorder

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

MockExternalSenderMockRecorder is the mock recorder for MockExternalSender.

func (*MockExternalSenderMockRecorder) Gossip

func (mr *MockExternalSenderMockRecorder) Gossip(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call

Gossip indicates an expected call of Gossip.

func (*MockExternalSenderMockRecorder) Send

func (mr *MockExternalSenderMockRecorder) Send(arg0, arg1, arg2, arg3 interface{}) *gomock.Call

Send indicates an expected call of Send.

Jump to

Keyboard shortcuts

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