From 7477f28d20b803246110d04833cd970ca620ccfb Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 10 Sep 2021 15:56:12 -0400 Subject: [PATCH] Revert "wakuv2 connectivity and peer management (#13)" This reverts commit e474468da384cfd1fce4fd06556e99e043b3268c. --- status/libstatus/core.nim | 21 --------------------- status/libstatus/mailservers.nim | 5 ++--- status/network.nim | 15 ++------------- status/settings.nim | 3 --- status/signals.nim | 5 ++--- status/signals/peerstats.nim | 14 -------------- status/signals/signal_type.nim | 1 - status/types/fleet.nim | 10 +++------- 8 files changed, 9 insertions(+), 65 deletions(-) delete mode 100644 status/signals/peerstats.nim diff --git a/status/libstatus/core.nim b/status/libstatus/core.nim index d070a7f..e3c2533 100644 --- a/status/libstatus/core.nim +++ b/status/libstatus/core.nim @@ -56,24 +56,3 @@ proc signTypedData*(data: string, address: string, password: string): string = proc getBloomFilter*(): string = return $callPrivateRPC("bloomFilter".prefix, %* []).parseJSON()["result"].getStr - -proc adminPeers*(): seq[string] = - let response = callPrivateRPC("admin_peers", %* []).parseJSON()["result"] - for jsonPeer in response: - result.add(jsonPeer["enode"].getStr) - -proc wakuV2Peers*(): seq[string] = - let response = callPrivateRPC("peers".prefix, %* []).parseJSON()["result"] - for (id, proto) in response.pairs: - if proto.len != 0: - result.add(id) - -proc dialPeer*(address: string):bool = - let response = callPrivateRPC("dialPeer".prefix, %* [address]).parseJSON() - if response.hasKey("error"): - error "waku peer could not be dialed", response - return false - return true - -proc dropPeerByID*(peerID: string) = - echo callPrivateRPC("dropPeer".prefix, %* [peerID]) diff --git a/status/libstatus/mailservers.nim b/status/libstatus/mailservers.nim index a81ad55..fab51cb 100644 --- a/status/libstatus/mailservers.nim +++ b/status/libstatus/mailservers.nim @@ -1,12 +1,11 @@ import json, times import core, ../utils -proc ping*(mailservers: seq[string], timeoutMs: int, isWakuV2: bool = false): string = +proc ping*(mailservers: seq[string], timeoutMs: int): string = var addresses: seq[string] = @[] for mailserver in mailservers: addresses.add(mailserver) - var rpcMethod = if isWakuV2: "mailservers_multiAddressPing" else: "mailservers_ping" - result = callPrivateRPC(rpcMethod, %* [ + result = callPrivateRPC("mailservers_ping", %* [ { "addresses": addresses, "timeoutMs": timeoutMs } ]) diff --git a/status/network.nim b/status/network.nim index 76fa0a2..95376a5 100644 --- a/status/network.nim +++ b/status/network.nim @@ -1,11 +1,10 @@ import chronicles import ../eventemitter import libstatus/settings -import libstatus/core import json -import uuids, strutils +import uuids import json_serialization -import ./types/[setting, fleet] +import ./types/[setting] logScope: topics = "network-model" @@ -22,16 +21,6 @@ proc newNetworkModel*(events: EventEmitter): NetworkModel = result.peers = @[] result.connected = false -proc fetchPeers*(self: NetworkModel): seq[string] = - var fleetStr = getSetting[string](Setting.Fleet) - if fleetStr == "": fleetStr = "eth.prod" - let fleet = parseEnum[Fleet](fleetStr) - let isWakuV2 = if fleet == WakuV2Prod or fleet == WakuV2Test: true else: false - if isWakuV2: - return wakuV2Peers() - else: - return adminPeers() - proc peerSummaryChange*(self: NetworkModel, peers: seq[string]) = if peers.len == 0 and self.connected: self.connected = false diff --git a/status/settings.nim b/status/settings.nim index 7637dda..bc31841 100644 --- a/status/settings.nim +++ b/status/settings.nim @@ -58,9 +58,6 @@ proc getCurrentNetwork*(self: SettingsModel): NetworkType = proc setWakuVersion*(self: SettingsModel, newVersion: int) = libstatus_settings.setWakuVersion(newVersion) -proc getWakuVersion*(self: SettingsModel): int = - libstatus_settings.getWakuVersion() - proc setBloomFilterMode*(self: SettingsModel, bloomFilterMode: bool): StatusGoError = libstatus_settings.setBloomFilterMode(bloomFilterMode) diff --git a/status/signals.nim b/status/signals.nim index fa3e0ce..f29bdf1 100644 --- a/status/signals.nim +++ b/status/signals.nim @@ -1,7 +1,7 @@ import json, json_serialization, strutils -import signals/[base, community, discovery_summary, envelope, expired, mailserver, messages, signal_type, stats, wallet, whisper_filter, peerstats] +import signals/[base, community, discovery_summary, envelope, expired, mailserver, messages, signal_type, stats, wallet, whisper_filter] -export base, community, discovery_summary, envelope, expired, mailserver, messages, signal_type, stats, wallet, whisper_filter, peerstats +export base, community, discovery_summary, envelope, expired, mailserver, messages, signal_type, stats, wallet, whisper_filter proc decode*(jsonSignal: JsonNode): Signal = let signalString = jsonSignal{"type"}.getStr @@ -18,7 +18,6 @@ proc decode*(jsonSignal: JsonNode): Signal = of SignalType.WhisperFilterAdded: WhisperFilterSignal.fromEvent(jsonSignal) of SignalType.Wallet: WalletSignal.fromEvent(jsonSignal) of SignalType.NodeLogin: Json.decode($jsonSignal, NodeSignal) - of SignalType.PeerStats: PeerStatsSignal.fromEvent(jsonSignal) of SignalType.DiscoverySummary: DiscoverySummarySignal.fromEvent(jsonSignal) of SignalType.MailserverRequestCompleted: MailserverRequestCompletedSignal.fromEvent(jsonSignal) of SignalType.MailserverRequestExpired: MailserverRequestExpiredSignal.fromEvent(jsonSignal) diff --git a/status/signals/peerstats.nim b/status/signals/peerstats.nim deleted file mode 100644 index fc59743..0000000 --- a/status/signals/peerstats.nim +++ /dev/null @@ -1,14 +0,0 @@ -import json -import base -import signal_type - -type PeerStatsSignal* = ref object of Signal - peers*: seq[string] - -proc fromEvent*(T: type PeerStatsSignal, jsonSignal: JsonNode): PeerStatsSignal = - result = PeerStatsSignal() - result.signalType = SignalType.PeerStats - if jsonSignal["event"].kind != JNull: - for (node, protocols) in jsonSignal["event"]["peers"].pairs(): - if protocols.getElems.len != 0: - result.peers.add(node) diff --git a/status/signals/signal_type.nim b/status/signals/signal_type.nim index c48f5a1..0a48eac 100644 --- a/status/signals/signal_type.nim +++ b/status/signals/signal_type.nim @@ -19,7 +19,6 @@ type SignalType* {.pure.} = enum SubscriptionsError = "subscriptions.error" WhisperFilterAdded = "whisper.filter.added" CommunityFound = "community.found" - PeerStats = "wakuv2.peerstats" Stats = "stats" Unknown diff --git a/status/types/fleet.nim b/status/types/fleet.nim index 1478f48..bd5374b 100644 --- a/status/types/fleet.nim +++ b/status/types/fleet.nim @@ -44,13 +44,9 @@ proc getNodes*(self: FleetConfig, fleet: Fleet, nodeType: FleetNodes = FleetNode if not self.fleet[$fleet].hasKey($nodeType): return result = toSeq(self.fleet[$fleet][$nodeType].values) -proc getMailservers*(self: FleetConfig, fleet: Fleet, isWakuV2: bool): Table[string, string] = - # TODO: If using wakuV2, this assumes that Waku nodes in fleet.status.json are also store nodes. - # Maybe it make senses to add a "waku-store" section in case we want to have separate node types? - # Discuss with @iurimatias, @cammellos and Vac team - let fleetKey = if isWakuV2: $FleetNodes.Waku else: $FleetNodes.Mailservers - if not self.fleet[$fleet].hasKey(fleetKey) : +proc getMailservers*(self: FleetConfig, fleet: Fleet): Table[string, string] = + if not self.fleet[$fleet].hasKey($FleetNodes.Mailservers): result = initTable[string,string]() return - result = self.fleet[$fleet][fleetKey] + result = self.fleet[$fleet][$FleetNodes.Mailservers]