tmlibp2p

package
v0.0.0-...-434d902 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: Apache-2.0 Imports: 18 Imported by: 2

Documentation

Overview

Package tmlibp2p contains implementations of the tmp2p interfaces using github.com/libp2p/go-libp2p.

Note that this package will likely be moved to its own module in a separate git repository, in the future.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

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

Connection is a connection to a libp2p network, including appropriate pubsub subscriptions.

func NewConnection

func NewConnection(ctx context.Context, log *slog.Logger, h *Host, codec tmcodec.MarshalCodec) (*Connection, error)

NewConnection returns a new Connection based on a host that has already joined a network.

func (*Connection) Codec

func (c *Connection) Codec() tmcodec.MarshalCodec

Codec returns c's codec. This is primarily useful for testing.

func (*Connection) ConsensusBroadcaster

func (c *Connection) ConsensusBroadcaster() tmp2p.ConsensusBroadcaster

ConsensusBroadcaster returns c, which already satisfies the ConsensusBroadcaster interface.

func (*Connection) Disconnect

func (c *Connection) Disconnect()

func (*Connection) Disconnected

func (c *Connection) Disconnected() <-chan struct{}

Disconnected returns a channel that is closed once c.Disconnect() has been called and has returned.

func (*Connection) Host

func (c *Connection) Host() *Host

Host returns c's underlying Host. This is useful for some bookkeeping in [tmlibp2ptest.Network].

func (*Connection) OutgoingPrecommitProofs

func (c *Connection) OutgoingPrecommitProofs() chan<- tmconsensus.PrecommitSparseProof

OutgoingPrecommitProofs returns a channel where precommits may be sent, after which they will be broadcast to the p2p network.

func (*Connection) OutgoingPrevoteProofs

func (c *Connection) OutgoingPrevoteProofs() chan<- tmconsensus.PrevoteSparseProof

OutgoingPrevoteProofs returns a channel where prevote proofs may be sent, after which they will be broadcast to the p2p network.

func (*Connection) OutgoingProposedHeaders

func (c *Connection) OutgoingProposedHeaders() chan<- tmconsensus.ProposedHeader

OutgoingProposedHeaders returns a channel where proposed headers may be sent, after which they will be broadcast to the p2p network.

func (*Connection) SetConsensusHandler

func (c *Connection) SetConsensusHandler(ctx context.Context, h tmconsensus.ConsensusHandler)

SetConsensusHandler sets the consensus handler for this Connection. h may be nil to ignore consensus messages.

type Host

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

Host is a libp2p host and a pubsub connection.

func NewHost

func NewHost(ctx context.Context, opts HostOptions) (*Host, error)

func (*Host) Close

func (h *Host) Close() error

Close closes the underlying libp2p host and returns its error.

func (*Host) Libp2pHost

func (h *Host) Libp2pHost() p2phost.Host

Libp2pHost returns the underlying libp2p host value.

func (*Host) PubSub

func (h *Host) PubSub() *pubsub.PubSub

PubSub returns the underlying libp2p pubsub value.

type HostOptions

type HostOptions struct {
	// Options are passed when creating a new libp2p host
	// (which is lower level than the Host type in this tmlibp2p package).
	Options []libp2p.Option

	// Currently PubSubOptions are always applied to NewGossipSub.
	PubSubOptions []pubsub.Option
}

HostOptions holds libp2p configuration for the host and pubsub value.

Directories

Path Synopsis
Package tmlibp2ptest provides the Network type that is useful for tests that need to instantiate a Gordian peer-to-peer network backed by tmlibp2p.
Package tmlibp2ptest provides the Network type that is useful for tests that need to instantiate a Gordian peer-to-peer network backed by tmlibp2p.

Jump to

Keyboard shortcuts

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