chore(REST): returning lightpush support and updated filter protocol (#2219)

This commit is contained in:
gabrielmer 2023-11-22 10:56:23 +02:00 committed by GitHub
parent c48accb513
commit 59ee3c69c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 0 deletions

View File

@ -16,6 +16,8 @@ import
../../../waku_core,
../../../waku_store,
../../../waku_filter,
../../../waku_filter_v2,
../../../waku_lightpush,
../../../waku_relay,
../../../waku_node,
../../../node/peer_manager,
@ -61,6 +63,14 @@ proc installAdminV1GetPeersHandler(router: var RestRouter, node: WakuNode) =
connected: it.connectedness == Connectedness.Connected))
tuplesToWakuPeers(peers, filterPeers)
if not node.wakuFilter.isNil():
# Map WakuFilter peers to WakuPeers and add to return list
let filterV2Peers = node.peerManager.peerStore.peers(WakuFilterSubscribeCodec)
.mapIt((multiaddr: constructMultiaddrStr(it),
protocol: WakuFilterSubscribeCodec,
connected: it.connectedness == Connectedness.Connected))
tuplesToWakuPeers(peers, filterV2Peers)
if not node.wakuStore.isNil():
# Map WakuStore peers to WakuPeers and add to return list
let storePeers = node.peerManager.peerStore
@ -70,6 +80,15 @@ proc installAdminV1GetPeersHandler(router: var RestRouter, node: WakuNode) =
connected: it.connectedness == Connectedness.Connected))
tuplesToWakuPeers(peers, storePeers)
if not node.wakuLightPush.isNil():
# Map WakuStore peers to WakuPeers and add to return list
let lightpushPeers = node.peerManager.peerStore
.peers(WakuLightPushCodec)
.mapIt((multiaddr: constructMultiaddrStr(it),
protocol: WakuLightPushCodec,
connected: it.connectedness == Connectedness.Connected))
tuplesToWakuPeers(peers, lightpushPeers)
let resp = RestApiResponse.jsonResponse(peers, status=Http200)
if resp.isErr():
error "An error ocurred while building the json respose: ", error=resp.error