p2p

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: ISC Imports: 64 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolDHT protocol.ID = "/qitmeer/kad/1.0.0"
)

Variables

This section is empty.

Functions

func BuildUserAgent added in v0.10.2

func BuildUserAgent(name string) string

func ConvertToInterfacePrivkey

func ConvertToInterfacePrivkey(privkey *ecdsa.PrivateKey) crypto.PrivKey

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) (*ecdsa.PrivateKey, 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 SerializeQNR

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

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

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 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) RemoveInventory

func (r *Rebroadcast) RemoveInventory(h *hash.Hash)

func (*Rebroadcast) Start

func (r *Rebroadcast) Start()

func (*Rebroadcast) Stop

func (r *Rebroadcast) Stop() error

type Service

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

func NewService

func NewService(cfg *config.Config, events *event.Feed, param *params.Params) (*Service, error)

func (*Service) BlockChain

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

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) Context

func (s *Service) Context() context.Context

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[string]int

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() ma.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(_ 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) 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() notify.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) RelayInventory

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

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 notify.Notify)

func (*Service) SetTimeSource

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

func (*Service) SetTxMemPool

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

func (*Service) Start

func (s *Service) Start() error

func (*Service) Started

func (s *Service) Started() bool

Started returns true if the p2p service has successfully started.

func (*Service) Stop

func (s *Service) Stop() error

func (*Service) TimeSource

func (s *Service) TimeSource() blockchain.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