p2p

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: GPL-3.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusProtocolID   = "/eth2/beacon_chain/req/status/1/" + encoder.ProtocolSuffixSSZSnappy
	GoodbyeProtocolID  = "/eth2/beacon_chain/req/goodbye/1/" + encoder.ProtocolSuffixSSZSnappy
	PingProtocolID     = "/eth2/beacon_chain/req/ping/1/" + encoder.ProtocolSuffixSSZSnappy
	MetaDataProtocolID = "/eth2/beacon_chain/req/metadata/2/" + encoder.ProtocolSuffixSSZSnappy
)

Variables

View Source
var (
	MESSAGE_DOMAIN_INVALID_SNAPPY = [4]byte{0x00, 0x00, 0x00, 0x00}
	MESSAGE_DOMAIN_VALID_SNAPPY   = [4]byte{0x01, 0x00, 0x00, 0x00}
)

Functions

func ConvertFromInterfacePrivKey

func ConvertFromInterfacePrivKey(privkey crypto.PrivKey) (*ecdsa.PrivateKey, error)

func EncodeGossip

func EncodeGossip(topic string, msg fastssz.Marshaler) ([]byte, []byte, error)

func PublishTopic

func PublishTopic(ctx context.Context, topicHandle *pubsub.Topic, data []byte, opts ...pubsub.PubOpt) error

Types

type BeaconClientPeer

type BeaconClientPeer struct {
	BeaconClient ENR
}

func (*BeaconClientPeer) GetPeerAddrInfo

func (bcp *BeaconClientPeer) GetPeerAddrInfo(ctx context.Context) (*peer.AddrInfo, error)

type ENR

type ENR interface {
	ENR(ctx context.Context) (string, error)
}

type Marshaler added in v1.0.5

type Marshaler interface {
	fastssz.Marshaler
	fastssz.Unmarshaler
}

func WrapSSZObject added in v1.0.5

func WrapSSZObject(sszObj common.SSZObj) Marshaler

func WrapSpecObject added in v1.0.5

func WrapSpecObject(spec *common.Spec, specObj common.SpecObj) Marshaler

type Status added in v1.0.5

type Status struct {
	*common.Status
	sync.Mutex
}

func NewStatus added in v1.0.5

func NewStatus() *Status

func (*Status) GetForkDigest added in v1.0.5

func (s *Status) GetForkDigest() common.ForkDigest

func (*Status) SetFinalizedCheckpoint added in v1.0.5

func (s *Status) SetFinalizedCheckpoint(c common.Checkpoint)

func (*Status) SetForkDigest added in v1.0.5

func (s *Status) SetForkDigest(d common.ForkDigest)

func (*Status) SetHead added in v1.0.5

func (s *Status) SetHead(h tree.Root, slot common.Slot)

type TestP2P

type TestP2P struct {
	InstanceID uint64

	// State objects
	ChainStatus *Status

	// Config
	ExternalIP             net.IP
	BeaconPortStart        int64
	MaxDevP2PSessionReuses int
	// contains filtered or unexported fields
}

func (*TestP2P) GetNextPeerIDs

func (t *TestP2P) GetNextPeerIDs(count uint64) []string

func (*TestP2P) GetTestPeer

func (t *TestP2P) GetTestPeer(ctx context.Context, count int) (TestPeers, error)

func (*TestP2P) NewTestPeer

func (t *TestP2P) NewTestPeer(ctx context.Context, port int64) (*TestPeer, error)

type TestPeer

type TestPeer struct {
	ID         TestPeerIndex
	Host       host.Host
	PubSub     *pubsub.PubSub
	PrivateKey crypto.PrivKey
	PublicKey  crypto.PubKey
	LocalNode  *enode.LocalNode

	MetaData *common.MetaData
	// contains filtered or unexported fields
}

func (*TestPeer) BroadcastBlobSidecar added in v1.0.5

func (p *TestPeer) BroadcastBlobSidecar(spec *common.Spec, blobSidecar *deneb.BlobSidecar, subnet *uint64) error

func (*TestPeer) BroadcastBlobSidecars added in v1.0.5

func (p *TestPeer) BroadcastBlobSidecars(spec *common.Spec, blobSidecars ...*deneb.BlobSidecar) error

func (*TestPeer) BroadcastSignedBeaconBlock added in v1.0.5

func (p *TestPeer) BroadcastSignedBeaconBlock(spec *common.Spec, signedBeaconBlock *deneb.SignedBeaconBlock) error

func (*TestPeer) Close

func (p *TestPeer) Close() error

func (*TestPeer) Connect

func (p *TestPeer) Connect(ctx context.Context, peer *BeaconClientPeer) error

func (*TestPeer) Goodbye

func (p *TestPeer) Goodbye(ctx context.Context, peer peer.ID) error

func (*TestPeer) SendInitialStatus

func (p *TestPeer) SendInitialStatus(ctx context.Context, peer peer.ID) error

func (*TestPeer) SetupStreams

func (p *TestPeer) SetupStreams() error

func (*TestPeer) WaitForP2PConnection

func (p *TestPeer) WaitForP2PConnection(ctx context.Context) error

type TestPeerIndex

type TestPeerIndex uint64

func (TestPeerIndex) Keys

func (id TestPeerIndex) Keys(instanceID uint64) (crypto.PrivKey, crypto.PubKey)

func (TestPeerIndex) PeerID

func (id TestPeerIndex) PeerID(instanceID uint64) string

func (TestPeerIndex) String

func (id TestPeerIndex) String() string

type TestPeers

type TestPeers []*TestPeer

func (TestPeers) BroadcastBlobSidecar added in v1.0.5

func (p TestPeers) BroadcastBlobSidecar(spec *common.Spec, blobSidecar *deneb.BlobSidecar, subnet *uint64) error

func (TestPeers) BroadcastBlobSidecars added in v1.0.5

func (p TestPeers) BroadcastBlobSidecars(spec *common.Spec, blobSidecars ...*deneb.BlobSidecar) error

func (TestPeers) BroadcastSignedBeaconBlock added in v1.0.5

func (p TestPeers) BroadcastSignedBeaconBlock(spec *common.Spec, signedBeaconBlockDeneb *deneb.SignedBeaconBlock) error

func (TestPeers) Close

func (pl TestPeers) Close() error

Jump to

Keyboard shortcuts

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