Documentation ¶
Index ¶
- Constants
- Variables
- func FromECDSA(priv *ecdsa.PrivateKey) []byte
- func GenerateKey() (*ecdsa.PrivateKey, error)
- func LoadECDSA(file string) (*ecdsa.PrivateKey, error)
- func P2pDefaultDataDir(flag bool) string
- func P2pGetUserHomeDir() string
- func P2pNodeId2HexString(id NodeID) string
- func S256() elliptic.Curve
- func SaveECDSA(file string, key *ecdsa.PrivateKey) error
- func ToECDSA(d []byte) (*ecdsa.PrivateKey, error)
- type Cfg4PeerListener
- type Cfg4PeerManager
- type Cfg4Protocols
- type Cfg4TabManager
- type Cfg4UdpListener
- type Config
- type Node
- type NodeID
- type P2pCfgErrno
- type Protocol
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",
}
View Source
var BootstrapNodes = P2pSetupDefaultBootstrapNodes()
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.
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
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
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
Click to show internal directories.
Click to hide internal directories.