refactor(wakunode2): add convenience methods for adding protocol peers

This commit is contained in:
Lorenzo Delgado 2022-09-01 17:02:58 +02:00 committed by GitHub
parent ea62e2b7ce
commit 982fb08c77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 7 deletions

View File

@ -590,26 +590,32 @@ proc connectToNode(n: WakuNode, remotePeer: RemotePeerInfo, source = "api") {.as
error "Failed to connect to peer", wireAddr = remotePeer.addrs[0], peerId = remotePeer.peerId
waku_node_errors.inc(labelValues = ["conn_init_failure"])
proc setStorePeer*(n: WakuNode, peer: RemotePeerInfo) =
n.wakuStore.setPeer(peer)
proc setStorePeer*(n: WakuNode, address: string) {.raises: [Defect, ValueError, LPError].} =
info "Set store peer", address = address
let remotePeer = parseRemotePeerInfo(address)
let peer = parseRemotePeerInfo(address)
n.setStorePeer(peer)
n.wakuStore.setPeer(remotePeer)
proc setFilterPeer*(n: WakuNode, peer: RemotePeerInfo) =
n.wakuFilter.setPeer(peer)
proc setFilterPeer*(n: WakuNode, address: string) {.raises: [Defect, ValueError, LPError].} =
info "Set filter peer", address = address
let remotePeer = parseRemotePeerInfo(address)
let peer = parseRemotePeerInfo(address)
n.setFilterPeer(peer)
n.wakuFilter.setPeer(remotePeer)
proc setLightPushPeer*(n: WakuNode, peer: RemotePeerInfo) =
n.wakuLightPush.setPeer(peer)
proc setLightPushPeer*(n: WakuNode, address: string) {.raises: [Defect, ValueError, LPError].} =
info "Set lightpush peer", address = address
let remotePeer = parseRemotePeerInfo(address)
n.wakuLightPush.setPeer(remotePeer)
let peer = parseRemotePeerInfo(address)
n.wakuLightPush.setPeer(peer)
proc connectToNodes*(n: WakuNode, nodes: seq[string], source = "api") {.async.} =
## `source` indicates source of node addrs (static config, api call, discovery, etc)