Resolves naming conflict (#821)

* resolves namespace conflicts

* moves pubsub import under compiler flag
This commit is contained in:
Sanaz Taheri Boshrooyeh 2022-01-21 10:55:36 -08:00 committed by GitHub
parent b3a7722297
commit dbccecc562
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 8 deletions

View File

@ -37,6 +37,7 @@ export
when defined(rln): when defined(rln):
import import
libp2p/protocols/pubsub/rpc/messages, libp2p/protocols/pubsub/rpc/messages,
libp2p/protocols/pubsub/pubsub,
web3, web3,
../protocol/waku_rln_relay/[rln, waku_rln_relay_utils] ../protocol/waku_rln_relay/[rln, waku_rln_relay_utils]
@ -463,7 +464,7 @@ when defined(rln):
## this procedure is a thin wrapper for the pubsub addValidator method ## this procedure is a thin wrapper for the pubsub addValidator method
## it sets message validator on the given pubsubTopic, the validator will check that ## it sets message validator on the given pubsubTopic, the validator will check that
## all the messages published in the pubsubTopic have a valid zero-knowledge proof ## all the messages published in the pubsubTopic have a valid zero-knowledge proof
proc validator(topic: string, message: messages.Message): Future[ValidationResult] {.async.} = proc validator(topic: string, message: messages.Message): Future[pubsub.ValidationResult] {.async.} =
let msg = WakuMessage.init(message.data) let msg = WakuMessage.init(message.data)
if msg.isOk(): if msg.isOk():
let let
@ -473,21 +474,21 @@ when defined(rln):
case validationRes: case validationRes:
of Valid: of Valid:
info "message validity is verified, relaying:", wakumessage=wakumessage info "message validity is verified, relaying:", wakumessage=wakumessage
return ValidationResult.Accept return pubsub.ValidationResult.Accept
of Invalid: of Invalid:
info "message validity could not be verified, discarding:", wakumessage=wakumessage info "message validity could not be verified, discarding:", wakumessage=wakumessage
return ValidationResult.Reject return pubsub.ValidationResult.Reject
of Spam: of Spam:
info "A spam message is found! yay! discarding:", wakumessage=wakumessage info "A spam message is found! yay! discarding:", wakumessage=wakumessage
return ValidationResult.Reject return pubsub.ValidationResult.Reject
# set a validator for the supplied pubsubTopic # set a validator for the supplied pubsubTopic
let pb = PubSub(node.wakuRelay) let pb = PubSub(node.wakuRelay)
pb.addValidator(pubsubTopic, validator) pb.addValidator(pubsubTopic, validator)
proc mountRlnRelay*(node: WakuNode, proc mountRlnRelay*(node: WakuNode,
ethClientAddrOpt: Option[string] = none(string), ethClientAddrOpt: Option[string] = none(string),
ethAccAddrOpt: Option[Address] = none(Address), ethAccAddrOpt: Option[web3.Address] = none(web3.Address),
memContractAddOpt: Option[Address] = none(Address), memContractAddOpt: Option[web3.Address] = none(web3.Address),
groupOpt: Option[seq[IDCommitment]] = none(seq[IDCommitment]), groupOpt: Option[seq[IDCommitment]] = none(seq[IDCommitment]),
memKeyPairOpt: Option[MembershipKeyPair] = none(MembershipKeyPair), memKeyPairOpt: Option[MembershipKeyPair] = none(MembershipKeyPair),
memIndexOpt: Option[MembershipIndex] = none(MembershipIndex), memIndexOpt: Option[MembershipIndex] = none(MembershipIndex),
@ -528,8 +529,8 @@ when defined(rln):
var var
ethClientAddr: string ethClientAddr: string
ethAccAddr: Address ethAccAddr: web3.Address
memContractAdd: Address memContractAdd: web3.Address
if onchainMode: if onchainMode:
ethClientAddr = ethClientAddrOpt.get() ethClientAddr = ethClientAddrOpt.get()
ethAccAddr = ethAccAddrOpt.get() ethAccAddr = ethAccAddrOpt.get()