Documentation ¶
Index ¶
Constants ¶
const ( PublicReachability = "public" PrivateReachability = "private" )
Variables ¶
This section is empty.
Functions ¶
func EnsureIdentity ¶ added in v1.0.0
EnsureIdentity generates an identity key file in given directory.
func PrettyIdentityInfoFromDir ¶ added in v1.0.0
PrettyIdentityInfoFromDir returns a printable ID from a given identity directory.
Types ¶
type Config ¶ added in v1.0.0
type Config struct { DataDir string LogLevel log.Level GracePeersShutdown time.Duration MaxMessageSize int // see https://lwn.net/Articles/542629/ for reuseport explanation DisableReusePort bool `mapstructure:"disable-reuseport"` DisableNatPort bool `mapstructure:"disable-natport"` DisableConnectionManager bool `mapstructure:"disable-connection-manager"` DisableResourceManager bool `mapstructure:"disable-resource-manager"` DisableDHT bool `mapstructure:"disable-dht"` Flood bool `mapstructure:"flood"` Listen string `mapstructure:"listen"` Bootnodes []string `mapstructure:"bootnodes"` Direct []string `mapstructure:"direct"` MinPeers int `mapstructure:"min-peers"` LowPeers int `mapstructure:"low-peers"` HighPeers int `mapstructure:"high-peers"` InboundFraction float64 `mapstructure:"inbound-fraction"` OutboundFraction float64 `mapstructure:"outbound-fraction"` AutoscalePeers bool `mapstructure:"autoscale-peers"` AdvertiseAddress string `mapstructure:"advertise-address"` AcceptQueue int `mapstructure:"p2p-accept-queue"` Metrics bool `mapstructure:"p2p-metrics"` Bootnode bool `mapstructure:"p2p-bootnode"` ForceReachability string `mapstructure:"p2p-reachability"` EnableHolepunching bool `mapstructure:"p2p-holepunching"` DisableLegacyDiscovery bool `mapstructure:"p2p-disable-legacy-discovery"` PrivateNetwork bool `mapstructure:"p2p-private-network"` RelayServer RelayServer `mapstructure:"relay-server"` IP4Blocklist []string `mapstructure:"ip4-blocklist"` IP6Blocklist []string `mapstructure:"ip6-blocklist"` }
Config for all things related to p2p layer.
type ConnectionInfo ¶ added in v1.1.2
type Host ¶ added in v1.0.0
Host is a conveniency wrapper for all p2p related functionality required to run a full spacemesh node.
func New ¶
func New(_ context.Context, logger log.Log, cfg Config, prologue []byte, opts ...Opt) (*Host, error)
New initializes libp2p host configured for spacemesh.
func (*Host) ConnectedPeerInfo ¶ added in v1.1.2
ConnectedPeerInfo retrieves a peer info object for the given peer.ID, if the given peer is not connected then nil is returned.
func (*Host) PeerProtocols ¶ added in v1.1.0
PeerProtocols returns the protocols supported by peer.
type Opt ¶ added in v1.0.0
type Opt func(fh *Host)
Opt is for configuring Host.
func WithBootnodes ¶ added in v1.1.2
func WithContext ¶ added in v1.0.0
WithContext set context for Host.
func WithDirectNodes ¶ added in v1.1.2
func WithNodeReporter ¶ added in v1.0.0
func WithNodeReporter(reporter func()) Opt
WithNodeReporter updates reporter that is notified every time when node added or removed a peer.
type Peer ¶
Peer is an alias to libp2p's peer.ID.
const NoPeer Peer = ""
NoPeer is used when peer doesn't matter.
type PeerInfo ¶ added in v1.1.2
type PeerInfo struct { ID Peer Connections []ConnectionInfo Tags []string }
PeerInfo groups relevant information about a peer.