types

package
v0.0.0-...-a173fca Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2021 License: LGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MODULENAME = "p2p"
)

Variables

View Source
var (
	DefaultP2pConfigMainnet = &P2pConfig{
		Config: p2p.Config{
			DialRatio:       3,
			ListenAddr:      "0.0.0.0:10086",
			MaxPeers:        25,
			MaxPendingPeers: 10,
			NoDiscovery:     false,
			DiscoveryV5:     true,
			NAT:             nat.Any(),
			BootstrapNodes:  nil,
			Name:            "drepnode",
			StaticNodes:     []*enode.Node{},
		},
		DataDir: "",
	}

	DefaultP2pConfigTestnet = &P2pConfig{
		Config: p2p.Config{
			DialRatio:       3,
			ListenAddr:      "0.0.0.0:44444",
			MaxPeers:        25,
			MaxPendingPeers: 10,
			NoDiscovery:     false,
			DiscoveryV5:     true,
			NAT:             nat.Any(),
			BootstrapNodes:  nil,
			Name:            "drepnode",
			StaticNodes:     []*enode.Node{},
		},
		DataDir: "",
	}
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// This field must be set to a valid secp256k1 private key.
	PrivateKey *secp256k1.PrivateKey `toml:"-"`

	// MaxPeers is the maximum number of peers that can be
	// connected. It must be greater than zero.
	MaxPeers int

	// MaxPendingPeers is the maximum number of peers that can be pending in the
	// handshake phase, counted separately for inbound and outbound connections.
	// Zero defaults to preset values.
	MaxPendingPeers int `toml:",omitempty"`

	// DialRatio controls the ratio of inbound to dialed connections.
	// Example: a DialRatio of 2 allows 1/2 of connections to be dialed.
	// Setting DialRatio to zero defaults it to 3.
	DialRatio int `toml:",omitempty"`

	// NoDiscovery can be used to disable the peer discovery mechanism.
	// Disabling is useful for protocol debugging (manual topology).
	NoDiscovery bool

	// DiscoveryV5 specifies whether the new topic-discovery based V5 discovery
	// protocol should be started or not.
	DiscoveryV5 bool `toml:",omitempty"`

	// Name sets the node name of this server.
	// Use common.MakeName to create a name that follows existing conventions.
	Name string `toml:"-"`

	// BootstrapNodes are used to establish connectivity
	// with the rest of the network.
	BootstrapNodes []*enode.Node

	// BootstrapNodesV5 are used to establish connectivity
	// with the rest of the network using the V5 discovery
	// protocol.
	BootstrapNodesV5 []*discv5.Node `toml:",omitempty"`

	// Static nodes are used as pre-configured connections which are always
	// maintained and re-connected on disconnects.
	StaticNodes []*enode.Node

	// Trusted nodes are used as pre-configured connections which are always
	// allowed to connect, even above the peer limit.
	TrustedNodes []*enode.Node

	// Connectivity can be restricted to certain Node networks.
	// If this option is set to a non-nil value, only hosts which match one of the
	// Node networks contained in the list are considered.
	NetRestrict *netutil.Netlist `toml:",omitempty"`

	// NodeDatabase is the path to the database containing the previously seen
	// live nodes in the network.
	NodeDatabase string `toml:",omitempty"`

	// If ListenAddr is set to a non-nil address, the server
	// will listen for incoming connections.
	//
	// If the port is zero, the operating system will pick a port. The
	// ListenAddr field will be updated with the actual address when
	// the server is started.
	ListenAddr string

	// If set to a non-nil value, the given NAT port mapper
	// is used to make the listening port available to the
	// Internet.
	NAT nat.Interface `toml:",omitempty"`

	// If NoDial is true, the server will not dial any peers.
	NoDial bool `toml:",omitempty"`

	// If EnableMsgEvents is set then the server will emit PeerEvents
	// whenever a message is sent to or received from a peer
	EnableMsgEvents bool

	// Logger is a custom logger to use with the p2p.Server.
	Logger *logrus.Logger `toml:",omitempty"`
}

type P2pConfig

type P2pConfig struct {
	p2p.Config
	DataDir string `json:",omitempty"`
}

func (*P2pConfig) GeneratePrivateKey

func (c *P2pConfig) GeneratePrivateKey() *secp256k1.PrivateKey

func (*P2pConfig) NodeName

func (c *P2pConfig) NodeName() string

NodeName returns the devp2p node identifier.

func (*P2pConfig) ResolvePath

func (c *P2pConfig) ResolvePath(path string) string

ResolvePath resolves path in the instance directory.

Jump to

Keyboard shortcuts

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