local

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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) IsSubscribeToValidatorNetwork added in v0.0.3

func (n *Local) IsSubscribeToValidatorNetwork(validatorPk *bls.PublicKey) bool

IsSubscribeToValidatorNetwork checks if there is a subscription to the validator topic

func (*Local) ReceivedDecidedChan

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

ReceivedDecidedChan returns the channel for decided messages

func (*Local) ReceivedMsgChan

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

ReceivedMsgChan implements network.Local interface

func (*Local) ReceivedSignatureChan

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

ReceivedSignatureChan returns the channel with signatures

func (*Local) ReceivedSyncMsgChan

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

ReceivedSyncMsgChan returns the channel for sync messages

func (*Local) RespondToGetDecidedByRange

func (n *Local) RespondToGetDecidedByRange(stream network.SyncStream, msg *network.SyncMessage) error

RespondToGetDecidedByRange responds to a GetDecidedByRange

func (*Local) RespondToHighestDecidedInstance

func (n *Local) RespondToHighestDecidedInstance(stream network.SyncStream, msg *network.SyncMessage) error

RespondToHighestDecidedInstance responds to a GetHighestDecidedInstance

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
}

Stream is used by local network

func NewLocalStream

func NewLocalStream(From string, To string) *Stream

NewLocalStream returs a stream instance

func (*Stream) Close

func (s *Stream) Close() error

Close implementation

func (*Stream) CloseWrite

func (s *Stream) CloseWrite() error

CloseWrite implementation

func (*Stream) Read

func (s *Stream) Read(p []byte) (n int, err error)

Read implementation

func (*Stream) RemotePeer

func (s *Stream) RemotePeer() string

RemotePeer implementation

func (*Stream) Write

func (s *Stream) Write(p []byte) (n int, err error)

Write implementation

func (*Stream) WriteSynMsg

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

WriteSynMsg implementation

Jump to

Keyboard shortcuts

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