network

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2021 License: GPL-3.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NetworkMsg_name = map[int32]string{
	0: "IBFTType",
	1: "DecidedType",
	2: "SignatureType",
	3: "SyncType",
}
View Source
var NetworkMsg_value = map[string]int32{
	"IBFTType":      0,
	"DecidedType":   1,
	"SignatureType": 2,
	"SyncType":      3,
}
View Source
var Sync_name = map[int32]string{
	0: "GetHighestType",
	1: "GetInstanceRange",
}
View Source
var Sync_value = map[string]int32{
	"GetHighestType":   0,
	"GetInstanceRange": 1,
}

Functions

This section is empty.

Types

type Message

type Message struct {
	Lambda               []byte                `protobuf:"bytes,1,opt,name=Lambda,proto3" json:"Lambda,omitempty"`
	SignedMessage        *proto1.SignedMessage `protobuf:"bytes,2,opt,name=SignedMessage,proto3" json:"SignedMessage,omitempty"`
	SyncMessage          *SyncMessage          `protobuf:"bytes,3,opt,name=SyncMessage,proto3" json:"SyncMessage,omitempty"`
	Type                 NetworkMsg            `protobuf:"varint,4,opt,name=Type,proto3,enum=network.NetworkMsg" json:"Type,omitempty"`
	XXX_NoUnkeyedLiteral struct{}              `json:"-"`
	XXX_unrecognized     []byte                `json:"-"`
	XXX_sizecache        int32                 `json:"-"`
}

Message is a wrapper struct for all network message types

func (*Message) Descriptor

func (*Message) Descriptor() ([]byte, []int)

func (*Message) GetLambda

func (m *Message) GetLambda() []byte

func (*Message) GetSignedMessage

func (m *Message) GetSignedMessage() *proto1.SignedMessage

func (*Message) GetSyncMessage

func (m *Message) GetSyncMessage() *SyncMessage

func (*Message) GetType

func (m *Message) GetType() NetworkMsg

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) Reset

func (m *Message) Reset()

func (*Message) String

func (m *Message) String() string

func (*Message) XXX_DiscardUnknown

func (m *Message) XXX_DiscardUnknown()

func (*Message) XXX_Marshal

func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Message) XXX_Merge

func (m *Message) XXX_Merge(src proto.Message)

func (*Message) XXX_Size

func (m *Message) XXX_Size() int

func (*Message) XXX_Unmarshal

func (m *Message) XXX_Unmarshal(b []byte) error

type Network

type Network interface {
	// Broadcast propagates a signed message to all peers
	Broadcast(msg *proto.SignedMessage) error

	// ReceivedMsgChan is a channel that forwards new propagated messages to a subscriber
	ReceivedMsgChan() <-chan *proto.SignedMessage

	// BroadcastSignature broadcasts the given signature for the given lambda
	BroadcastSignature(msg *proto.SignedMessage) error

	// ReceivedSignatureChan returns the channel with signatures
	ReceivedSignatureChan() <-chan *proto.SignedMessage

	// BroadcastDecided broadcasts a decided instance with collected signatures
	BroadcastDecided(msg *proto.SignedMessage) error

	// ReceivedDecidedChan returns the channel for decided messages
	ReceivedDecidedChan() <-chan *proto.SignedMessage

	// GetHighestDecidedInstance sends a highest decided request to peers and returns answers.
	// If peer list is nil, broadcasts to all.
	GetHighestDecidedInstance(peerID string, msg *SyncMessage) (*SyncMessage, error)

	// RespondToHighestDecidedInstance responds to a GetHighestDecidedInstance
	RespondToHighestDecidedInstance(stream SyncStream, msg *SyncMessage) error

	// GetDecidedByRange returns a list of decided signed messages up to 25 in a batch.
	GetDecidedByRange(peerID string, msg *SyncMessage) (*SyncMessage, error)

	// RespondToGetDecidedByRange responds to a GetDecidedByRange
	RespondToGetDecidedByRange(stream SyncStream, msg *SyncMessage) error

	// ReceivedSyncMsgChan returns the channel for sync messages
	ReceivedSyncMsgChan() <-chan *SyncChanObj

	// SubscribeToValidatorNetwork subscribing and listen to validator network
	SubscribeToValidatorNetwork(validatorPk *bls.PublicKey) error

	// IsSubscribeToValidatorNetwork checks if there is a subscription to the validator topic
	IsSubscribeToValidatorNetwork(validatorPk *bls.PublicKey) bool

	// AllPeers returns all connected peers for a validator PK
	AllPeers(validatorPk []byte) ([]string, error)
}

Network represents the behavior of the network

type NetworkMsg

type NetworkMsg int32
const (
	// IBFTType are all iBFT related messages
	NetworkMsg_IBFTType NetworkMsg = 0
	// DecidedType is an iBFT specific message for broadcasting post consensus decided message with signatures
	NetworkMsg_DecidedType NetworkMsg = 1
	// SignatureType is an SSV node specific message for broadcasting post consensus signatures on eth2 duties
	NetworkMsg_SignatureType NetworkMsg = 2
	// SyncType is an SSV iBFT specific message that a node uses to sync up with other nodes
	NetworkMsg_SyncType NetworkMsg = 3
)

func (NetworkMsg) EnumDescriptor

func (NetworkMsg) EnumDescriptor() ([]byte, []int)

func (NetworkMsg) String

func (x NetworkMsg) String() string

type Sync

type Sync int32
const (
	// GetHighestType is a request from peers to return the highest decided/ prepared instance they know of
	Sync_GetHighestType Sync = 0
	// GetInstanceRange is a request from peers to return instances and their decided/ prepared justifications
	Sync_GetInstanceRange Sync = 1
)

func (Sync) EnumDescriptor

func (Sync) EnumDescriptor() ([]byte, []int)

func (Sync) String

func (x Sync) String() string

type SyncChanObj

type SyncChanObj struct {
	Msg    *SyncMessage
	Stream SyncStream
}

SyncChanObj is a wrapper object for streaming of sync messages

type SyncMessage

type SyncMessage struct {
	SignedMessages       []*proto1.SignedMessage `protobuf:"bytes,1,rep,name=SignedMessages,proto3" json:"SignedMessages,omitempty"`
	FromPeerID           string                  `protobuf:"bytes,2,opt,name=FromPeerID,proto3" json:"FromPeerID,omitempty"`
	Params               []uint64                `protobuf:"varint,3,rep,packed,name=params,proto3" json:"params,omitempty"`
	ValidatorPk          []byte                  `protobuf:"bytes,4,opt,name=validator_pk,json=validatorPk,proto3" json:"validator_pk,omitempty"`
	Type                 Sync                    `protobuf:"varint,5,opt,name=Type,proto3,enum=network.Sync" json:"Type,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
	XXX_unrecognized     []byte                  `json:"-"`
	XXX_sizecache        int32                   `json:"-"`
}

func (*SyncMessage) Descriptor

func (*SyncMessage) Descriptor() ([]byte, []int)

func (*SyncMessage) GetFromPeerID

func (m *SyncMessage) GetFromPeerID() string

func (*SyncMessage) GetParams

func (m *SyncMessage) GetParams() []uint64

func (*SyncMessage) GetSignedMessages

func (m *SyncMessage) GetSignedMessages() []*proto1.SignedMessage

func (*SyncMessage) GetType

func (m *SyncMessage) GetType() Sync

func (*SyncMessage) GetValidatorPk

func (m *SyncMessage) GetValidatorPk() []byte

func (*SyncMessage) ProtoMessage

func (*SyncMessage) ProtoMessage()

func (*SyncMessage) Reset

func (m *SyncMessage) Reset()

func (*SyncMessage) String

func (m *SyncMessage) String() string

func (*SyncMessage) XXX_DiscardUnknown

func (m *SyncMessage) XXX_DiscardUnknown()

func (*SyncMessage) XXX_Marshal

func (m *SyncMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SyncMessage) XXX_Merge

func (m *SyncMessage) XXX_Merge(src proto.Message)

func (*SyncMessage) XXX_Size

func (m *SyncMessage) XXX_Size() int

func (*SyncMessage) XXX_Unmarshal

func (m *SyncMessage) XXX_Unmarshal(b []byte) error

type SyncStream

type SyncStream interface {
	io.Reader
	io.Writer
	io.Closer

	// CloseWrite closes the stream for writing but leaves it open for
	// reading.
	//
	// CloseWrite does not free the stream, users must still call Close or
	// Reset.
	CloseWrite() error

	// RemotePeer returns a string identifier of the remote peer connected to this stream
	RemotePeer() string
}

SyncStream is a interface for all stream related functions for the sync process.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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