feat: add wakuext_listenAddresses

This commit is contained in:
Richard Ramos 2022-11-24 17:27:46 -04:00 committed by RichΛrd
parent f87a38074a
commit ee6bda5bcc
7 changed files with 32 additions and 0 deletions

View File

@ -74,6 +74,11 @@ func (w *gethWakuWrapper) DialPeerByID(peerID string) error {
return errors.New("not available in WakuV1")
}
// ListenAddresses function only added for compatibility with waku V2
func (w *gethWakuWrapper) ListenAddresses() ([]string, error) {
return nil, errors.New("not available in WakuV1")
}
// PeerCount function only added for compatibility with waku V2
func (w *gethWakuWrapper) DropPeer(peerID string) error {
return errors.New("not available in WakuV1")

View File

@ -253,6 +253,10 @@ func (w *gethWakuV2Wrapper) DialPeerByID(peerID string) error {
return w.waku.DialPeerByID(peerID)
}
func (w *gethWakuV2Wrapper) ListenAddresses() ([]string, error) {
return w.waku.ListenAddresses(), nil
}
func (w *gethWakuV2Wrapper) DropPeer(peerID string) error {
return w.waku.DropPeer(peerID)
}

View File

@ -76,6 +76,8 @@ type Waku interface {
// PeerCount
PeerCount() int
ListenAddresses() ([]string, error)
Peers() map[string]WakuV2Peer
StartDiscV5() error

View File

@ -25,3 +25,7 @@ func (m *Messenger) DropPeer(peerID string) error {
func (m *Messenger) Peers() map[string]types.WakuV2Peer {
return m.transport.Peers()
}
func (m *Messenger) ListenAddresses() ([]string, error) {
return m.transport.ListenAddresses()
}

View File

@ -619,6 +619,10 @@ func (t *Transport) StopDiscV5() error {
return t.waku.StopDiscV5()
}
func (t *Transport) ListenAddresses() ([]string, error) {
return t.waku.ListenAddresses()
}
func (t *Transport) AddStorePeer(address string) (string, error) {
return t.waku.AddStorePeer(address)
}

View File

@ -1163,6 +1163,10 @@ func (api *PublicAPI) Peers() map[string]types.WakuV2Peer {
return api.service.messenger.Peers()
}
func (api *PublicAPI) ListenAddresses() ([]string, error) {
return api.service.messenger.ListenAddresses()
}
func (api *PublicAPI) ChangeIdentityImageShowTo(showTo settings.ProfilePicturesShowToType) error {
err := api.service.accountsDB.SaveSettingField(settings.ProfilePicturesShowTo, showTo)
if err != nil {

View File

@ -1125,6 +1125,15 @@ func (w *Waku) Peers() map[string]types.WakuV2Peer {
return FormatPeerStats(w.node, w.node.PeerStats())
}
func (w *Waku) ListenAddresses() []string {
addrs := w.node.ListenAddresses()
var result []string
for _, addr := range addrs {
result = append(result, addr.String())
}
return result
}
func (w *Waku) StartDiscV5() error {
if w.node.DiscV5() == nil {
return errors.New("discv5 is not setup")