From 52b99f37afeed5cc5db092e02a15ed4563c7a44c Mon Sep 17 00:00:00 2001 From: Sanaz Taheri Boshrooyeh <35961250+staheri14@users.noreply.github.com> Date: Tue, 20 Jul 2021 11:51:32 -0700 Subject: [PATCH] Fixes the order of fields of History Response protobuf (#676) * shifts history response field numbers by 1 * adds changelog * minor rewording * minor --- CHANGELOG.md | 2 ++ waku/v2/protocol/waku_store/waku_store.nim | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a271f88a8..89587b4f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ This release contains the following: - Updates the `resume` Nim API to fetch historical messages in sequence of pages. - Support for stable version of `relay` protocol, with protocol ID `/vac/waku/relay/2.0.0` - Support for multiple protocol IDs - now matches any protocol that adds postfix to stable ID. +- Updates the order of fields of `HistoryResponse` protobuf message. + The filed numbers of the `HistoryResponse` are shifted up by one to match up the [13/WAKU2-STORE](https://rfc.vac.dev/spec/13/) specs. #### General refactoring #### Docs diff --git a/waku/v2/protocol/waku_store/waku_store.nim b/waku/v2/protocol/waku_store/waku_store.nim index 02721347e..2d9c707a3 100644 --- a/waku/v2/protocol/waku_store/waku_store.nim +++ b/waku/v2/protocol/waku_store/waku_store.nim @@ -174,17 +174,17 @@ proc init*(T: type HistoryResponse, buffer: seq[byte]): ProtoResult[T] = let pb = initProtoBuffer(buffer) var messages: seq[seq[byte]] - discard ? pb.getRepeatedField(1, messages) + discard ? pb.getRepeatedField(2, messages) for buf in messages: msg.messages.add(? WakuMessage.init(buf)) var pagingInfoBuffer: seq[byte] - discard ? pb.getField(2,pagingInfoBuffer) + discard ? pb.getField(3, pagingInfoBuffer) msg.pagingInfo= ? PagingInfo.init(pagingInfoBuffer) var error: uint32 - discard ? pb.getField(3, error) + discard ? pb.getField(4, error) msg.error = HistoryResponseError(error) return ok(msg) @@ -232,11 +232,11 @@ proc encode*(response: HistoryResponse): ProtoBuffer = var output = initProtoBuffer() for msg in response.messages: - output.write(1, msg.encode()) + output.write(2, msg.encode()) - output.write(2, response.pagingInfo.encode()) + output.write(3, response.pagingInfo.encode()) - output.write(3, uint32(ord(response.error))) + output.write(4, uint32(ord(response.error))) return output