From 26c17afb5dbc3e5c09c7a07840136aa26501a729 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Sun, 11 Apr 2021 10:45:14 -0400 Subject: [PATCH] Using go-waku --- src/status/libstatus/accounts.nim | 22 +++++++++++++++------ src/status/libstatus/accounts/constants.nim | 11 +++++------ src/status/libstatus/mailservers.nim | 21 ++++++++++++++++++++ 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/src/status/libstatus/accounts.nim b/src/status/libstatus/accounts.nim index 40e03c8249..b5577dbfb1 100644 --- a/src/status/libstatus/accounts.nim +++ b/src/status/libstatus/accounts.nim @@ -19,16 +19,26 @@ proc getNodeConfig*(fleetConfig: FleetConfig, installationId: string, networkCon result = constants.NODE_CONFIG.copy() result["ClusterConfig"]["Fleet"] = newJString($fleet) - result["ClusterConfig"]["BootNodes"] = %* fleetConfig.getNodes(fleet, FleetNodes.Bootnodes) - result["ClusterConfig"]["TrustedMailServers"] = %* fleetConfig.getNodes(fleet, FleetNodes.Mailservers) - result["ClusterConfig"]["StaticNodes"] = %* fleetConfig.getNodes(fleet, FleetNodes.Whisper) - result["ClusterConfig"]["RendezvousNodes"] = %* fleetConfig.getNodes(fleet, FleetNodes.Rendezvous) - result["Rendezvous"] = newJBool(fleetConfig.getNodes(fleet, FleetNodes.Rendezvous).len > 0) + result["ClusterConfig"]["BootNodes"] = %* (@[]) + result["ClusterConfig"]["TrustedMailServers"] = %* (@[]) + result["ClusterConfig"]["StaticNodes"] = %* (@[]) + result["ClusterConfig"]["RendezvousNodes"] = %* (@[]) + result["ClusterConfig"]["WakuNodes"] = %*(@[ + "/ip4/134.209.113.86/tcp/9000/p2p/16Uiu2HAmVVi6Q4j7MAKVibquW8aA27UNrA4Q8Wkz9EetGViu8ZF1", + ]) + result["ClusterConfig"]["WakuStoreNodes"] = %*(@[ + "/ip4/134.209.113.86/tcp/9000/p2p/16Uiu2HAmVVi6Q4j7MAKVibquW8aA27UNrA4Q8Wkz9EetGViu8ZF1" + ]) + + result["Rendezvous"] = newJBool(false) result["NetworkId"] = networkConfig["config"]["NetworkId"] result["DataDir"] = newDataDir.newJString() result["UpstreamConfig"]["Enabled"] = networkConfig["config"]["UpstreamConfig"]["Enabled"] result["UpstreamConfig"]["URL"] = upstreamUrl result["ShhextConfig"]["InstallationID"] = newJString(installationId) + + + echo $result # TODO: commented since it's not necessary (we do the connections thru C bindings). Enable it thru an option once status-nodes are able to be configured in desktop # result["ListenAddr"] = if existsEnv("STATUS_PORT"): newJString("0.0.0.0:" & $getEnv("STATUS_PORT")) else: newJString("0.0.0.0:30305") result["WakuConfig"]["BloomFilterMode"] = newJBool(bloomFilterMode) @@ -167,7 +177,7 @@ proc getAccountSettings*(account: GeneratedAccount, defaultNetworks: JsonNode, i "wallet-root-address": account.derived.walletRoot.address, "preview-privacy?": true, "signing-phrase": generateSigningPhrase(3), - "log-level": "INFO", + "log-level": "DEBUG", "latest-derived-path": 0, "networks/networks": defaultNetworks, "currency": "usd", diff --git a/src/status/libstatus/accounts/constants.nim b/src/status/libstatus/accounts/constants.nim index 3611c57b59..d7f4970e58 100644 --- a/src/status/libstatus/accounts/constants.nim +++ b/src/status/libstatus/accounts/constants.nim @@ -124,13 +124,13 @@ var NODE_CONFIG* = %* { #"ListenAddr": ":30304", "LogEnabled": true, "LogFile": "geth.log", - "LogLevel": "INFO", + "LogLevel": "DEBUG", "MailserversConfig": { "Enabled": true }, "Name": "StatusDesktop", "NetworkId": 1, - "NoDiscovery": false, + "NoDiscovery": true, "PermissionsConfig": { "Enabled": true }, @@ -160,11 +160,10 @@ var NODE_CONFIG* = %* { "Enabled": true, "URL": "https://mainnet.infura.io/v3/" & INFURA_TOKEN_RESOLVED }, - "WakuConfig": { - "BloomFilterMode": nil, + "WakuV2Config": { "Enabled": true, - "LightClient": true, - "MinimumPoW": 0.001 + "Host": "0.0.0.0", + "Port": 0 }, "WalletConfig": { "Enabled": true diff --git a/src/status/libstatus/mailservers.nim b/src/status/libstatus/mailservers.nim index f6a1034c78..e9eb5bef92 100644 --- a/src/status/libstatus/mailservers.nim +++ b/src/status/libstatus/mailservers.nim @@ -18,6 +18,27 @@ proc delete*(peer: string) = proc requestAllHistoricMessages*(): string = return callPrivateRPC("requestAllHistoricMessages".prefix, %*[]) +proc requestStoreMessages*(topics: seq[string], symKeyID: string, peer: string, numberOfMessages: int, fromTimestamp: int64 = 0, toTimestamp: int64 = 0, force: bool = false) = + var toValue = times.toUnix(times.getTime()) + var fromValue = toValue - 86400 + if fromTimestamp != 0: + fromValue = fromTimestamp + if toTimestamp != 0: + toValue = toTimestamp + + echo callPrivateRPC("requestMessages".prefix, %* [ + { + "topics": topics, + "mailServerPeer": "16Uiu2HAmVVi6Q4j7MAKVibquW8aA27UNrA4Q8Wkz9EetGViu8ZF1", + "timeout": 30, + "limit": numberOfMessages, + "cursor": nil, + "from": fromValue, + "to": toValue, + "force": force + } + ]) + proc syncChatFromSyncedFrom*(chatId: string): string = return callPrivateRPC("syncChatFromSyncedFrom".prefix, %*[chatId])