p2p

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: ISC Imports: 70 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxRegainMempoolSize = 1000
)
View Source
const PeerStore = "peerstore"

Variables

This section is empty.

Functions

func BuildUserAgent

func BuildUserAgent(name string) string

func ConvertToInterfacePubkey

func ConvertToInterfacePubkey(pubkey *ecdsa.PublicKey) crypto.PubKey

func ConvertToSingleMultiAddr

func ConvertToSingleMultiAddr(node *qnode.Node) (ma.Multiaddr, error)

func IpAddr

func IpAddr() net.IP

Retrieves an external ipv4 address and converts into a libp2p formatted value.

func MakePeer

func MakePeer(addr string) (*peer.AddrInfo, error)

MakePeer from multiaddress string.

func MultiAddrFromString

func MultiAddrFromString(address string) (ma.Multiaddr, error)

func PrivateKey

func PrivateKey(dataDir string, privateKeyPath string, readWritePermissions os.FileMode) (crypto.PrivKey, error)

Determines a private key for p2p networking from the p2p service's configuration struct. If no key is found, it generates a new one.

func ProtocolDHT

func ProtocolDHT() protocol.ID

func SerializeQNR

func SerializeQNR(record *qnr.Record) (string, error)

SerializeQNR takes the qnr record in its key-value form and serializes it.

func ToECDSAPrivKey added in v1.0.20

func ToECDSAPrivKey(privKey crypto.PrivKey) (*ecdsa.PrivateKey, error)

func UseLogger

func UseLogger(logger l.Logger)

UseLogger uses a specified Logger to output package logging info.

Types

type Listener

type Listener interface {
	Self() *qnode.Node
	Close()
	Lookup(qnode.ID) []*qnode.Node
	Resolve(*qnode.Node) *qnode.Node
	RandomNodes() qnode.Iterator
	Ping(*qnode.Node) error
	RequestQNR(*qnode.Node) (*qnode.Node, error)
	LocalNode() *qnode.LocalNode
}

Listener defines the discovery V5 network interface that is used to communicate with other peers.

type PrivateP2PAPI

type PrivateP2PAPI struct {
	// contains filtered or unexported fields
}

func NewPrivateP2PAPI

func NewPrivateP2PAPI(s *Service) *PrivateP2PAPI

func (*PrivateP2PAPI) AddPeer

func (api *PrivateP2PAPI) AddPeer(qmaddr string) (interface{}, error)

func (*PrivateP2PAPI) Banlist added in v1.0.21

func (api *PrivateP2PAPI) Banlist() (interface{}, error)

Banlist

func (*PrivateP2PAPI) CheckConsistency added in v1.0.21

func (api *PrivateP2PAPI) CheckConsistency(hashOrNumber string) (interface{}, error)

func (*PrivateP2PAPI) DelPeer

func (api *PrivateP2PAPI) DelPeer(pid string) (interface{}, error)

func (*PrivateP2PAPI) DisableRelayTx added in v1.0.21

func (api *PrivateP2PAPI) DisableRelayTx(dis bool) (interface{}, error)

func (*PrivateP2PAPI) Pause

func (api *PrivateP2PAPI) Pause() (interface{}, error)

func (*PrivateP2PAPI) Ping

func (api *PrivateP2PAPI) Ping(addr string, port uint, protocol string) (interface{}, error)

func (*PrivateP2PAPI) ReloadPeers added in v1.0.20

func (api *PrivateP2PAPI) ReloadPeers() error

Reload All Peers

func (*PrivateP2PAPI) RemoveBan added in v1.0.21

func (api *PrivateP2PAPI) RemoveBan(id *string) (interface{}, error)

RemoveBan

func (*PrivateP2PAPI) ResetPeers

func (api *PrivateP2PAPI) ResetPeers() (interface{}, error)

func (*PrivateP2PAPI) SetLibp2pLogLevel added in v1.0.21

func (api *PrivateP2PAPI) SetLibp2pLogLevel(level string) (interface{}, error)

type PublicP2PAPI

type PublicP2PAPI struct {
	// contains filtered or unexported fields
}

func NewPublicP2PAPI

func NewPublicP2PAPI(s *Service) *PublicP2PAPI

func (*PublicP2PAPI) GetNetworkInfo added in v1.0.21

func (api *PublicP2PAPI) GetNetworkInfo() (interface{}, error)

func (*PublicP2PAPI) GetPeerInfo

func (api *PublicP2PAPI) GetPeerInfo(verbose *bool, pid *string) (interface{}, error)

Return the peer info

func (*PublicP2PAPI) IsCurrent added in v1.0.19

func (api *PublicP2PAPI) IsCurrent() (interface{}, error)

Return IsCurrent

type Rebroadcast

type Rebroadcast struct {
	// contains filtered or unexported fields
}

func NewRebroadcast

func NewRebroadcast(s *Service) *Rebroadcast

func (*Rebroadcast) AddInventory

func (r *Rebroadcast) AddInventory(h *hash.Hash, data interface{})

func (*Rebroadcast) RegainMempool

func (r *Rebroadcast) RegainMempool()

func (*Rebroadcast) RemoveInventory

func (r *Rebroadcast) RemoveInventory(hs []*hash.Hash)

func (*Rebroadcast) Start

func (r *Rebroadcast) Start()

func (*Rebroadcast) Stop

func (r *Rebroadcast) Stop() error

type Service

type Service struct {
	service.Service
	// contains filtered or unexported fields
}

func NewService

func NewService(cfg *config.Config, consensus model.Consensus, param *params.Params) (*Service, error)

func (*Service) APIs

func (s *Service) APIs() []api.API

func (*Service) BlockChain

func (s *Service) BlockChain() *blockchain.BlockChain

func (*Service) BroadcastBlock added in v1.2.0

func (s *Service) BroadcastBlock(block *types.SerializedBlock, source *peer.ID) error

func (*Service) BroadcastMessage

func (s *Service) BroadcastMessage(data interface{})

func (*Service) Config

func (s *Service) Config() *common.Config

func (*Service) Connect

func (s *Service) Connect(pi peer.AddrInfo) error

Connect to a specific peer.

func (*Service) ConnectTo

func (s *Service) ConnectTo(node *qnode.Node)

func (*Service) ConnectToPeer

func (s *Service) ConnectToPeer(qmaddr string, force bool) error

func (*Service) Consensus added in v1.0.21

func (s *Service) Consensus() model.Consensus

func (*Service) Disconnect

func (s *Service) Disconnect(pid peer.ID) error

Disconnect from a peer.

func (*Service) Encoding

func (s *Service) Encoding() encoder.NetworkEncoding

Encoding returns the configured networking encoding.

func (*Service) GetBanlist

func (s *Service) GetBanlist() map[peer.ID][]*json.BadResponse

func (*Service) GetGenesisHash

func (s *Service) GetGenesisHash() *hash.Hash

func (*Service) Host

func (s *Service) Host() host.Host

Host returns the currently running libp2p host of the service.

func (*Service) HostAddress

func (s *Service) HostAddress() []string

func (*Service) HostDNS

func (s *Service) HostDNS() multiaddr.Multiaddr

func (*Service) IncreaseBytesRecv

func (s *Service) IncreaseBytesRecv(pid peer.ID, size int)

func (*Service) IncreaseBytesSent

func (s *Service) IncreaseBytesSent(pid peer.ID, size int)

func (*Service) InterceptAccept

func (s *Service) InterceptAccept(n network.ConnMultiaddrs) (allow bool)

InterceptAccept tests whether an incipient inbound connection is allowed.

func (*Service) InterceptAddrDial

func (s *Service) InterceptAddrDial(p peer.ID, m multiaddr.Multiaddr) (allow bool)

InterceptAddrDial tests whether we're permitted to dial the specified multiaddr for the given peer.

func (*Service) InterceptPeerDial

func (s *Service) InterceptPeerDial(p peer.ID) (allow bool)

InterceptPeerDial tests whether we're permitted to Dial the specified peer.

func (*Service) InterceptSecured

func (s *Service) InterceptSecured(_ network.Direction, _ peer.ID, n network.ConnMultiaddrs) (allow bool)

InterceptSecured tests whether a given connection, now authenticated, is allowed.

func (*Service) InterceptUpgraded

func (s *Service) InterceptUpgraded(n network.Conn) (allow bool, reason control.DisconnectReason)

InterceptUpgraded tests whether a fully capable connection is allowed.

func (*Service) IsCurrent

func (s *Service) IsCurrent() bool

func (*Service) IsNearlySynced added in v1.2.0

func (s *Service) IsNearlySynced() bool

func (*Service) IsRunning added in v1.0.21

func (s *Service) IsRunning() bool

func (*Service) KademliaDHTOption

func (s *Service) KademliaDHTOption() libp2p.Option

func (*Service) Metadata

func (s *Service) Metadata() *pb.MetaData

Metadata returns a copy of the peer's metadata.

func (*Service) MetadataSeq

func (s *Service) MetadataSeq() uint64

MetadataSeq returns the metadata sequence number.

func (*Service) Node

func (s *Service) Node() *qnode.Node

func (*Service) Notify

func (s *Service) Notify() model.Notify

func (*Service) PeerID

func (s *Service) PeerID() peer.ID

PeerID returns the Peer ID of the local peer.

func (*Service) PeerSync

func (s *Service) PeerSync() *synch.PeerSync

func (*Service) Peers

func (s *Service) Peers() *peers.Status

Peers returns the peer status interface.

func (*Service) PubSub

func (s *Service) PubSub() *pubsub.PubSub

PubSub returns the p2p pubsub framework.

func (*Service) QNR

func (s *Service) QNR() *qnr.Record

QNR returns the local node's current QNR.

func (*Service) Rebroadcast

func (s *Service) Rebroadcast() *Rebroadcast

func (*Service) RefreshQNR

func (s *Service) RefreshQNR()

func (*Service) RegainMempool

func (s *Service) RegainMempool()

func (*Service) RelayInventory

func (s *Service) RelayInventory(nds []*notify.NotifyData)

func (*Service) RelayNodeInfo

func (s *Service) RelayNodeInfo() *peer.AddrInfo

func (*Service) RemoveBan

func (s *Service) RemoveBan(id string)

func (*Service) Resolve

func (s *Service) Resolve(n *qnode.Node) *qnode.Node

func (*Service) SetBlockChain

func (s *Service) SetBlockChain(blockChain *blockchain.BlockChain)

func (*Service) SetNotify

func (s *Service) SetNotify(notify model.Notify)

func (*Service) SetTimeSource

func (s *Service) SetTimeSource(timeSource model.MedianTimeSource)

func (*Service) SetTxMemPool

func (s *Service) SetTxMemPool(txMemPool *mempool.TxPool)

func (*Service) Start

func (s *Service) Start() error

func (*Service) Stop

func (s *Service) Stop() error

func (*Service) TimeSource

func (s *Service) TimeSource() model.MedianTimeSource

func (*Service) TxMemPool

func (s *Service) TxMemPool() *mempool.TxPool

Directories

Path Synopsis
Package discover implements the Node Discovery Protocol.
Package discover implements the Node Discovery Protocol.
Package iputils contains useful functions for ip address formatting.
Package iputils contains useful functions for ip address formatting.
Package netutil contains extensions to the net package.
Package netutil contains extensions to the net package.
proto
v1
Code generated by fastssz.
Code generated by fastssz.

Jump to

Keyboard shortcuts

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