p2p

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// BlockTopicName is the block topic string
	BlockTopicName string = "koinos.blocks"

	// TransactionTopicName is the transaction topic string
	TransactionTopicName string = "koinos.transactions"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionManager

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

ConnectionManager attempts to reconnect to peers using the network.Notifiee interface.

func NewConnectionManager

func NewConnectionManager(
	host host.Host,
	localRPC rpc.LocalRPC,
	peerOpts *options.PeerConnectionOptions,
	libProvider LastIrreversibleBlockProvider,
	initialPeers []string,
	peerErrorChan chan<- PeerError,
	gossipVoteChan chan<- GossipVote,
	signalPeerDisconnectChan chan<- peer.ID) *ConnectionManager

NewConnectionManager creates a new PeerReconnectManager object

func (*ConnectionManager) ClosedStream

func (c *ConnectionManager) ClosedStream(n network.Network, s network.Stream)

ClosedStream is part of the libp2p network.Notifiee interface

func (*ConnectionManager) Connected

func (c *ConnectionManager) Connected(net network.Network, conn network.Conn)

Connected is part of the libp2p network.Notifiee interface

func (*ConnectionManager) Disconnected

func (c *ConnectionManager) Disconnected(net network.Network, conn network.Conn)

Disconnected is part of the libp2p network.Notifiee interface

func (*ConnectionManager) Listen

Listen is part of the libp2p network.Notifiee interface

func (*ConnectionManager) ListenClose

func (c *ConnectionManager) ListenClose(n network.Network, _ multiaddr.Multiaddr)

ListenClose is part of the libp2p network.Notifiee interface

func (*ConnectionManager) OpenedStream

func (c *ConnectionManager) OpenedStream(n network.Network, s network.Stream)

OpenedStream is part of the libp2p network.Notifiee interface

func (*ConnectionManager) Start

func (c *ConnectionManager) Start(ctx context.Context)

Start the connection manager

type GossipEnableHandler

type GossipEnableHandler interface {
	EnableGossip(context.Context, bool)
}

GossipEnableHandler is an interface for handling enable/disable gossip requests

type GossipManager

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

GossipManager manages gossip on a given topic

func NewGossipManager

func NewGossipManager(ps *pubsub.PubSub, errChan chan<- PeerError, topicName string) *GossipManager

NewGossipManager creates and returns a new instance of gossipManager

func (*GossipManager) PublishMessage

func (gm *GossipManager) PublishMessage(ctx context.Context, bytes []byte) bool

PublishMessage publishes the given object to this manager's topic

func (*GossipManager) RegisterValidator

func (gm *GossipManager) RegisterValidator(val interface{})

RegisterValidator registers the validate function to be used for messages

func (*GossipManager) Start

func (gm *GossipManager) Start(ctx context.Context, ch chan<- []byte) error

Start starts gossiping on this topic

func (*GossipManager) Stop

func (gm *GossipManager) Stop()

Stop stops all gossiping on this topic

type GossipToggle

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

GossipToggle tracks peer gossip votes and toggles gossip accordingly

func NewGossipToggle

func NewGossipToggle(gossipEnabler GossipEnableHandler, voteChan <-chan GossipVote, peerDisconnectedChan <-chan peer.ID, opts options.GossipToggleOptions) *GossipToggle

NewGossipToggle creates a GossipToggle

func (*GossipToggle) Start

func (g *GossipToggle) Start(ctx context.Context)

Start begins gossip vote processing

type GossipVote

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

GossipVote is a vote from a peer to enable gossip or not

type KoinosGossip

type KoinosGossip struct {
	Block         *GossipManager
	Transaction   *GossipManager
	PubSub        *pubsub.PubSub
	PeerErrorChan chan<- PeerError
	// contains filtered or unexported fields
}

KoinosGossip handles gossip of blocks and transactions

func NewKoinosGossip

func NewKoinosGossip(
	ctx context.Context,
	rpc rpc.LocalRPC,
	ps *pubsub.PubSub,
	peerErrorChan chan<- PeerError,
	id peer.ID,
	libProvider LastIrreversibleBlockProvider) *KoinosGossip

NewKoinosGossip constructs a new koinosGossip instance

func (*KoinosGossip) EnableGossip

func (kg *KoinosGossip) EnableGossip(ctx context.Context, enable bool)

EnableGossip satisfies GossipEnableHandler interface

func (*KoinosGossip) StartGossip

func (kg *KoinosGossip) StartGossip(ctx context.Context)

StartGossip enables gossip of blocks and transactions

func (*KoinosGossip) StopGossip

func (kg *KoinosGossip) StopGossip()

StopGossip stops gossiping on both block and transaction topics

type LastIrreversibleBlockProvider

type LastIrreversibleBlockProvider interface {
	GetLastIrreversibleBlock() koinos.BlockTopology
}

LastIrreversibleBlockProvider is an interface for providing the last irreversible block to PeerConnection

type PeerConnection

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

PeerConnection handles the sync portion of a connection to a peer

func NewPeerConnection

func NewPeerConnection(id peer.ID, libProvider LastIrreversibleBlockProvider, localRPC rpc.LocalRPC, peerRPC rpc.RemoteRPC, peerErrorChan chan<- PeerError, gossipVoteChan chan<- GossipVote, opts *options.PeerConnectionOptions) *PeerConnection

NewPeerConnection creates a PeerConnection

func (*PeerConnection) Start

func (p *PeerConnection) Start(ctx context.Context)

Start syncing to the peer

type PeerError

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

PeerError represents an error originating from a peer

type PeerErrorHandler

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

PeerErrorHandler handles PeerErrors and tracks errors over time to determine if a peer should be disconnected from

func NewPeerErrorHandler

func NewPeerErrorHandler(disconnectPeerChan chan<- peer.ID, peerErrorChan <-chan PeerError, opts options.PeerErrorHandlerOptions) *PeerErrorHandler

NewPeerErrorHandler creates a new PeerErrorHandler

func (*PeerErrorHandler) CanConnect

func (p *PeerErrorHandler) CanConnect(ctx context.Context, id peer.ID) bool

CanConnect to peer if the peer's error score is below the error score threshold

func (*PeerErrorHandler) InterceptAccept

func (p *PeerErrorHandler) InterceptAccept(network.ConnMultiaddrs) bool

InterceptAccept implements the libp2p ConnectionGater interface

func (*PeerErrorHandler) InterceptAddrDial

func (p *PeerErrorHandler) InterceptAddrDial(peer.ID, multiaddr.Multiaddr) bool

InterceptAddrDial implements the libp2p ConnectionGater interface

func (*PeerErrorHandler) InterceptPeerDial

func (p *PeerErrorHandler) InterceptPeerDial(pid peer.ID) bool

InterceptPeerDial implements the libp2p ConnectionGater interface

func (*PeerErrorHandler) InterceptSecured

func (p *PeerErrorHandler) InterceptSecured(_ network.Direction, pid peer.ID, _ network.ConnMultiaddrs) bool

InterceptSecured implements the libp2p ConnectionGater interface

func (*PeerErrorHandler) InterceptUpgraded

func (p *PeerErrorHandler) InterceptUpgraded(network.Conn) (bool, control.DisconnectReason)

InterceptUpgraded implements the libp2p ConnectionGater interface

func (*PeerErrorHandler) Start

func (p *PeerErrorHandler) Start(ctx context.Context)

Start processing peer errors

Jump to

Keyboard shortcuts

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