network

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: Apache-2.0, BSD-2-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewEvents = event.CreateGroupConstructor(func() (newEvents *Events) {
	return &Events{
		BlockReceived:                 event.New1[*BlockReceivedEvent](),
		BlockRequestReceived:          event.New1[*BlockRequestReceivedEvent](),
		SlotCommitmentReceived:        event.New1[*SlotCommitmentReceivedEvent](),
		SlotCommitmentRequestReceived: event.New1[*SlotCommitmentRequestReceivedEvent](),
		AttestationsReceived:          event.New1[*AttestationsReceivedEvent](),
		AttestationsRequestReceived:   event.New1[*AttestationsRequestReceivedEvent](),
		Error:                         event.New1[*ErrorEvent](),
	}
})

NewEvents contains the constructor of the Events object (it is generated by a generic factory).

Functions

This section is empty.

Types

type AttestationsReceivedEvent

type AttestationsReceivedEvent struct {
	Commitment   *commitment.Commitment
	BlockIDs     models.BlockIDs
	Attestations *orderedmap.OrderedMap[slot.Index, *advancedset.AdvancedSet[*notarization.Attestation]]
	Source       identity.ID
}

type AttestationsRequestReceivedEvent

type AttestationsRequestReceivedEvent struct {
	Commitment *commitment.Commitment
	EndIndex   slot.Index
	Source     identity.ID
}

type BlockReceivedEvent

type BlockReceivedEvent struct {
	Block  *models.Block
	Source identity.ID
}

type BlockRequestReceivedEvent

type BlockRequestReceivedEvent struct {
	BlockID models.BlockID
	Source  identity.ID
}

type Endpoint

type Endpoint interface {
	RegisterProtocol(protocolID string, newMessage func() proto.Message, handler func(identity.ID, proto.Message) error)

	UnregisterProtocol(protocolID string)

	Send(packet proto.Message, protocolID string, to ...identity.ID)
}

type ErrorEvent

type ErrorEvent struct {
	Error  error
	Source identity.ID
}

type Events

type Events struct {
	BlockReceived                 *event.Event1[*BlockReceivedEvent]
	BlockRequestReceived          *event.Event1[*BlockRequestReceivedEvent]
	SlotCommitmentReceived        *event.Event1[*SlotCommitmentReceivedEvent]
	SlotCommitmentRequestReceived *event.Event1[*SlotCommitmentRequestReceivedEvent]
	AttestationsReceived          *event.Event1[*AttestationsReceivedEvent]
	AttestationsRequestReceived   *event.Event1[*AttestationsRequestReceivedEvent]
	Error                         *event.Event1[*ErrorEvent]

	event.Group[Events, *Events]
}

type MockedEndpoint

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

func NewMockedEndpoint

func NewMockedEndpoint(id identity.ID, network *MockedNetwork, partition string) (newMockedNetwork *MockedEndpoint)

func (*MockedEndpoint) RegisterProtocol

func (m *MockedEndpoint) RegisterProtocol(protocolID string, newMessage func() proto.Message, handler func(identity.ID, proto.Message) error)

func (*MockedEndpoint) Send

func (m *MockedEndpoint) Send(packet proto.Message, protocolID string, to ...identity.ID)

func (*MockedEndpoint) UnregisterProtocol

func (m *MockedEndpoint) UnregisterProtocol(protocolID string)

type MockedNetwork

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

func NewMockedNetwork

func NewMockedNetwork() (mockedNetwork *MockedNetwork)

func (*MockedNetwork) Join

func (m *MockedNetwork) Join(endpointID identity.ID, partition ...string) (endpoint *MockedEndpoint)

func (*MockedNetwork) MergePartitionsToMain

func (m *MockedNetwork) MergePartitionsToMain(partitions ...string)

type Protocol

type Protocol struct {
	Events *Events
	// contains filtered or unexported fields
}

func NewProtocol

func NewProtocol(network Endpoint, workerPool *workerpool.WorkerPool, slotTimeProvider *slot.TimeProvider, opts ...options.Option[Protocol]) (protocol *Protocol)

func (*Protocol) RequestAttestations

func (p *Protocol) RequestAttestations(cm *commitment.Commitment, endIndex slot.Index, to ...identity.ID)

func (*Protocol) RequestBlock

func (p *Protocol) RequestBlock(id models.BlockID, to ...identity.ID)

func (*Protocol) RequestCommitment

func (p *Protocol) RequestCommitment(id commitment.ID, to ...identity.ID)

func (*Protocol) SendAttestations

func (p *Protocol) SendAttestations(cm *commitment.Commitment, blockIDs models.BlockIDs, attestations *orderedmap.OrderedMap[slot.Index, *advancedset.AdvancedSet[*notarization.Attestation]], to ...identity.ID)

func (*Protocol) SendBlock

func (p *Protocol) SendBlock(block *models.Block, to ...identity.ID)

func (*Protocol) SendSlotCommitment

func (p *Protocol) SendSlotCommitment(cm *commitment.Commitment, to ...identity.ID)

func (*Protocol) Unregister

func (p *Protocol) Unregister()

type SlotCommitmentReceivedEvent

type SlotCommitmentReceivedEvent struct {
	Commitment *commitment.Commitment
	Source     identity.ID
}

type SlotCommitmentRequestReceivedEvent

type SlotCommitmentRequestReceivedEvent struct {
	CommitmentID commitment.ID
	Source       identity.ID
}

Directories

Path Synopsis
p2p

Jump to

Keyboard shortcuts

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