mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-09 01:13:08 +00:00
enable mix in enr and add mix protocol config
This commit is contained in:
parent
8ca9726081
commit
6d24bb1fec
@ -665,8 +665,15 @@ with the drawback of consuming some more bandwidth.""",
|
||||
.}: bool
|
||||
|
||||
#Mix config
|
||||
mixkey* {.desc: "ED25519 private key as 64 char hex string.", name: "mixkey".}:
|
||||
Option[string]
|
||||
mix* {.
|
||||
desc: "Enable mix protocol: true|false",
|
||||
defaultValue: false,
|
||||
name: "mix"
|
||||
.}: bool
|
||||
mixkey* {.
|
||||
desc: "ED25519 private key as 64 char hex string.",
|
||||
name: "mixkey"
|
||||
.}: Option[string]
|
||||
#TODO: Temp config for simulations.Ideally need to get this info from bootstrap ENRs
|
||||
#[ mixBootstrapNodes* {.
|
||||
desc:
|
||||
|
||||
@ -122,6 +122,7 @@ proc networkConfiguration*(conf: WakuNodeConf, clientId: string): NetConfigResul
|
||||
store = conf.store,
|
||||
relay = conf.relay,
|
||||
sync = conf.storeSync,
|
||||
mix = conf.mix,
|
||||
)
|
||||
|
||||
# Resolve and use DNS domain IP
|
||||
|
||||
@ -427,16 +427,17 @@ proc setupProtocols(
|
||||
err("failed to set node waku peer-exchange peer: " & peerExchangeNode.error)
|
||||
|
||||
#mount mix
|
||||
let mixPrivKey:string =
|
||||
if conf.mixkey.isSome():
|
||||
conf.mixkey.get()
|
||||
else:
|
||||
error "missing mix key"
|
||||
return err("missing mix key")
|
||||
(
|
||||
await node.mountMix(mixPrivKey)
|
||||
).isOkOr:
|
||||
return err("failed to mount waku mix protocol: " & $error)
|
||||
if conf.mix:
|
||||
let mixPrivKey:string =
|
||||
if conf.mixkey.isSome():
|
||||
conf.mixkey.get()
|
||||
else:
|
||||
error "missing mix key"
|
||||
return err("missing mix key")
|
||||
(
|
||||
await node.mountMix(mixPrivKey)
|
||||
).isOkOr:
|
||||
return err("failed to mount waku mix protocol: " & $error)
|
||||
return ok()
|
||||
|
||||
## Start node
|
||||
|
||||
@ -20,6 +20,7 @@ type
|
||||
Filter = 2
|
||||
Lightpush = 3
|
||||
Sync = 4
|
||||
Mix = 5
|
||||
|
||||
const capabilityToCodec = {
|
||||
Capabilities.Relay: WakuRelayCodec,
|
||||
@ -30,7 +31,7 @@ const capabilityToCodec = {
|
||||
}.toTable
|
||||
|
||||
func init*(
|
||||
T: type CapabilitiesBitfield, lightpush, filter, store, relay, sync: bool = false
|
||||
T: type CapabilitiesBitfield, lightpush, filter, store, relay, sync, mix: bool = false
|
||||
): T =
|
||||
## Creates an waku2 ENR flag bit field according to RFC 31 (https://rfc.vac.dev/spec/31/)
|
||||
var bitfield: uint8
|
||||
@ -44,6 +45,8 @@ func init*(
|
||||
bitfield.setBit(3)
|
||||
if sync:
|
||||
bitfield.setBit(4)
|
||||
if mix:
|
||||
bitfield.setBit(5)
|
||||
CapabilitiesBitfield(bitfield)
|
||||
|
||||
func init*(T: type CapabilitiesBitfield, caps: varargs[Capabilities]): T =
|
||||
|
||||
@ -127,4 +127,6 @@ proc publishWithConn*(
|
||||
for obs in wl.publishObservers:
|
||||
obs.onMessagePublished(pubSubTopic, message)
|
||||
|
||||
return lightpushSuccessResult(1)
|
||||
#TODO: Implement response handling.
|
||||
|
||||
return lightpushSuccessResult(1)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user