chore: adding more logs for identifying mailserver interactions (#38)
This commit is contained in:
parent
f42c249395
commit
3655396b57
|
@ -33,13 +33,18 @@ proc startMessenger*() =
|
|||
discard callPrivateRPC("startMessenger".prefix)
|
||||
|
||||
proc addPeer*(peer: string) =
|
||||
discard callPrivateRPC("admin_addPeer", %* [peer])
|
||||
let response = callPrivateRPC("admin_addPeer", %* [peer])
|
||||
info "addPeer", topics="mailserver-interaction", rpc_method="admin_addPeer", peer, response
|
||||
|
||||
proc removePeer*(peer: string) =
|
||||
discard callPrivateRPC("admin_removePeer", %* [peer])
|
||||
let response = callPrivateRPC("admin_removePeer", %* [peer])
|
||||
info "removePeer", topics="mailserver-interaction", rpc_method="admin_removePeer", peer, response
|
||||
|
||||
|
||||
proc markTrustedPeer*(peer: string) =
|
||||
discard callPrivateRPC("markTrustedPeer".prefix(false), %* [peer])
|
||||
let response = callPrivateRPC("markTrustedPeer".prefix(false), %* [peer])
|
||||
info "markTrustedPeer", topics="mailserver-interaction", rpc_method="waku_markTrustedPeer", peer, response
|
||||
|
||||
|
||||
proc getBlockByNumber*(blockNumber: string): string =
|
||||
result = callPrivateRPC("eth_getBlockByNumber", %* [blockNumber, false])
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import json, times
|
||||
import json, times, chronicles
|
||||
import core, ../utils
|
||||
|
||||
proc ping*(mailservers: seq[string], timeoutMs: int): string =
|
||||
|
@ -8,18 +8,23 @@ proc ping*(mailservers: seq[string], timeoutMs: int): string =
|
|||
result = callPrivateRPC("mailservers_ping", %* [
|
||||
{ "addresses": addresses, "timeoutMs": timeoutMs }
|
||||
])
|
||||
info "ping", topics="mailserver-interaction", rpc_method="mailservers_ping", addresses, timeoutMs, result
|
||||
|
||||
proc update*(peer: string) =
|
||||
discard callPrivateRPC("updateMailservers".prefix, %* [[peer]])
|
||||
let response = callPrivateRPC("updateMailservers".prefix, %* [[peer]])
|
||||
info "update", topics="mailserver-interaction", rpc_method="wakuext_updateMailservers", peer, response
|
||||
|
||||
proc setMailserver*(peer: string): string =
|
||||
return callPrivateRPC("setMailserver".prefix, %* [peer])
|
||||
result = callPrivateRPC("setMailserver".prefix, %* [peer])
|
||||
info "setMailserver", topics="mailserver-interaction", rpc_method="wakuext_setMailserver", peer, result
|
||||
|
||||
proc delete*(peer: string) =
|
||||
discard callPrivateRPC("mailservers_deleteMailserver", %* [peer])
|
||||
let response = callPrivateRPC("mailservers_deleteMailserver", %* [peer])
|
||||
info "delete", topics="mailserver-interaction", rpc_method="mailservers_deleteMailserver", peer, response
|
||||
|
||||
proc requestAllHistoricMessages*(): string =
|
||||
return callPrivateRPC("requestAllHistoricMessages".prefix, %*[])
|
||||
result = callPrivateRPC("requestAllHistoricMessages".prefix, %*[])
|
||||
info "requestAllHistoricMessages", topics="mailserver-interaction", rpc_method="mailservers_requestAllHistoricMessages", result
|
||||
|
||||
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())
|
||||
|
@ -43,7 +48,9 @@ proc requestStoreMessages*(topics: seq[string], symKeyID: string, peer: string,
|
|||
])
|
||||
|
||||
proc syncChatFromSyncedFrom*(chatId: string): string =
|
||||
return callPrivateRPC("syncChatFromSyncedFrom".prefix, %*[chatId])
|
||||
result = callPrivateRPC("syncChatFromSyncedFrom".prefix, %*[chatId])
|
||||
info "syncChatFromSyncedFrom", topics="mailserver-interaction", rpc_method="wakuext_syncChatFromSyncedFrom", chatId, result
|
||||
|
||||
proc fillGaps*(chatId: string, messageIds: seq[string]): string =
|
||||
return callPrivateRPC("fillGaps".prefix, %*[chatId, messageIds])
|
||||
result = callPrivateRPC("fillGaps".prefix, %*[chatId, messageIds])
|
||||
info "fillGaps", topics="mailserver-interaction", rpc_method="wakuext_fillGaps", chatId, messageIds, result
|
||||
|
|
|
@ -97,29 +97,38 @@ proc getFleet*(): Fleet =
|
|||
proc getPinnedMailserver*(): string =
|
||||
let pinnedMailservers = getSetting[JsonNode](Setting.PinnedMailservers, %*{})
|
||||
let fleet = getSetting[string](Setting.Fleet, $Fleet.PROD)
|
||||
return pinnedMailservers{fleet}.getStr()
|
||||
result = pinnedMailservers{fleet}.getStr()
|
||||
info "getPinnedMailserver", topics="mailserver-interaction", fleet, result
|
||||
|
||||
|
||||
proc pinMailserver*(enode: string = "") =
|
||||
let pinnedMailservers = getSetting[JsonNode](Setting.PinnedMailservers, %*{})
|
||||
let fleet = getSetting[string](Setting.Fleet, $Fleet.PROD)
|
||||
|
||||
pinnedMailservers[fleet] = newJString(enode)
|
||||
discard saveSetting(Setting.PinnedMailservers, pinnedMailservers)
|
||||
let response = saveSetting(Setting.PinnedMailservers, pinnedMailservers)
|
||||
info "pinMailserver", topics="mailserver-interaction", enode, response
|
||||
|
||||
|
||||
proc saveMailserver*(name, enode: string) =
|
||||
let fleet = getSetting[string](Setting.Fleet, $Fleet.PROD)
|
||||
let result = callPrivateRPC("mailservers_addMailserver", %* [
|
||||
let id = $genUUID()
|
||||
let response = callPrivateRPC("mailservers_addMailserver", %* [
|
||||
%*{
|
||||
"id": $genUUID(),
|
||||
"id": id,
|
||||
"name": name,
|
||||
"address": enode,
|
||||
"fleet": $fleet
|
||||
}
|
||||
]).parseJSON()["result"]
|
||||
])
|
||||
let result = response.parseJSON()["result"]
|
||||
info "saveMailserver", topics="mailserver-interaction", rpc_method="mailservers_addMailserver", id, name, enode, fleet, response
|
||||
|
||||
|
||||
proc getMailservers*():JsonNode =
|
||||
let fleet = getSetting[string](Setting.Fleet, $Fleet.PROD)
|
||||
result = callPrivateRPC("mailservers_getMailservers").parseJSON()["result"]
|
||||
let response = callPrivateRPC("mailservers_getMailservers")
|
||||
result = response.parseJSON()["result"]
|
||||
info "getMailservers", topics="mailserver-interaction", rpc_method="mailservers_getMailservers", response
|
||||
|
||||
proc getNodeConfig*():JsonNode =
|
||||
result = status_go.getNodeConfig().parseJSON()
|
||||
|
|
Loading…
Reference in New Issue