local

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLocalStream

func NewLocalStream(From string, To string) network.SyncStream

NewLocalStream returs a stream instance

Types

type Local

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

Local implements network.Local interface

func NewLocalNetwork

func NewLocalNetwork() *Local

NewLocalNetwork creates a new instance of a local network

func (*Local) AllPeers

func (n *Local) AllPeers(validatorPk []byte) ([]string, error)

AllPeers returns all connected peers for a validator PK

func (*Local) Broadcast

func (n *Local) Broadcast(topicName []byte, signed *proto.SignedMessage) error

Broadcast implements network.Local interface

func (*Local) BroadcastDecided

func (n *Local) BroadcastDecided(topicName []byte, msg *proto.SignedMessage) error

BroadcastDecided broadcasts a decided instance with collected signatures

func (*Local) BroadcastSignature

func (n *Local) BroadcastSignature(topicName []byte, msg *proto.SignedMessage) error

BroadcastSignature broadcasts the given signature for the given lambda

func (*Local) CopyWithLocalNodeID

func (n *Local) CopyWithLocalNodeID(id peer.ID) *Local

CopyWithLocalNodeID copies the local network instance and adds a unique node id to it this is used for peer specific messages like sync messages to identify each node

func (*Local) GetDecidedByRange

func (n *Local) GetDecidedByRange(peerStr string, msg *network.SyncMessage) (*network.SyncMessage, error)

GetDecidedByRange returns a list of decided signed messages up to 25 in a batch.

func (*Local) GetHighestDecidedInstance

func (n *Local) GetHighestDecidedInstance(peerStr string, msg *network.SyncMessage) (*network.SyncMessage, error)

GetHighestDecidedInstance sends a highest decided request to peers and returns answers. If peer list is nil, broadcasts to all.

func (*Local) GetLastChangeRoundMsg added in v0.0.14

func (n *Local) GetLastChangeRoundMsg(peerStr string, msg *network.SyncMessage) (*network.SyncMessage, error)

GetLastChangeRoundMsg returns the latest change round msg for a running instance, could return nil

func (*Local) MaxBatch added in v0.0.14

func (n *Local) MaxBatch() uint64

MaxBatch implementation

func (*Local) NotifyOperatorID added in v0.1.9

func (n *Local) NotifyOperatorID(oid string)

NotifyOperatorID implementation

func (*Local) ReceivedDecidedChan

func (n *Local) ReceivedDecidedChan() (<-chan *proto.SignedMessage, func())

ReceivedDecidedChan returns the channel for decided messages

func (*Local) ReceivedMsgChan

func (n *Local) ReceivedMsgChan() (<-chan *proto.SignedMessage, func())

ReceivedMsgChan implements network.Local interface

func (*Local) ReceivedSignatureChan

func (n *Local) ReceivedSignatureChan() (<-chan *proto.SignedMessage, func())

ReceivedSignatureChan returns the channel with signatures

func (*Local) ReceivedSyncMsgChan

func (n *Local) ReceivedSyncMsgChan() (<-chan *network.SyncChanObj, func())

ReceivedSyncMsgChan returns the channel for sync messages

func (*Local) RespondSyncMsg added in v0.1.9

func (n *Local) RespondSyncMsg(streamID string, msg *network.SyncMessage) error

RespondSyncMsg responds to sync messages

func (*Local) SubscribeToMainTopic added in v0.1.1

func (n *Local) SubscribeToMainTopic() error

SubscribeToMainTopic implementation

func (*Local) SubscribeToValidatorNetwork

func (n *Local) SubscribeToValidatorNetwork(validatorPk *bls.PublicKey) error

SubscribeToValidatorNetwork for new validator create new topic, subscribe and start listen

type Stream

type Stream struct {
	From        string
	To          string
	ReceiveChan chan *network.SyncMessage
	// contains filtered or unexported fields
}

Stream is used by local network

func (*Stream) Close

func (s *Stream) Close() error

Close implementation

func (*Stream) CloseWrite

func (s *Stream) CloseWrite() error

CloseWrite implementation

func (*Stream) ID added in v0.1.9

func (s *Stream) ID() string

ID implementation

func (*Stream) ReadWithTimeout added in v0.1.5

func (s *Stream) ReadWithTimeout(timeout time.Duration) ([]byte, error)

ReadWithTimeout implementation

func (*Stream) RemotePeer

func (s *Stream) RemotePeer() string

RemotePeer implementation

func (*Stream) WriteSynMsg

func (s *Stream) WriteSynMsg(msg *network.SyncMessage) (n int, err error)

WriteSynMsg implementation

func (*Stream) WriteWithTimeout added in v0.1.5

func (s *Stream) WriteWithTimeout(data []byte, timeout time.Duration) error

WriteWithTimeout implementation

Jump to

Keyboard shortcuts

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