mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-03 22:43:09 +00:00
use 4KB msgSize in mix
This commit is contained in:
parent
95f83d4b78
commit
bbd3133933
@ -108,21 +108,23 @@ proc setupAndPublish(rng: ref HmacDrbgContext, conf: LPMixConf) {.async.} =
|
||||
RemotePeerInfo.init(pxPeerId, @[MultiAddress.init(pxPeerAddr).get()])
|
||||
node.peerManager.addServicePeer(pxPeerInfo1, WakuPeerExchangeCodec)
|
||||
|
||||
let keyPairResult = generateKeyPair()
|
||||
if keyPairResult.isErr:
|
||||
return
|
||||
let (mixPrivKey, mixPubKey) = keyPairResult.get()
|
||||
if not conf.withoutMix:
|
||||
let keyPairResult = generateKeyPair()
|
||||
if keyPairResult.isErr:
|
||||
return
|
||||
let (mixPrivKey, mixPubKey) = keyPairResult.get()
|
||||
(await node.mountMix(mixPrivKey)).isOkOr:
|
||||
error "failed to mount waku mix protocol: ", error = $error
|
||||
return
|
||||
|
||||
(await node.mountMix(mixPrivKey)).isOkOr:
|
||||
error "failed to mount waku mix protocol: ", error = $error
|
||||
return
|
||||
let dPeerId = PeerId.init(destPeerId).valueOr:
|
||||
error "Failed to initialize PeerId", err = error
|
||||
return
|
||||
|
||||
let conn = MixEntryConnection.newConn(
|
||||
destPeerAddr, dPeerId, ProtocolType.fromString(WakuLightPushCodec), node.mix
|
||||
)
|
||||
var conn: Connection
|
||||
if not conf.withoutMix:
|
||||
conn = MixEntryConnection.newConn(
|
||||
destPeerAddr, dPeerId, ProtocolType.fromString(WakuLightPushCodec), node.mix
|
||||
)
|
||||
|
||||
await node.start()
|
||||
node.peerManager.start()
|
||||
@ -134,17 +136,33 @@ proc setupAndPublish(rng: ref HmacDrbgContext, conf: LPMixConf) {.async.} =
|
||||
(await node.fetchPeerExchangePeers()).isOkOr:
|
||||
warn "Cannot fetch peers from peer exchange", cause = error
|
||||
|
||||
while node.getMixNodePoolSize() < conf.minMixPoolSize:
|
||||
info "waiting for mix nodes to be discovered",
|
||||
if not conf.withoutMix:
|
||||
while node.getMixNodePoolSize() < conf.minMixPoolSize:
|
||||
info "waiting for mix nodes to be discovered",
|
||||
currentpoolSize = node.getMixNodePoolSize()
|
||||
await sleepAsync(1000)
|
||||
notice "publisher service started with mix node pool size ",
|
||||
currentpoolSize = node.getMixNodePoolSize()
|
||||
await sleepAsync(1000)
|
||||
|
||||
notice "publisher service started with mix node pool size ",
|
||||
currentpoolSize = node.getMixNodePoolSize()
|
||||
var i = 0
|
||||
while i < conf.numMsgs:
|
||||
if conf.withoutMix:
|
||||
let connOpt = await node.peerManager.dialPeer(dPeerId, WakuLightPushCodec)
|
||||
if connOpt.isNone():
|
||||
error "failed to dial peer"
|
||||
return
|
||||
conn = connOpt.get()
|
||||
i = i + 1
|
||||
let text = "hi there i'm a publisher using mix, this is msg number " & $i
|
||||
let text =
|
||||
"""Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam venenatis magna ut tortor faucibus, in vestibulum nibh commodo. Aenean eget vestibulum augue. Nullam suscipit urna non nunc efficitur, at iaculis nisl consequat. Mauris quis ultrices elit. Suspendisse lobortis odio vitae laoreet facilisis. Cras ornare sem felis, at vulputate magna aliquam ac. Duis quis est ultricies, euismod nulla ac, interdum dui. Maecenas sit amet est vitae enim commodo gravida. Proin vitae elit nulla. Donec tempor dolor lectus, in faucibus velit elementum quis. Donec non mauris eu nibh faucibus cursus ut egestas dolor. Aliquam venenatis ligula id velit pulvinar malesuada. Vestibulum scelerisque, justo non porta gravida, nulla justo tempor purus, at sollicitudin erat erat vel libero.
|
||||
Fusce nec eros eu metus tristique aliquet. Sed ut magna sagittis, vulputate diam sit amet, aliquam magna. Aenean sollicitudin velit lacus, eu ultrices magna semper at. Integer vitae felis ligula. In a eros nec risus condimentum tincidunt fermentum sit amet ex. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nullam vitae justo maximus, fringilla tellus nec, rutrum purus. Etiam efficitur nisi dapibus euismod vestibulum. Phasellus at felis elementum, tristique nulla ac, consectetur neque.
|
||||
Maecenas hendrerit nibh eget velit rutrum, in ornare mauris molestie. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Praesent dignissim efficitur eros, sit amet rutrum justo mattis a. Fusce mollis neque at erat placerat bibendum. Ut fringilla fringilla orci, ut fringilla metus fermentum vel. In hac habitasse platea dictumst. Donec hendrerit porttitor odio. Suspendisse ornare sollicitudin mauris, sodales pulvinar velit finibus vel. Fusce id pulvinar neque. Suspendisse eget tincidunt sapien, ac accumsan turpis.
|
||||
Curabitur cursus tincidunt leo at aliquet. Nunc dapibus quam id venenatis varius. Aenean eget augue vel velit dapibus aliquam. Nulla facilisi. Curabitur cursus, turpis vel congue volutpat, tellus eros cursus lacus, eu fringilla turpis orci non ipsum. In hac habitasse platea dictumst. Nulla aliquam nisl a nunc placerat, eget dignissim felis pulvinar. Fusce sed porta mauris. Donec sodales arcu in nisl sodales, quis posuere massa ultricies. Nam feugiat massa eget felis ultricies finibus. Nunc magna nulla, interdum a elit vel, egestas efficitur urna. Ut posuere tincidunt odio in maximus. Sed at dignissim est.
|
||||
Morbi accumsan elementum ligula ut fringilla. Praesent in ex metus. Phasellus urna est, tempus sit amet elementum vitae, sollicitudin vel ipsum. Fusce hendrerit eleifend dignissim. Maecenas tempor dapibus dui quis laoreet. Cras tincidunt sed ipsum sed pellentesque. Proin ut tellus nec ipsum varius interdum. Curabitur id velit ligula. Etiam sapien nulla, cursus sodales orci eu, porta lobortis nunc. Nunc at dapibus velit. Nulla et nunc vehicula, condimentum erat quis, elementum dolor. Quisque eu metus fermentum, vestibulum tellus at, sollicitudin odio. Ut vel neque justo.
|
||||
Praesent porta porta velit, vel porttitor sem. Donec sagittis at nulla venenatis iaculis. Nullam vel eleifend felis. Nullam a pellentesque lectus. Aliquam tincidunt semper dui sed bibendum. Donec hendrerit, urna et cursus dictum, neque neque convallis magna, id condimentum sem urna quis massa. Fusce non quam vulputate, fermentum mauris at, malesuada ipsum. Mauris id pellentesque libero. Donec vel erat ullamcorper, dapibus quam id, imperdiet urna. Praesent sed ligula ut est pellentesque pharetra quis et diam. Ut placerat lorem eget mi fermentum aliquet.
|
||||
This is message #""" &
|
||||
$i &
|
||||
""" sent from a publisher using mix.Testing larger message transmission over the Waku network is important for understanding performance characteristics under various conditions. End of transmission."""
|
||||
let message = WakuMessage(
|
||||
payload: toBytes(text), # content of the message
|
||||
contentTopic: LightpushContentTopic, # content topic to publish to
|
||||
@ -153,7 +171,7 @@ proc setupAndPublish(rng: ref HmacDrbgContext, conf: LPMixConf) {.async.} =
|
||||
) # current timestamp
|
||||
|
||||
let res = await node.wakuLightpushClient.publishWithConn(
|
||||
LightpushPubsubTopic, message, conn
|
||||
LightpushPubsubTopic, message, conn, dPeerId
|
||||
)
|
||||
|
||||
if res.isOk:
|
||||
@ -167,6 +185,8 @@ proc setupAndPublish(rng: ref HmacDrbgContext, conf: LPMixConf) {.async.} =
|
||||
error "failed to publish message", error = res.error
|
||||
lp_mix_failed.inc(labelValues = ["publish_error"])
|
||||
|
||||
if conf.withoutMix:
|
||||
await conn.close()
|
||||
await sleepAsync(conf.msgInterval)
|
||||
info "###########Sent all messages via mix"
|
||||
quit(0)
|
||||
|
||||
@ -22,3 +22,7 @@ type LPMixConf* = object
|
||||
defaultValue: 3,
|
||||
name: "min-mix-pool-size"
|
||||
.}: int
|
||||
|
||||
withoutMix* {.
|
||||
desc: "Do not use mix for publishing.", defaultValue: false, name: "without-mix"
|
||||
.}: bool
|
||||
|
||||
2
vendor/mix
vendored
2
vendor/mix
vendored
@ -1 +1 @@
|
||||
Subproject commit 078945a54d279c70bb4d96a00cd276b2060011c5
|
||||
Subproject commit be0ed0de37d71945075fd6c16537510e8fbc8a65
|
||||
@ -93,12 +93,16 @@ proc publishToAny*(
|
||||
## This proc is similar to the publish one but in this case
|
||||
## we don't specify a particular peer and instead we get it from peer manager
|
||||
|
||||
info "publishToAny", msg_hash = computeMessageHash(pubsubTopic, message).to0xHex
|
||||
|
||||
let peer = wl.peerManager.selectPeer(WakuLightPushCodec).valueOr:
|
||||
# TODO: check if it is matches the situation - shall we distinguish client side missing peers from server side?
|
||||
return lighpushErrorResult(NO_PEERS_TO_RELAY, "no suitable remote peers")
|
||||
|
||||
info "publishToAny",
|
||||
my_peer_id = wl.peerManager.switch.peerInfo.peerId,
|
||||
peer_id = peer.peerId,
|
||||
msg_hash = computeMessageHash(pubsubTopic, message).to0xHex,
|
||||
sentTime = getNowInNanosecondTime()
|
||||
|
||||
let pushRequest = LightpushRequest(
|
||||
requestId: generateRequestId(wl.rng),
|
||||
pubSubTopic: some(pubSubTopic),
|
||||
@ -116,13 +120,14 @@ proc publishWithConn*(
|
||||
pubSubTopic: PubsubTopic,
|
||||
message: WakuMessage,
|
||||
conn: Connection,
|
||||
destPeer: PeerId,
|
||||
): Future[WakuLightPushResult] {.async, gcsafe.} =
|
||||
## This proc is similar to the publish one but in this case
|
||||
## we use existing connection to publish.
|
||||
|
||||
info "publishWithConn",
|
||||
my_peer_id = wl.peerManager.switch.peerInfo.peerId,
|
||||
peer_id = conn.peerId,
|
||||
peer_id = destPeer,
|
||||
msg_hash = computeMessageHash(pubsubTopic, message).to0xHex,
|
||||
sentTime = getNowInNanosecondTime()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user