Documentation
¶
Index ¶
- func GetMultiAddrFromString(addr string) (multiaddr.Multiaddr, error)
- type Interface
- type Node
- func (n *Node) Advertise(ctx context.Context, ns string)
- func (n *Node) Bootstrap(ctx context.Context, bootstrapPeers []string) error
- func (n *Node) ConnectToPeerWithMultiaddr(ctx context.Context, addr multiaddr.Multiaddr) (*peer.AddrInfo, error)
- func (n *Node) DiscoverPeers(ctx context.Context, ns string) error
- func (n *Node) FindPeers(ctx context.Context, peerIDs []peer.ID) []peer.AddrInfo
- func (n *Node) GetID() string
- func (n *Node) GetMultiaddr() ([]multiaddr.Multiaddr, error)
- func (n *Node) GetPeerID() peer.ID
- func (n *Node) GetSyncing() bool
- func (n *Node) HandleIncomingMessages(ctx context.Context, topicName string) error
- func (n *Node) HeighestBlockNumberDiscovered() uint64
- func (n *Node) JoinPubSubNetwork(topicName string) error
- func (n *Node) Peers() peer.IDSlice
- func (n *Node) PublishMessageToNetwork(ctx context.Context, topicName string, data []byte) error
- func (n *Node) Sync(ctx context.Context) error
- func (n *Node) Uptime() int64
- type PeerFinderBootstrapper
- type PublishSubscriber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMultiAddrFromString ¶
GetMultiAddrFromString gets the multiaddress from the string encoded address.
Types ¶
type Interface ¶
type Interface interface { GetSyncing() bool Sync(ctx context.Context) error ConnectToPeerWithMultiaddr(ctx context.Context, addr multiaddr.Multiaddr) (*peer.AddrInfo, error) Advertise(ctx context.Context, ns string) DiscoverPeers(ctx context.Context, ns string) error PublishMessageToNetwork(ctx context.Context, topicName string, data []byte) error HandleIncomingMessages(ctx context.Context, topicName string) error GetMultiaddr() ([]multiaddr.Multiaddr, error) Peers() peer.IDSlice GetID() string GetPeerID() peer.ID Bootstrap(ctx context.Context, bootstrapPeers []string) error FindPeers(ctx context.Context, peerIDs []peer.ID) []peer.AddrInfo JoinPubSubNetwork(topicName string) error HeighestBlockNumberDiscovered() uint64 Uptime() int64 }
Interface defines a node's functionalities.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node represents all the node functionalities
func New ¶
func New(cfg *ffgconfig.Config, host host.Host, dht PeerFinderBootstrapper, discovery libp2pdiscovery.Discovery, pubSub PublishSubscriber, search search.IndexSearcher, storage storage.Interface, blockchain blockchain.Interface, dataQuery dataquery.Interface, blockDownloaderProtocol blockdownloader.Interface, storageProtocol storageprotocol.Interface, uptime int64) (*Node, error)
New creates a new node.
func (*Node) ConnectToPeerWithMultiaddr ¶
func (n *Node) ConnectToPeerWithMultiaddr(ctx context.Context, addr multiaddr.Multiaddr) (*peer.AddrInfo, error)
ConnectToPeerWithMultiaddr connects to a node given its full address.
func (*Node) DiscoverPeers ¶
DiscoverPeers discovers peers from randevouz point.
func (*Node) GetMultiaddr ¶
GetMultiaddr returns the peers multiaddr.
func (*Node) GetSyncing ¶
GetSyncing returns true if node is syncing.
func (*Node) HandleIncomingMessages ¶
HandleIncomingMessages gets the messages from gossip network.
func (*Node) HeighestBlockNumberDiscovered ¶ added in v1.1.16
nolint:misspell HeighestBlockNumberDiscovered gets the heighest block discovered from other peers in the network.
func (*Node) JoinPubSubNetwork ¶
JoinPubSubNetwork joins the gossip network.
func (*Node) PublishMessageToNetwork ¶
PublishMessageToNetwork publish a message to the network.
type PeerFinderBootstrapper ¶
type PeerFinderBootstrapper interface { FindPeer(ctx context.Context, id peer.ID) (_ peer.AddrInfo, err error) Bootstrap(ctx context.Context) error }
PeerFinderBootstrapper is a dht interface.
type PublishSubscriber ¶
type PublishSubscriber interface { // Publish to a topic. Publish(topic string, data []byte, opts ...pubsub.PubOpt) error // Join a topic. Join(topic string, opts ...pubsub.TopicOpt) (*pubsub.Topic, error) // Subscribe to a topic. Subscribe(topic string, opts ...pubsub.SubOpt) (*pubsub.Subscription, error) }
PublishSubscriber is a pub sub interface.