config

package
v0.0.0-...-bd3bf0e Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2020 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PcfgEnoNone = iota
	PcfgEnoParameter
	PcfgEnoPublicKye
	PcfgEnoPrivateKye
	PcfgEnoDataDir
	PcfgEnoDatabase
	PcfgEnoIpAddr
	PcfgEnoNodeId
)
View Source
const MaxInbounds = MaxPeers / 2

Max concurrecny inboudn and outbound

View Source
const MaxOutbounds = MaxPeers / 2
View Source
const MaxPeers = 32

Max peers

View Source
const MaxProtocols = 32

Max protocols

View Source
const NodeIDBits = 512

Node ID length in bits

View Source
const NodeIDBytes = NodeIDBits / 8
View Source
const P2pMaxBootstrapNodes = 32

Bootstrap nodes, in a format like:

node-identity-hex-string@ip:udp-port:tcp-port
View Source
const (
	PcfgEnoIpAddrivateKey = "nodekey" // Path within the datadir to the node's private key

)

Some paths

Variables

View Source
var BootstrapNodeUrl = []string{

	"7552072DFE9BCB9F51FD65459E9AEF77FE02D4210C227668663A6E81792CE3216FB7CDBD8AA589C49D0279824F6011D2719C1540B42B24F94A9C3006C98388DB@192.168.2.129:30303:30303",
}

Build "Node" struct for bootstraps

View Source
var PtrConfig = &config

Functions

func FromECDSA

func FromECDSA(priv *ecdsa.PrivateKey) []byte

FromECDSA exports a private key into a binary dump.

func GenerateKey

func GenerateKey() (*ecdsa.PrivateKey, error)

func LoadECDSA

func LoadECDSA(file string) (*ecdsa.PrivateKey, error)

LoadECDSA loads a secp256k1 private key from the given file.

func P2pDefaultDataDir

func P2pDefaultDataDir(flag bool) string

Get default data directory

func P2pGetUserHomeDir

func P2pGetUserHomeDir() string

Get user directory

func P2pNodeId2HexString

func P2pNodeId2HexString(id NodeID) string

Node identity to hex string

func S256

func S256() elliptic.Curve

by yeeco, alias Ethereum's S256 to elliptic.P256

func SaveECDSA

func SaveECDSA(file string, key *ecdsa.PrivateKey) error

SaveECDSA saves a secp256k1 private key to the given file with restrictive permissions. The key data is saved hex-encoded.

func ToECDSA

func ToECDSA(d []byte) (*ecdsa.PrivateKey, error)

ToECDSA creates a private key with the given D value.

Types

type Cfg4PeerListener

type Cfg4PeerListener struct {
	IP          net.IP // ip address
	Port        uint16 // port numbers
	ID          NodeID // the node's public key
	MaxInBounds int    // max concurrency inbounds
}

Configuration about peer listener on TCP

func P2pConfig4PeerListener

func P2pConfig4PeerListener() *Cfg4PeerListener

Get configuration of peer listener

type Cfg4PeerManager

type Cfg4PeerManager struct {
	IP            net.IP     // ip address
	Port          uint16     // tcp port number
	UDP           uint16     // udp port number, used with handshake procedure
	ID            NodeID     // the node's public key
	MaxPeers      int        // max peers would be
	MaxOutbounds  int        // max concurrency outbounds
	MaxInBounds   int        // max concurrency inbounds
	Statics       []*Node    // static nodes
	NoDial        bool       // do not dial outbound
	BootstrapNode bool       // local is a bootstrap node
	ProtoNum      uint32     // local protocol number
	Protocols     []Protocol // local protocol table
}

func P2pConfig4PeerManager

func P2pConfig4PeerManager() *Cfg4PeerManager

Get configuration of peer manager

type Cfg4Protocols

type Cfg4Protocols struct {
	ProtoNum  uint32     // local protocol number
	Protocols []Protocol // local protocol table
}

Configuration about protocols supported

func P2pConfig4Protocols

func P2pConfig4Protocols() *Cfg4Protocols

Get protocols

type Cfg4TabManager

type Cfg4TabManager struct {
	Local          Node    // local node
	BootstrapNodes []*Node // bootstrap nodes
	DataDir        string  // data directory
	NodeDB         string  // node database
	BootstrapNode  bool    // bootstrap node flag
}

Configuration about table manager

func P2pConfig4TabManager

func P2pConfig4TabManager() *Cfg4TabManager

Get configuration op table manager

type Cfg4UdpListener

type Cfg4UdpListener struct {
	IP  net.IP // ip address
	UDP uint16 // udp port numbers
	TCP uint16 // tcp port numbers
	ID  NodeID // the node's public key
}

Configuration about neighbor listener on UDP

func P2pConfig4UdpListener

func P2pConfig4UdpListener() *Cfg4UdpListener

Get configuration of neighbor discovering listener

type Config

type Config struct {
	Version        string            // p2p version
	PrivateKey     *ecdsa.PrivateKey // node private key
	PublicKey      *ecdsa.PublicKey  // node public key
	MaxPeers       int               // max peers can be
	MaxInbounds    int               // max peers for inbound concurrency establishing can be
	MaxOutbounds   int               // max peers for outbound concurrency establishing can be
	Name           string            // node name
	BootstrapNodes []*Node           // bootstrap nodes
	StaticNodes    []*Node           // static nodes
	NodeDataDir    string            // node data directory
	NodeDatabase   string            // node database
	ListenAddr     string            // address listened
	NoDial         bool              // outboundless flag
	BootstrapNode  bool              // bootstrap node flag
	Local          Node              // myself
	ProtoNum       uint32            // local protocol number
	Protocols      []Protocol        // local protocol table
}

Node static Configuration parameters

func P2pDefaultConfig

func P2pDefaultConfig() *Config

Get default config

func P2pGetConfig

func P2pGetConfig() *Config

Get global configuration pointer

type Node

type Node struct {
	IP       net.IP // ip address
	UDP, TCP uint16 // port numbers
	ID       NodeID // the node's public key
}

Node

func P2pSetupDefaultBootstrapNodes

func P2pSetupDefaultBootstrapNodes() []*Node

Setup default bootstrap nodes

type NodeID

type NodeID [NodeIDBytes]byte

Node identity

func P2pHexString2NodeId

func P2pHexString2NodeId(hex string) *NodeID

Hex-string to node identity

type P2pCfgErrno

type P2pCfgErrno int

errno

func P2pSetConfig

func P2pSetConfig(cfg *Config) P2pCfgErrno

P2pSetConfig

type Protocol

type Protocol struct {
	Pid uint32  // protocol identity
	Ver [4]byte // protocol version: M.m0.m1.m2
}

Jump to

Keyboard shortcuts

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