p2p

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: GPL-3.0 Imports: 50 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
)
View Source
const (

	// UserAgentKey is the key for storing to the user agent value
	UserAgentKey = "user-agent"
)

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 NewSyncStream added in v0.1.5

func NewSyncStream(stream core.Stream) network.SyncStream

NewSyncStream returns a new instance of syncStream

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        `` /* 133-byte string literal not displayed */
	PubSubTraceOut   string        `yaml:"PubSubTraceOut" env:"PUBSUB_TRACE_OUT" env-description:"File path to hold collected pubsub traces"`

	NetworkTrace bool `yaml:"NetworkTrace" env:"NETWORK_TRACE" env-description:"A boolean flag to turn on network debugging"`

	ExporterPeerID string `` /* 152-byte string literal not displayed */

	Fork forks.Fork

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

	// NetworkPrivateKey is used for network identity
	NetworkPrivateKey *ecdsa.PrivateKey
	// OperatorPrivateKey is used for operator identity
	OperatorPrivateKey *rsa.PrivateKey
	// ReportLastMsg whether to report last msg metric
	ReportLastMsg bool
	// NodeType differentiate exporters peers from others
	NodeType NodeType
}

Config - describe the config options for p2p network

type IndexData added in v0.1.2

type IndexData map[string]string

IndexData is the type of stored data

type NodeType added in v0.1.5

type NodeType int64

NodeType indicate node operation type. In purpose for distinguish between different types of peers

const (
	Unknown NodeType = iota
	Operator
	Exporter
)

NodeTypes are const types for NodeType

func (NodeType) FromString added in v0.1.5

func (nt NodeType) FromString(nodeType string) NodeType

FromString convert string to NodeType. If not exist, return Unknown

func (NodeType) String added in v0.1.5

func (nt NodeType) String() string

type PeersIndex added in v0.1.2

type PeersIndex interface {
	Run()
	GetPeerData(pid, key string) string
	IndexPeer(conn network.Conn)
}

PeersIndex is responsible for indexing peers information index data is not persisted at the moment

func NewPeersIndex added in v0.1.2

func NewPeersIndex(host host.Host, ids *identify.IDService, logger *zap.Logger) PeersIndex

NewPeersIndex creates a new instance

type Storage added in v0.1.5

type Storage interface {
	GetPrivateKey() (*ecdsa.PrivateKey, bool, error)
	SavePrivateKey(privateKey *ecdsa.PrivateKey) error
	SetupPrivateKey(NetworkPrivateKey string) error
}

Storage represents the interface for ssv node storage

func NewP2PStorage added in v0.1.5

func NewP2PStorage(db basedb.IDb, logger *zap.Logger) Storage

NewP2PStorage creates a new instance of Storage

Jump to

Keyboard shortcuts

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