sender

package
v1.6.2-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: BSD-3-Clause Imports: 10 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppSender added in v1.5.3

type AppSender interface {
	// Send an application-level request
	SendAppRequest(nodeIDs ids.ShortSet, chainID ids.ID, requestID uint32, deadline time.Duration, appRequestBytes []byte) []ids.ShortID
	// Send an application-level response to a request
	SendAppResponse(nodeID ids.ShortID, chainID ids.ID, requestID uint32, appResponseBytes []byte)
	// Gossip an application-level message
	SendAppGossip(subnetID, chainID ids.ID, appGossipBytes []byte, validatorOnly bool)
	SendAppGossipSpecific(nodeIDs ids.ShortSet, subnetID, chainID ids.ID, appGossipBytes []byte, validatorOnly bool)
}

AppSender sends app-level messages

type ExternalSender

type ExternalSender interface {
	AppSender

	// Send a GetAcceptedFrontier message for chain [chainID] to validators in [nodeIDs].
	// The validator should reply by [deadline].
	// Returns the IDs of validators that may receive the message.
	// If we're not connected to a validator in [nodeIDs], for example,
	// it will not be included in the return value.
	SendGetAcceptedFrontier(nodeIDs ids.ShortSet, chainID ids.ID, requestID uint32, deadline time.Duration) []ids.ShortID
	SendAcceptedFrontier(nodeID ids.ShortID, chainID ids.ID, requestID uint32, containerIDs []ids.ID)

	SendGetAccepted(nodeIDs ids.ShortSet, chainID ids.ID, requestID uint32, deadline time.Duration, containerIDs []ids.ID) []ids.ShortID
	SendAccepted(nodeID ids.ShortID, chainID ids.ID, requestID uint32, containerIDs []ids.ID)

	// Request ancestors of container [containerID] in chain [chainID] from validator [nodeID].
	// The validator should reply by [deadline].
	// Returns true if the validator may receive the message.
	// If we're not connected to [nodeID], for example, returns false.
	SendGetAncestors(nodeID ids.ShortID, chainID ids.ID, requestID uint32, deadline time.Duration, containerID ids.ID) bool
	SendMultiPut(nodeID ids.ShortID, chainID ids.ID, requestID uint32, containers [][]byte)

	SendGet(nodeID ids.ShortID, chainID ids.ID, requestID uint32, deadline time.Duration, containerID ids.ID) bool
	SendPut(nodeID ids.ShortID, chainID ids.ID, requestID uint32, containerID ids.ID, container []byte)

	SendPushQuery(nodeIDs ids.ShortSet, chainID ids.ID, requestID uint32, deadline time.Duration, containerID ids.ID, container []byte) []ids.ShortID
	SendPullQuery(nodeIDs ids.ShortSet, chainID ids.ID, requestID uint32, deadline time.Duration, containerID ids.ID) []ids.ShortID
	SendChits(nodeID ids.ShortID, chainID ids.ID, requestID uint32, votes []ids.ID)

	SendGossip(subnetID, chainID, containerID ids.ID, container []byte, validatorOnly bool)
}

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

type ExternalSenderTest

type ExternalSenderTest struct {
	T *testing.T
	B *testing.B

	CantSendGetAcceptedFrontier, CantSendAcceptedFrontier,
	CantSendGetAccepted, CantSendAccepted,
	CantSendGetAncestors, CantSendMultiPut,
	CantSendGet, CantSendPut,
	CantSendPullQuery, CantSendPushQuery, CantSendChits,
	CantSendGossip,
	CantSendAppRequest, CantSendAppResponse, CantSendAppGossip, CantSendAppGossipSpecific bool

	SendGetAcceptedFrontierF func(nodeIDs ids.ShortSet, chainID ids.ID, requestID uint32, deadline time.Duration) []ids.ShortID
	SendAcceptedFrontierF    func(nodeID ids.ShortID, chainID ids.ID, requestID uint32, containerIDs []ids.ID)

	SendGetAcceptedF func(nodeIDs ids.ShortSet, chainID ids.ID, requestID uint32, deadline time.Duration, containerIDs []ids.ID) []ids.ShortID
	SendAcceptedF    func(nodeID ids.ShortID, chainID ids.ID, requestID uint32, containerIDs []ids.ID)

	SendGetAncestorsF func(nodeID ids.ShortID, chainID ids.ID, requestID uint32, deadline time.Duration, containerID ids.ID) bool
	SendMultiPutF     func(nodeID ids.ShortID, chainID ids.ID, requestID uint32, containers [][]byte)

	SendGetF func(nodeID ids.ShortID, chainID ids.ID, requestID uint32, deadline time.Duration, containerID ids.ID) bool
	SendPutF func(nodeID ids.ShortID, chainID ids.ID, requestID uint32, containerID ids.ID, container []byte)

	SendPushQueryF func(nodeIDs ids.ShortSet, chainID ids.ID, requestID uint32, deadline time.Duration, containerID ids.ID, container []byte) []ids.ShortID
	SendPullQueryF func(nodeIDs ids.ShortSet, chainID ids.ID, requestID uint32, deadline time.Duration, containerID ids.ID) []ids.ShortID
	SendChitsF     func(nodeID ids.ShortID, chainID ids.ID, requestID uint32, votes []ids.ID)

	SendGossipF func(subnetID, chainID, containerID ids.ID, container []byte, validatorOnly bool)

	SendAppRequestF        func(nodeIDs ids.ShortSet, chainID ids.ID, requestID uint32, deadline time.Duration, appRequestBytes []byte) []ids.ShortID
	SendAppResponseF       func(nodeIDs ids.ShortID, chainID ids.ID, requestID uint32, appResponseBytyes []byte)
	SendAppGossipF         func(subnetID, chainID ids.ID, appGossipBytyes []byte, validatorOnly bool)
	SendAppGossipSpecificF func(nodeIDs ids.ShortSet, subnetID, chainID ids.ID, appGossipBytyes []byte, validatorOnly bool)
}

ExternalSenderTest is a test sender

func (*ExternalSenderTest) Default

func (s *ExternalSenderTest) Default(cant bool)

Default set the default callable value to [cant]

func (*ExternalSenderTest) SendAccepted added in v1.5.3

func (s *ExternalSenderTest) SendAccepted(nodeID ids.ShortID, chainID ids.ID, requestID uint32, containerIDs []ids.ID)

SendAccepted calls SendAcceptedF 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) SendAcceptedFrontier added in v1.5.3

func (s *ExternalSenderTest) SendAcceptedFrontier(nodeID ids.ShortID, chainID ids.ID, requestID uint32, containerIDs []ids.ID)

SendAcceptedFrontier calls SendAcceptedFrontierF 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) SendAppGossip added in v1.5.3

func (s *ExternalSenderTest) SendAppGossip(subnetID, chainID ids.ID, appGossipBytes []byte, validatorOnly bool)

SendAppGossip calls SendAppGossipF 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) SendAppGossipSpecific added in v1.6.2

func (s *ExternalSenderTest) SendAppGossipSpecific(nodeIDs ids.ShortSet, subnetID, chainID ids.ID, appGossipBytes []byte, validatorOnly bool)

SendAppGossipSpecific calls SendAppGossipSpecificF 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) SendAppRequest added in v1.5.3

func (s *ExternalSenderTest) SendAppRequest(nodeIDs ids.ShortSet, chainID ids.ID, requestID uint32, deadline time.Duration, appRequestBytes []byte) []ids.ShortID

SendAppRequest calls SendAppRequestF 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) SendAppResponse added in v1.5.3

func (s *ExternalSenderTest) SendAppResponse(nodeID ids.ShortID, chainID ids.ID, requestID uint32, appResponseBytes []byte)

SendAppResponse calls SendAppResponseF 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) SendChits added in v1.5.3

func (s *ExternalSenderTest) SendChits(vdr ids.ShortID, chainID ids.ID, requestID uint32, votes []ids.ID)

SendChits calls SendChitsF 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) SendGet added in v1.5.3

func (s *ExternalSenderTest) SendGet(vdr ids.ShortID, chainID ids.ID, requestID uint32, deadline time.Duration, vtxID ids.ID) bool

SendGet calls SendGetF 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) SendGetAccepted added in v1.5.3

func (s *ExternalSenderTest) SendGetAccepted(nodeIDs ids.ShortSet, chainID ids.ID, requestID uint32, deadline time.Duration, containerIDs []ids.ID) []ids.ShortID

SendGetAccepted calls SendGetAcceptedF 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) SendGetAcceptedFrontier added in v1.5.3

func (s *ExternalSenderTest) SendGetAcceptedFrontier(nodeIDs ids.ShortSet, chainID ids.ID, requestID uint32, deadline time.Duration) []ids.ShortID

SendGetAcceptedFrontier calls SendGetAcceptedFrontierF 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) SendGetAncestors added in v1.5.3

func (s *ExternalSenderTest) SendGetAncestors(vdr ids.ShortID, chainID ids.ID, requestID uint32, deadline time.Duration, vtxID ids.ID) bool

SendGetAncestors calls SendGetAncestorsF 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) SendGossip added in v1.5.3

func (s *ExternalSenderTest) SendGossip(subnetID, chainID, containerID ids.ID, container []byte, validatorOnly bool)

SendGossip calls SendGossipF 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) SendMultiPut added in v1.5.3

func (s *ExternalSenderTest) SendMultiPut(vdr ids.ShortID, chainID ids.ID, requestID uint32, vtxs [][]byte)

SendMultiPut calls SendMultiPutF 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) SendPullQuery added in v1.5.3

func (s *ExternalSenderTest) SendPullQuery(vdrs ids.ShortSet, chainID ids.ID, requestID uint32, deadline time.Duration, vtxID ids.ID) []ids.ShortID

SendPullQuery calls SendPullQueryF 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) SendPushQuery added in v1.5.3

func (s *ExternalSenderTest) SendPushQuery(vdrs ids.ShortSet, chainID ids.ID, requestID uint32, deadline time.Duration, vtxID ids.ID, vtx []byte) []ids.ShortID

SendPushQuery calls SendPushQueryF 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) SendPut added in v1.5.3

func (s *ExternalSenderTest) SendPut(vdr ids.ShortID, chainID ids.ID, requestID uint32, vtxID ids.ID, vtx []byte)

SendPut calls SendPutF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

type Sender

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

Sender is a wrapper around an ExternalSender. Messages to this node are put directly into router rather than being sent over the network via the wrapped ExternalSender. Sender registers outbound requests with router so that router fires a timeout if we don't get a response to the request.

func (*Sender) Context

func (s *Sender) Context() *snow.Context

Context of this sender

func (*Sender) Initialize

func (s *Sender) Initialize(
	ctx *snow.Context,
	sender ExternalSender,
	router router.Router,
	timeouts *timeout.Manager,
	metricsNamespace string,
	metricsRegisterer prometheus.Registerer,
) error

Initialize this sender

func (*Sender) SendAccepted added in v1.5.3

func (s *Sender) SendAccepted(nodeID ids.ShortID, requestID uint32, containerIDs []ids.ID)

func (*Sender) SendAcceptedFrontier added in v1.5.3

func (s *Sender) SendAcceptedFrontier(nodeID ids.ShortID, requestID uint32, containerIDs []ids.ID)

func (*Sender) SendAppGossip added in v1.5.3

func (s *Sender) SendAppGossip(appResponseBytes []byte) error

SendAppGossip sends an application-level gossip message to peers.

func (*Sender) SendAppGossipSpecific added in v1.6.2

func (s *Sender) SendAppGossipSpecific(nodeIDs ids.ShortSet, appResponseBytes []byte) error

SendAppGossip sends an application-level gossip message to specified peers.

func (*Sender) SendAppRequest added in v1.5.3

func (s *Sender) SendAppRequest(nodeIDs ids.ShortSet, requestID uint32, appRequestBytes []byte) error

SendAppRequest sends an application-level request to the given nodes. The meaning of this request, and how it should be handled, is defined by the VM.

func (*Sender) SendAppResponse added in v1.5.3

func (s *Sender) SendAppResponse(nodeID ids.ShortID, requestID uint32, appResponseBytes []byte) error

SendAppResponse sends a response to an application-level request from the given node

func (*Sender) SendChits added in v1.5.3

func (s *Sender) SendChits(nodeID ids.ShortID, requestID uint32, votes []ids.ID)

SendChits sends chits

func (*Sender) SendGet added in v1.5.3

func (s *Sender) SendGet(nodeID ids.ShortID, requestID uint32, containerID ids.ID)

SendGet sends a Get message to the consensus engine running on the specified chain to the specified node. The Get message signifies that this consensus engine would like the recipient to send this consensus engine the specified container.

func (*Sender) SendGetAccepted added in v1.5.3

func (s *Sender) SendGetAccepted(nodeIDs ids.ShortSet, requestID uint32, containerIDs []ids.ID)

func (*Sender) SendGetAcceptedFrontier added in v1.5.3

func (s *Sender) SendGetAcceptedFrontier(nodeIDs ids.ShortSet, requestID uint32)

func (*Sender) SendGetAncestors added in v1.5.3

func (s *Sender) SendGetAncestors(nodeID ids.ShortID, requestID uint32, containerID ids.ID)

func (*Sender) SendGossip added in v1.5.3

func (s *Sender) SendGossip(containerID ids.ID, container []byte)

SendGossip gossips the provided container

func (*Sender) SendMultiPut added in v1.5.3

func (s *Sender) SendMultiPut(nodeID ids.ShortID, requestID uint32, containers [][]byte)

SendMultiPut sends a MultiPut message to the consensus engine running on the specified chain on the specified node. The MultiPut message gives the recipient the contents of several containers.

func (*Sender) SendPullQuery added in v1.5.3

func (s *Sender) SendPullQuery(nodeIDs ids.ShortSet, requestID uint32, containerID ids.ID)

SendPullQuery sends a PullQuery message to the consensus engines running on the specified chains on the specified nodes. The PullQuery message signifies that this consensus engine would like each node to send their preferred frontier.

func (*Sender) SendPushQuery added in v1.5.3

func (s *Sender) SendPushQuery(nodeIDs ids.ShortSet, requestID uint32, containerID ids.ID, container []byte)

SendPushQuery sends a PushQuery message to the consensus engines running on the specified chains on the specified nodes. The PushQuery message signifies that this consensus engine would like each node to send their preferred frontier given the existence of the specified container.

func (*Sender) SendPut added in v1.5.3

func (s *Sender) SendPut(nodeID ids.ShortID, requestID uint32, containerID ids.ID, container []byte)

SendPut sends a Put message to the consensus engine running on the specified chain on the specified node. The Put message signifies that this consensus engine is giving to the recipient the contents of the specified container.

Jump to

Keyboard shortcuts

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