adds startTime and endTime to the HistoryQuery (#451)

This commit is contained in:
Sanaz Taheri Boshrooyeh 2021-04-02 15:53:28 -07:00 committed by GitHub
parent 192c2c7ea0
commit a0dba2fea4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -330,11 +330,11 @@ procSuite "Waku Store":
decodedEmptyPagingInfo.isErr == false
decodedEmptyPagingInfo.value == emptyPagingInfo
test "HistoryQuery Protobuf encod/init test":
test "HistoryQuery Protobuf encode/init test":
let
index = computeIndex(WakuMessage(payload: @[byte 1], contentTopic: ContentTopic(1)))
pagingInfo = PagingInfo(pageSize: 1, cursor: index, direction: PagingDirection.BACKWARD)
query=HistoryQuery(topics: @[ContentTopic(1)], pagingInfo: pagingInfo)
query=HistoryQuery(topics: @[ContentTopic(1)], pagingInfo: pagingInfo, startTime: float64(10), endTime: float64(11))
pb = query.encode()
decodedQuery = HistoryQuery.init(pb.buffer)

View File

@ -146,6 +146,10 @@ proc init*(T: type HistoryQuery, buffer: seq[byte]): ProtoResult[T] =
msg.pagingInfo = ? PagingInfo.init(pagingInfoBuffer)
discard ? pb.getField(3, msg.startTime)
discard ? pb.getField(4, msg.endTime)
ok(msg)
proc init*(T: type HistoryResponse, buffer: seq[byte]): ProtoResult[T] =
@ -190,6 +194,9 @@ proc encode*(query: HistoryQuery): ProtoBuffer =
result.write(2, query.pagingInfo.encode())
result.write(3, query.startTime)
result.write(4, query.endTime)
proc encode*(response: HistoryResponse): ProtoBuffer =
result = initProtoBuffer()

View File

@ -39,6 +39,8 @@ type
HistoryQuery* = object
topics*: seq[ContentTopic]
pagingInfo*: PagingInfo # used for pagination
startTime*: float64 # used for time-window query
endTime*: float64 # used for time-window query
HistoryResponse* = object
messages*: seq[WakuMessage]