network

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: GPL-3.0 Imports: 7 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",
	2: "GetLatestChangeRound",
}
View Source
var Sync_value = map[string]int32{
	"GetHighestType":       0,
	"GetInstanceRange":     1,
	"GetLatestChangeRound": 2,
}

Functions

This section is empty.

Types

type Broadcaster added in v0.1.5

type Broadcaster interface {
	// Broadcast propagates a signed message to all peers
	Broadcast(topicName []byte, msg *proto.SignedMessage) error
	// BroadcastSignature broadcasts the given signature for the given lambda
	BroadcastSignature(topicName []byte, msg *proto.SignedMessage) error
	// BroadcastDecided broadcasts a decided instance with collected signatures
	BroadcastDecided(topicName []byte, msg *proto.SignedMessage) error
	// BroadcastMainTopic broadcasts the given msg on main channel
	BroadcastMainTopic(msg *proto.SignedMessage) error
	// MaxBatch returns the maximum batch size for network responses
	MaxBatch() uint64
}

Broadcaster is the interface for broadcasting messages in the network

type Message

type Message struct {
	SignedMessage *proto.SignedMessage
	SyncMessage   *SyncMessage
	Stream        SyncStream
	Type          NetworkMsg
}

Message is a container for network messages.

type Network

type Network interface {
	Reader
	Broadcaster
	Syncer
}

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 Reader added in v0.1.5

type Reader interface {
	// ReceivedMsgChan is a channel that forwards new propagated messages to a subscriber
	ReceivedMsgChan() (<-chan *proto.SignedMessage, func())
	// ReceivedSignatureChan returns the channel with signatures
	ReceivedSignatureChan() (<-chan *proto.SignedMessage, func())
	// ReceivedDecidedChan returns the channel for decided messages
	ReceivedDecidedChan() (<-chan *proto.SignedMessage, func())
	// ReceivedSyncMsgChan returns the channel for sync messages
	ReceivedSyncMsgChan() (<-chan *SyncChanObj, func())
	// SubscribeToValidatorNetwork subscribes and listens to validator's network
	SubscribeToValidatorNetwork(validatorPk *bls.PublicKey) error
	// AllPeers returns all connected peers for a validator PK
	AllPeers(validatorPk []byte) ([]string, error)
	// SubscribeToMainTopic subscribes to main topic
	SubscribeToMainTopic() error
	// MaxBatch returns the maximum batch size for network responses
	MaxBatch() uint64
}

Reader is the interface for reading messages from the network

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
	// GetCurrentInstance is a request from peers to return their current running instance details
	Sync_GetLatestChangeRound Sync = 2
)

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"`
	Lambda               []byte                  `protobuf:"bytes,4,opt,name=Lambda,proto3" json:"Lambda,omitempty"`
	Type                 Sync                    `protobuf:"varint,5,opt,name=Type,proto3,enum=network.Sync" json:"Type,omitempty"`
	Error                string                  `protobuf:"bytes,6,opt,name=error,proto3" json:"error,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
	XXX_unrecognized     []byte                  `json:"-"`
	XXX_sizecache        int32                   `json:"-"`
}

func (*SyncMessage) Descriptor

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

func (*SyncMessage) GetError added in v0.0.13

func (m *SyncMessage) GetError() string

func (*SyncMessage) GetFromPeerID

func (m *SyncMessage) GetFromPeerID() string

func (*SyncMessage) GetLambda added in v0.0.4

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

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) 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.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

	// ReadWithTimeout will read bytes from stream and return the result, will return error if timeout or error.
	// does not close stream when returns
	ReadWithTimeout(timeout time.Duration) ([]byte, error)

	// WriteWithTimeout will write bytes to stream, will return error if timeout or error.
	// does not close stream when returns
	WriteWithTimeout(data []byte, timeout time.Duration) error
}

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

type Syncer added in v0.1.5

type Syncer interface {
	// GetHighestDecidedInstance sends a highest decided request to peers and returns answers.
	// If peer list is nil, broadcasts to all.
	GetHighestDecidedInstance(peerStr string, msg *SyncMessage) (*SyncMessage, error)
	// GetDecidedByRange returns a list of decided signed messages up to 25 in a batch.
	GetDecidedByRange(peerStr string, msg *SyncMessage) (*SyncMessage, error)
	// GetLastChangeRoundMsg returns the latest change round msg for a running instance, could return nil
	GetLastChangeRoundMsg(peerStr string, msg *SyncMessage) (*SyncMessage, error)
	// RespondToHighestDecidedInstance responds to a GetHighestDecidedInstance
	RespondToHighestDecidedInstance(stream SyncStream, msg *SyncMessage) error
	// RespondToGetDecidedByRange responds to a GetDecidedByRange
	RespondToGetDecidedByRange(stream SyncStream, msg *SyncMessage) error
	// RespondToLastChangeRoundMsg responds to a GetLastChangeRoundMsg
	RespondToLastChangeRoundMsg(stream SyncStream, msg *SyncMessage) error
}

Syncer represents the needed functionality for performing sync

Directories

Path Synopsis
v0

Jump to

Keyboard shortcuts

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