Skip to content

Commit

Permalink
Merge branch 'master' into chore-merge-release-v0.33-to-master
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmer authored Oct 2, 2024
2 parents 7bc42b5 + 643ab20 commit ca44878
Show file tree
Hide file tree
Showing 13 changed files with 169 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ proc process*(
of RETRIEVE_MY_ENR:
return ok($(%*waku.node.enr.toURI()))

error "unsupported operation in DebugNodeRequest"
return err("unsupported operation in DebugNodeRequest")
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import std/[json, sequtils]
import chronos, results, libp2p/multiaddress
import chronos, chronicles, results, libp2p/multiaddress
import
../../../../waku/factory/waku,
../../../../waku/discovery/waku_dnsdisc,
Expand Down Expand Up @@ -117,6 +117,7 @@ proc process*(
of START_DISCV5:
let res = await waku.wakuDiscv5.start()
res.isOkOr:
error "START_DISCV5 failed", error = error
return err($error)

return ok("discv5 started correctly")
Expand All @@ -126,17 +127,21 @@ proc process*(
return ok("discv5 stopped correctly")
of GET_BOOTSTRAP_NODES:
let nodes = retrieveBootstrapNodes($self[].enrTreeUrl, $self[].nameDnsServer).valueOr:
error "GET_BOOTSTRAP_NODES failed", error = error
return err($error)

return ok($(%*nodes))
of UPDATE_DISCV5_BOOTSTRAP_NODES:
updateDiscv5BootstrapNodes($self[].nodes, waku).isOkOr:
error "UPDATE_DISCV5_BOOTSTRAP_NODES failed", error = error
return err($error)

return ok("discovery request processed correctly")
of PEER_EXCHANGE:
let numValidPeers = (await performPeerExchangeRequestTo(self[].numPeers, waku)).valueOr:
error "PEER_EXCHANGE failed", error = error
return err("error calling performPeerExchangeRequestTo: " & $error)
return ok($numValidPeers)

error "discovery request not handled"
return err("discovery request not handled")
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,17 @@ proc process*(
case self.operation
of CREATE_NODE:
waku[] = (await createWaku(self.configJson)).valueOr:
error "CREATE_NODE failed", error = error
return err("error processing createWaku request: " & $error)
of START_NODE:
(await waku.startWaku()).isOkOr:
error "START_NODE failed", error = error
return err("problem starting waku: " & $error)
of STOP_NODE:
try:
await waku[].stop()
except Exception:
error "STOP_NODE failed", error = getCurrentExceptionMsg()
return err("exception stopping node: " & getCurrentExceptionMsg())

return ok("")
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ proc process*(
of CONNECT_TO:
let ret = waku.node.connectTo($self[].peerMultiAddr, self[].dialTimeout)
if ret.isErr():
error "CONNECT_TO failed", error = ret.error
return err(ret.error)
of GET_ALL_PEER_IDS:
## returns a comma-separated string of peerIDs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,22 @@ proc process*(
let pubsubTopic = $self.pubsubTopic

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)
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(
pubsubTopic, msg, peer = peerOpt.get()
)
).isOkOr:
error "PUBLISH failed", error = error
return err("LightpushRequest error publishing: " & $error)

return ok("")
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,20 @@ proc process*(

let numPeers = await waku.node.wakuRelay.publish(pubsubTopic, msg)
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:
let msgHash = computeMessageHash(pubSubTopic, msg).to0xHex
return ok(msgHash)
of LIST_CONNECTED_PEERS:
let numConnPeers = waku.node.wakuRelay.getNumConnectedPeers($self.pubsubTopic).valueOr:
error "LIST_CONNECTED_PEERS failed", error = error
return err($error)
return ok($numConnPeers)
of LIST_MESH_PEERS:
let numPeersInMesh = waku.node.wakuRelay.getNumPeersInMesh($self.pubsubTopic).valueOr:
error "LIST_MESH_PEERS failed", error = error
return err($error)
return ok($numPeersInMesh)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import std/[json, sugar, options]
import chronos, results
import chronos, chronicles, results
import
../../../../../waku/factory/waku,
../../../../alloc,
Expand Down Expand Up @@ -143,4 +143,5 @@ proc process*(
of REMOTE_QUERY:
return await cast[ptr JsonStoreQueryRequest](self[].storeReq).process(waku)

error "store request not handled at all"
return err("store request not handled at all")
9 changes: 4 additions & 5 deletions tests/waku_archive/test_driver_postgres.nim
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,15 @@ suite "Postgres driver":
var futures = newSeq[Future[ArchiveDriverResult[void]]](0)

let beforeSleep = now()
for _ in 1 .. 100:

for _ in 1 .. 25:
futures.add(driver.sleep(1))

await allFutures(futures)

let diff = now() - beforeSleep
# Actually, the diff randomly goes between 1 and 2 seconds.
# although in theory it should spend 1s because we establish 100
# connections and we spawn 100 tasks that spend ~1s each.
assert diff < 20_000_000_000

assert diff < 2_000_000_000 ## nanoseconds

asyncTest "Insert a message":
const contentTopic = "test-content-topic"
Expand Down
2 changes: 1 addition & 1 deletion vendor/negentropy
Submodule negentropy updated 1 files
+1 −1 cpp/Makefile
Loading

0 comments on commit ca44878

Please sign in to comment.