2021-08-30 14:57:28 +00:00
|
|
|
package protocol
|
|
|
|
|
2023-02-22 21:58:17 +00:00
|
|
|
import (
|
2023-05-22 21:38:02 +00:00
|
|
|
"crypto/ecdsa"
|
|
|
|
|
2023-02-22 21:58:17 +00:00
|
|
|
"github.com/libp2p/go-libp2p/core/peer"
|
2024-08-16 18:24:21 +00:00
|
|
|
"github.com/multiformats/go-multiaddr"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/p2p/enode"
|
2022-11-24 15:00:44 +00:00
|
|
|
|
2023-02-22 21:58:17 +00:00
|
|
|
"github.com/status-im/status-go/eth-node/types"
|
|
|
|
)
|
|
|
|
|
2024-08-16 18:24:21 +00:00
|
|
|
func (m *Messenger) AddStorePeer(address multiaddr.Multiaddr) (peer.ID, error) {
|
2021-08-30 14:57:28 +00:00
|
|
|
return m.transport.AddStorePeer(address)
|
|
|
|
}
|
|
|
|
|
2024-08-16 18:24:21 +00:00
|
|
|
func (m *Messenger) AddRelayPeer(address multiaddr.Multiaddr) (peer.ID, error) {
|
2024-06-11 07:45:01 +00:00
|
|
|
return m.transport.AddRelayPeer(address)
|
2021-08-30 14:57:28 +00:00
|
|
|
}
|
|
|
|
|
2024-08-16 18:24:21 +00:00
|
|
|
func (m *Messenger) DialPeer(address multiaddr.Multiaddr) error {
|
2021-09-10 17:06:06 +00:00
|
|
|
return m.transport.DialPeer(address)
|
|
|
|
}
|
|
|
|
|
2024-08-16 18:24:21 +00:00
|
|
|
func (m *Messenger) DialPeerByID(peerID peer.ID) error {
|
2021-09-10 17:06:06 +00:00
|
|
|
return m.transport.DialPeerByID(peerID)
|
|
|
|
}
|
|
|
|
|
2024-08-16 18:24:21 +00:00
|
|
|
func (m *Messenger) DropPeer(peerID peer.ID) error {
|
2021-08-30 14:57:28 +00:00
|
|
|
return m.transport.DropPeer(peerID)
|
|
|
|
}
|
|
|
|
|
2024-08-16 18:24:21 +00:00
|
|
|
func (m *Messenger) Peers() types.PeerStats {
|
2021-08-30 14:57:28 +00:00
|
|
|
return m.transport.Peers()
|
|
|
|
}
|
2022-11-24 21:27:46 +00:00
|
|
|
|
2024-07-01 15:37:54 +00:00
|
|
|
func (m *Messenger) RelayPeersByTopic(topic string) (*types.PeerList, error) {
|
|
|
|
return m.transport.RelayPeersByTopic(topic)
|
|
|
|
}
|
|
|
|
|
2024-08-16 18:24:21 +00:00
|
|
|
func (m *Messenger) ListenAddresses() ([]multiaddr.Multiaddr, error) {
|
2022-11-24 21:27:46 +00:00
|
|
|
return m.transport.ListenAddresses()
|
|
|
|
}
|
2023-05-22 21:38:02 +00:00
|
|
|
|
2024-08-16 18:24:21 +00:00
|
|
|
func (m *Messenger) ENR() (*enode.Node, error) {
|
2024-06-18 19:48:49 +00:00
|
|
|
return m.transport.ENR()
|
|
|
|
}
|
|
|
|
|
2023-05-22 21:38:02 +00:00
|
|
|
// Subscribe to a pubsub topic, passing an optional public key if the pubsub topic is protected
|
|
|
|
func (m *Messenger) SubscribeToPubsubTopic(topic string, optPublicKey *ecdsa.PublicKey) error {
|
|
|
|
return m.transport.SubscribeToPubsubTopic(topic, optPublicKey)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Messenger) StorePubsubTopicKey(topic string, privKey *ecdsa.PrivateKey) error {
|
|
|
|
return m.transport.StorePubsubTopicKey(topic, privKey)
|
|
|
|
}
|