Skip to content

Commit 16ce21d

Browse files
authored
feat: waku sync full topic support (#3275)
1 parent 32a1725 commit 16ce21d

File tree

14 files changed

+979
-309
lines changed

14 files changed

+979
-309
lines changed

tests/waku_store_sync/sync_utils.nim

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ proc randomHash*(rng: var Rand): WakuMessageHash =
2222

2323
proc newTestWakuRecon*(
2424
switch: Switch,
25-
idsRx: AsyncQueue[SyncID],
26-
wantsTx: AsyncQueue[PeerId],
27-
needsTx: AsyncQueue[(PeerId, Fingerprint)],
28-
cluster: uint16 = 1,
25+
pubsubTopics: seq[PubsubTopic] = @[],
26+
contentTopics: seq[ContentTopic] = @[],
2927
syncRange: timer.Duration = DefaultSyncRange,
30-
shards: seq[uint16] = @[0, 1, 2, 3, 4, 5, 6, 7],
28+
idsRx: AsyncQueue[(SyncID, PubsubTopic, ContentTopic)],
29+
wantsTx: AsyncQueue[PeerId],
30+
needsTx: AsyncQueue[(PeerId, WakuMessageHash)],
3131
): Future[SyncReconciliation] {.async.} =
3232
let peerManager = PeerManager.new(switch)
3333

3434
let res = await SyncReconciliation.new(
35-
cluster = cluster,
36-
shards = shards,
35+
pubsubTopics = pubsubTopics,
36+
contentTopics = contentTopics,
3737
peerManager = peerManager,
3838
wakuArchive = nil,
39-
relayJitter = 0.seconds,
4039
syncRange = syncRange,
40+
relayJitter = 0.seconds,
4141
idsRx = idsRx,
4242
localWantsTx = wantsTx,
4343
remoteNeedsTx = needsTx,
@@ -52,9 +52,9 @@ proc newTestWakuRecon*(
5252

5353
proc newTestWakuTransfer*(
5454
switch: Switch,
55-
idsTx: AsyncQueue[SyncID],
55+
idsTx: AsyncQueue[(SyncID, PubsubTopic, ContentTopic)],
5656
wantsRx: AsyncQueue[PeerId],
57-
needsRx: AsyncQueue[(PeerId, Fingerprint)],
57+
needsRx: AsyncQueue[(PeerId, WakuMessageHash)],
5858
): SyncTransfer =
5959
let peerManager = PeerManager.new(switch)
6060

tests/waku_store_sync/test_codec.nim

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ suite "Waku Store Sync Codec":
9999
let range4 = (bounds4, RangeType.ItemSet)
100100

101101
let payload = RangesData(
102+
pubsubTopics: @[DefaultPubsubTopic],
103+
contentTopics: @[],
102104
ranges: @[range1, range2, range3, range4],
103105
fingerprints: @[],
104106
itemSets: @[itemSet1, itemSet2, itemSet3, itemSet4],
@@ -139,6 +141,8 @@ suite "Waku Store Sync Codec":
139141
ranges.add(range)
140142

141143
let payload = RangesData(
144+
pubsubTopics: @[DefaultPubsubTopic],
145+
contentTopics: @[],
142146
ranges: ranges,
143147
fingerprints:
144148
@[randomHash(rng), randomHash(rng), randomHash(rng), randomHash(rng)],
@@ -186,8 +190,13 @@ suite "Waku Store Sync Codec":
186190
ranges.add((bound, RangeType.ItemSet))
187191
itemSets.add(itemSet)
188192

189-
let payload =
190-
RangesData(ranges: ranges, fingerprints: fingerprints, itemSets: itemSets)
193+
let payload = RangesData(
194+
pubsubTopics: @[DefaultPubsubTopic],
195+
contentTopics: @[],
196+
ranges: ranges,
197+
fingerprints: fingerprints,
198+
itemSets: itemSets,
199+
)
191200

192201
let encodedPayload = payload.deltaEncode()
193202

0 commit comments

Comments
 (0)