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):
import
libp2p/protocols/pubsub/rpc/messages,
libp2p/protocols/pubsub/pubsub,
web3,
../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
## 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
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)
if msg.isOk():
let
@ -473,21 +474,21 @@ when defined(rln):
case validationRes:
of Valid:
info "message validity is verified, relaying:", wakumessage=wakumessage
return ValidationResult.Accept
return pubsub.ValidationResult.Accept
of Invalid:
info "message validity could not be verified, discarding:", wakumessage=wakumessage
return ValidationResult.Reject
return pubsub.ValidationResult.Reject
of Spam:
info "A spam message is found! yay! discarding:", wakumessage=wakumessage
return ValidationResult.Reject
return pubsub.ValidationResult.Reject
# set a validator for the supplied pubsubTopic
let pb = PubSub(node.wakuRelay)
pb.addValidator(pubsubTopic, validator)
proc mountRlnRelay*(node: WakuNode,
ethClientAddrOpt: Option[string] = none(string),
ethAccAddrOpt: Option[Address] = none(Address),
memContractAddOpt: Option[Address] = none(Address),
ethAccAddrOpt: Option[web3.Address] = none(web3.Address),
memContractAddOpt: Option[web3.Address] = none(web3.Address),
groupOpt: Option[seq[IDCommitment]] = none(seq[IDCommitment]),
memKeyPairOpt: Option[MembershipKeyPair] = none(MembershipKeyPair),
memIndexOpt: Option[MembershipIndex] = none(MembershipIndex),
@ -528,8 +529,8 @@ when defined(rln):
var
ethClientAddr: string
ethAccAddr: Address
memContractAdd: Address
ethAccAddr: web3.Address
memContractAdd: web3.Address
if onchainMode:
ethClientAddr = ethClientAddrOpt.get()
ethAccAddr = ethAccAddrOpt.get()