p2p

package
v0.0.13 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// DiscoveryInterval is how often we re-publish our mDNS records.
	DiscoveryInterval = time.Second

	// DiscoveryServiceTag is used in our mDNS advertisements to discover other chat peers.
	DiscoveryServiceTag = "bloxstaking.ssv"

	// MsgChanSize is the buffer size of the message channel
	MsgChanSize = 128
)

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, logger *zap.Logger, cfg *Config) (network.Network, error)

New is the constructor of p2pNetworker

func SetupNetworkMetrics added in v0.0.6

func SetupNetworkMetrics(logger *zap.Logger, net network.Network)

SetupNetworkMetrics initialize collector for process metrics

func TransformEnr added in v0.0.4

func TransformEnr(enr string) []string

TransformEnr converts defaults enr value and convert it to slice

Types

type Config

type Config struct {
	// yaml/env arguments
	Enr              string        `yaml:"Enr" env:"ENR_KEY" env-description:"enr used in discovery" env-default:""`
	DiscoveryType    string        `yaml:"DiscoveryType" env:"DISCOVERY_TYPE_KEY" env-description:"Method to use in discovery" env-default:"discv5"`
	TCPPort          int           `yaml:"TcpPort" env:"TCP_PORT" env-default:"13000"`
	UDPPort          int           `yaml:"UdpPort" env:"UDP_PORT" env-default:"12000"`
	HostAddress      string        `yaml:"HostAddress" env:"HOST_ADDRESS" env-required:"true" env-description:"External ip node is exposed for discovery"`
	HostDNS          string        `yaml:"HostDNS" env:"HOST_DNS" env-description:"External DNS node is exposed for discovery"`
	RequestTimeout   time.Duration `yaml:"RequestTimeout" env:"P2P_REQUEST_TIMEOUT"  env-default:"5s"`
	MaxBatchResponse uint64        `yaml:"MaxBatchResponse" env:"P2P_MAX_BATCH_RESPONSE" env-description:"maximum number of returned objects in a batch"`

	// objects / instances
	HostID              peer.ID
	Topics              map[string]*pubsub.Topic
	Discv5BootStrapAddr []string
}

Config - describe the config options for p2p network

type SyncStream

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

SyncStream is a wrapper struct for the core.Stream interface to match the network.SyncStream interface

func (*SyncStream) Close

func (s *SyncStream) Close() error

Close closes the stream

func (*SyncStream) CloseWrite

func (s *SyncStream) CloseWrite() error

CloseWrite closes write stream

func (*SyncStream) Read

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

Read reads data to p

func (*SyncStream) RemotePeer

func (s *SyncStream) RemotePeer() string

RemotePeer returns connected peer

func (*SyncStream) Write

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

Write writes p to stream

type TestValidatorStorage

type TestValidatorStorage struct {
}

TestValidatorStorage implementation

func (*TestValidatorStorage) GetAllValidatorsShare

func (v *TestValidatorStorage) GetAllValidatorsShare() ([]*storage.Share, error)

GetAllValidatorsShare implementation

func (*TestValidatorStorage) LoadFromConfig

func (v *TestValidatorStorage) LoadFromConfig(nodeID uint64, pubKey *bls.PublicKey, shareKey *bls.SecretKey, ibftCommittee map[uint64]*proto.Node) error

LoadFromConfig implementation

func (*TestValidatorStorage) SaveValidatorShare

func (v *TestValidatorStorage) SaveValidatorShare(validator *storage.Share) error

SaveValidatorShare implementation

Jump to

Keyboard shortcuts

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