Tiny cleanup and more encapsulation in protocol.nim files (#2488)

This commit is contained in:
Ivan FB 2024-03-04 15:31:37 +01:00 committed by GitHub
parent 5b174fb392
commit a2e28a04f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 4 additions and 12 deletions

View File

@ -120,14 +120,6 @@ proc new*(T: type WakuFilterLegacy,
wf.initProtocolHandler()
return wf
proc init*(T: type WakuFilterLegacy,
peerManager: PeerManager,
rng: ref rand.HmacDrbgContext,
timeout: Duration = WakuLegacyFilterTimeout): T {.
deprecated: "WakuFilterLegacy.new()' instead".} =
WakuFilterLegacy.new(peerManager, rng, timeout)
proc sendFilterRpc(wf: WakuFilterLegacy, rpc: FilterRPC, peer: PeerId|RemotePeerInfo): Future[WakuFilterResult[void]] {.async, gcsafe.}=
let connOpt = await wf.peerManager.dialPeer(peer, WakuLegacyFilterCodec)
if connOpt.isNone():

View File

@ -261,7 +261,7 @@ proc new*(T: type WakuFilter,
const MaintainSubscriptionsInterval* = 1.minutes
proc startMaintainingSubscriptions*(wf: WakuFilter, interval: Duration) =
proc startMaintainingSubscriptions(wf: WakuFilter, interval: Duration) =
trace "starting to maintain subscriptions"
var maintainSubs: CallbackFunc
maintainSubs = CallbackFunc(

View File

@ -62,7 +62,7 @@ proc handleRequest*(wl: WakuLightPush, peerId: PeerId, buffer: seq[byte]): Futur
let rpc = PushRPC(requestId: requestId, response: some(response))
return rpc
proc initProtocolHandler*(wl: WakuLightPush) =
proc initProtocolHandler(wl: WakuLightPush) =
proc handle(conn: Connection, proto: string) {.async.} =
let buffer = await conn.readLp(MaxRpcSize.int)
let rpc = await handleRequest(wl, conn.peerId, buffer)

View File

@ -68,7 +68,7 @@ proc request*(m: WakuMetadata, conn: Connection): Future[Result[WakuMetadataResp
return ok(response)
proc initProtocolHandler*(m: WakuMetadata) =
proc initProtocolHandler(m: WakuMetadata) =
proc handle(conn: Connection, proto: string) {.async, gcsafe, closure.} =
let res = catch: await conn.readLp(RpcResponseMaxBytes)
let buffer = res.valueOr:

View File

@ -196,7 +196,7 @@ proc isSubscribed*(w: WakuRelay, topic: PubsubTopic): bool =
proc subscribedTopics*(w: WakuRelay): seq[PubsubTopic] =
return toSeq(GossipSub(w).topics.keys())
proc generateOrderedValidator*(w: WakuRelay): auto {.gcsafe.} =
proc generateOrderedValidator(w: WakuRelay): auto {.gcsafe.} =
# rejects messages that are not WakuMessage
let wrappedValidator = proc(pubsubTopic: string,
message: messages.Message): Future[ValidationResult] {.async.} =