mirror of https://github.com/waku-org/nwaku.git
Adding error logs for failed libwaku operations (#3067)
This commit is contained in:
parent
8b0884c7b5
commit
d8e6a5cda7
|
@ -32,4 +32,5 @@ proc process*(
|
||||||
of RETRIEVE_MY_ENR:
|
of RETRIEVE_MY_ENR:
|
||||||
return ok($(%*waku.node.enr.toURI()))
|
return ok($(%*waku.node.enr.toURI()))
|
||||||
|
|
||||||
|
error "unsupported operation in DebugNodeRequest"
|
||||||
return err("unsupported operation in DebugNodeRequest")
|
return err("unsupported operation in DebugNodeRequest")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import std/[json, sequtils]
|
import std/[json, sequtils]
|
||||||
import chronos, results, libp2p/multiaddress
|
import chronos, chronicles, results, libp2p/multiaddress
|
||||||
import
|
import
|
||||||
../../../../waku/factory/waku,
|
../../../../waku/factory/waku,
|
||||||
../../../../waku/discovery/waku_dnsdisc,
|
../../../../waku/discovery/waku_dnsdisc,
|
||||||
|
@ -117,6 +117,7 @@ proc process*(
|
||||||
of START_DISCV5:
|
of START_DISCV5:
|
||||||
let res = await waku.wakuDiscv5.start()
|
let res = await waku.wakuDiscv5.start()
|
||||||
res.isOkOr:
|
res.isOkOr:
|
||||||
|
error "START_DISCV5 failed", error = error
|
||||||
return err($error)
|
return err($error)
|
||||||
|
|
||||||
return ok("discv5 started correctly")
|
return ok("discv5 started correctly")
|
||||||
|
@ -126,17 +127,21 @@ proc process*(
|
||||||
return ok("discv5 stopped correctly")
|
return ok("discv5 stopped correctly")
|
||||||
of GET_BOOTSTRAP_NODES:
|
of GET_BOOTSTRAP_NODES:
|
||||||
let nodes = retrieveBootstrapNodes($self[].enrTreeUrl, $self[].nameDnsServer).valueOr:
|
let nodes = retrieveBootstrapNodes($self[].enrTreeUrl, $self[].nameDnsServer).valueOr:
|
||||||
|
error "GET_BOOTSTRAP_NODES failed", error = error
|
||||||
return err($error)
|
return err($error)
|
||||||
|
|
||||||
return ok($(%*nodes))
|
return ok($(%*nodes))
|
||||||
of UPDATE_DISCV5_BOOTSTRAP_NODES:
|
of UPDATE_DISCV5_BOOTSTRAP_NODES:
|
||||||
updateDiscv5BootstrapNodes($self[].nodes, waku).isOkOr:
|
updateDiscv5BootstrapNodes($self[].nodes, waku).isOkOr:
|
||||||
|
error "UPDATE_DISCV5_BOOTSTRAP_NODES failed", error = error
|
||||||
return err($error)
|
return err($error)
|
||||||
|
|
||||||
return ok("discovery request processed correctly")
|
return ok("discovery request processed correctly")
|
||||||
of PEER_EXCHANGE:
|
of PEER_EXCHANGE:
|
||||||
let numValidPeers = (await performPeerExchangeRequestTo(self[].numPeers, waku)).valueOr:
|
let numValidPeers = (await performPeerExchangeRequestTo(self[].numPeers, waku)).valueOr:
|
||||||
|
error "PEER_EXCHANGE failed", error = error
|
||||||
return err("error calling performPeerExchangeRequestTo: " & $error)
|
return err("error calling performPeerExchangeRequestTo: " & $error)
|
||||||
return ok($numValidPeers)
|
return ok($numValidPeers)
|
||||||
|
|
||||||
|
error "discovery request not handled"
|
||||||
return err("discovery request not handled")
|
return err("discovery request not handled")
|
||||||
|
|
|
@ -74,14 +74,17 @@ proc process*(
|
||||||
case self.operation
|
case self.operation
|
||||||
of CREATE_NODE:
|
of CREATE_NODE:
|
||||||
waku[] = (await createWaku(self.configJson)).valueOr:
|
waku[] = (await createWaku(self.configJson)).valueOr:
|
||||||
|
error "CREATE_NODE failed", error = error
|
||||||
return err("error processing createWaku request: " & $error)
|
return err("error processing createWaku request: " & $error)
|
||||||
of START_NODE:
|
of START_NODE:
|
||||||
(await waku.startWaku()).isOkOr:
|
(await waku.startWaku()).isOkOr:
|
||||||
|
error "START_NODE failed", error = error
|
||||||
return err("problem starting waku: " & $error)
|
return err("problem starting waku: " & $error)
|
||||||
of STOP_NODE:
|
of STOP_NODE:
|
||||||
try:
|
try:
|
||||||
await waku[].stop()
|
await waku[].stop()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
error "STOP_NODE failed", error = getCurrentExceptionMsg()
|
||||||
return err("exception stopping node: " & getCurrentExceptionMsg())
|
return err("exception stopping node: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
return ok("")
|
return ok("")
|
||||||
|
|
|
@ -72,6 +72,7 @@ proc process*(
|
||||||
of CONNECT_TO:
|
of CONNECT_TO:
|
||||||
let ret = waku.node.connectTo($self[].peerMultiAddr, self[].dialTimeout)
|
let ret = waku.node.connectTo($self[].peerMultiAddr, self[].dialTimeout)
|
||||||
if ret.isErr():
|
if ret.isErr():
|
||||||
|
error "CONNECT_TO failed", error = ret.error
|
||||||
return err(ret.error)
|
return err(ret.error)
|
||||||
of GET_ALL_PEER_IDS:
|
of GET_ALL_PEER_IDS:
|
||||||
## returns a comma-separated string of peerIDs
|
## returns a comma-separated string of peerIDs
|
||||||
|
|
|
@ -87,17 +87,22 @@ proc process*(
|
||||||
let pubsubTopic = $self.pubsubTopic
|
let pubsubTopic = $self.pubsubTopic
|
||||||
|
|
||||||
if waku.node.wakuLightpushClient.isNil():
|
if waku.node.wakuLightpushClient.isNil():
|
||||||
return err("LightpushRequest waku.node.wakuLightpushClient is nil")
|
let errorMsg = "LightpushRequest waku.node.wakuLightpushClient is nil"
|
||||||
|
error "PUBLISH failed", error = errorMsg
|
||||||
|
return err(errorMsg)
|
||||||
|
|
||||||
let peerOpt = waku.node.peerManager.selectPeer(WakuLightPushCodec)
|
let peerOpt = waku.node.peerManager.selectPeer(WakuLightPushCodec)
|
||||||
if peerOpt.isNone():
|
if peerOpt.isNone():
|
||||||
return err("failed to lightpublish message, no suitable remote peers")
|
let errorMsg = "failed to lightpublish message, no suitable remote peers"
|
||||||
|
error "PUBLISH failed", error = errorMsg
|
||||||
|
return err(errorMsg)
|
||||||
|
|
||||||
(
|
(
|
||||||
await waku.node.wakuLightpushClient.publish(
|
await waku.node.wakuLightpushClient.publish(
|
||||||
pubsubTopic, msg, peer = peerOpt.get()
|
pubsubTopic, msg, peer = peerOpt.get()
|
||||||
)
|
)
|
||||||
).isOkOr:
|
).isOkOr:
|
||||||
|
error "PUBLISH failed", error = error
|
||||||
return err("LightpushRequest error publishing: " & $error)
|
return err("LightpushRequest error publishing: " & $error)
|
||||||
|
|
||||||
return ok("")
|
return ok("")
|
||||||
|
|
|
@ -104,16 +104,20 @@ proc process*(
|
||||||
|
|
||||||
let numPeers = await waku.node.wakuRelay.publish(pubsubTopic, msg)
|
let numPeers = await waku.node.wakuRelay.publish(pubsubTopic, msg)
|
||||||
if numPeers == 0:
|
if numPeers == 0:
|
||||||
return err("Message not sent because no peers found.")
|
let errorMsg = "Message not sent because no peers found."
|
||||||
|
error "PUBLISH failed", error = errorMsg
|
||||||
|
return err(errorMsg)
|
||||||
elif numPeers > 0:
|
elif numPeers > 0:
|
||||||
let msgHash = computeMessageHash(pubSubTopic, msg).to0xHex
|
let msgHash = computeMessageHash(pubSubTopic, msg).to0xHex
|
||||||
return ok(msgHash)
|
return ok(msgHash)
|
||||||
of LIST_CONNECTED_PEERS:
|
of LIST_CONNECTED_PEERS:
|
||||||
let numConnPeers = waku.node.wakuRelay.getNumConnectedPeers($self.pubsubTopic).valueOr:
|
let numConnPeers = waku.node.wakuRelay.getNumConnectedPeers($self.pubsubTopic).valueOr:
|
||||||
|
error "LIST_CONNECTED_PEERS failed", error = error
|
||||||
return err($error)
|
return err($error)
|
||||||
return ok($numConnPeers)
|
return ok($numConnPeers)
|
||||||
of LIST_MESH_PEERS:
|
of LIST_MESH_PEERS:
|
||||||
let numPeersInMesh = waku.node.wakuRelay.getNumPeersInMesh($self.pubsubTopic).valueOr:
|
let numPeersInMesh = waku.node.wakuRelay.getNumPeersInMesh($self.pubsubTopic).valueOr:
|
||||||
|
error "LIST_MESH_PEERS failed", error = error
|
||||||
return err($error)
|
return err($error)
|
||||||
return ok($numPeersInMesh)
|
return ok($numPeersInMesh)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import std/[json, sugar, options]
|
import std/[json, sugar, options]
|
||||||
import chronos, results
|
import chronos, chronicles, results
|
||||||
import
|
import
|
||||||
../../../../../waku/factory/waku,
|
../../../../../waku/factory/waku,
|
||||||
../../../../alloc,
|
../../../../alloc,
|
||||||
|
@ -143,4 +143,5 @@ proc process*(
|
||||||
of REMOTE_QUERY:
|
of REMOTE_QUERY:
|
||||||
return await cast[ptr JsonStoreQueryRequest](self[].storeReq).process(waku)
|
return await cast[ptr JsonStoreQueryRequest](self[].storeReq).process(waku)
|
||||||
|
|
||||||
|
error "store request not handled at all"
|
||||||
return err("store request not handled at all")
|
return err("store request not handled at all")
|
||||||
|
|
Loading…
Reference in New Issue