mirror of https://github.com/status-im/go-waku.git
feat: include pubsubTopics supported by peer in getPeers REST API (#943)
This commit is contained in:
parent
13e2d7ac4b
commit
5a5ee51f4b
|
@ -27,6 +27,7 @@ type WakuPeer struct {
|
||||||
MultiAddrs []string `json:"multiaddrs"`
|
MultiAddrs []string `json:"multiaddrs"`
|
||||||
Protocols []string `json:"protocols"`
|
Protocols []string `json:"protocols"`
|
||||||
Connected bool `json:"connected"`
|
Connected bool `json:"connected"`
|
||||||
|
PubsubTopics []string `json:"pubsubTopics"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WakuPeerInfo struct {
|
type WakuPeerInfo struct {
|
||||||
|
@ -76,6 +77,7 @@ func (a *AdminService) getV1Peers(w http.ResponseWriter, req *http.Request) {
|
||||||
}
|
}
|
||||||
wPeer.Protocols = append(wPeer.Protocols, string(proto))
|
wPeer.Protocols = append(wPeer.Protocols, string(proto))
|
||||||
}
|
}
|
||||||
|
wPeer.PubsubTopics = peer.PubsubTopics
|
||||||
response = append(response, wPeer)
|
response = append(response, wPeer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,3 +86,7 @@ components:
|
||||||
type: string
|
type: string
|
||||||
connected:
|
connected:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
pubsubTopics:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
|
@ -57,6 +57,7 @@ type Peer struct {
|
||||||
Protocols []protocol.ID `json:"protocols"`
|
Protocols []protocol.ID `json:"protocols"`
|
||||||
Addrs []ma.Multiaddr `json:"addrs"`
|
Addrs []ma.Multiaddr `json:"addrs"`
|
||||||
Connected bool `json:"connected"`
|
Connected bool `json:"connected"`
|
||||||
|
PubsubTopics []string `json:"pubsubTopics"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type storeFactory func(w *WakuNode) store.Store
|
type storeFactory func(w *WakuNode) store.Store
|
||||||
|
@ -858,11 +859,16 @@ func (w *WakuNode) Peers() ([]*Peer, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
addrs := utils.EncapsulatePeerID(peerId, w.host.Peerstore().Addrs(peerId)...)
|
addrs := utils.EncapsulatePeerID(peerId, w.host.Peerstore().Addrs(peerId)...)
|
||||||
|
topics, err := w.host.Peerstore().(*wps.WakuPeerstoreImpl).PubSubTopics(peerId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
peers = append(peers, &Peer{
|
peers = append(peers, &Peer{
|
||||||
ID: peerId,
|
ID: peerId,
|
||||||
Protocols: protocols,
|
Protocols: protocols,
|
||||||
Connected: connected,
|
Connected: connected,
|
||||||
Addrs: addrs,
|
Addrs: addrs,
|
||||||
|
PubsubTopics: topics,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return peers, nil
|
return peers, nil
|
||||||
|
|
Loading…
Reference in New Issue