mirror of
https://github.com/waku-org/nwaku.git
synced 2025-02-05 11:34:45 +00:00
adds startTime and endTime to the HistoryQuery (#451)
This commit is contained in:
parent
192c2c7ea0
commit
a0dba2fea4
@ -330,11 +330,11 @@ procSuite "Waku Store":
|
|||||||
decodedEmptyPagingInfo.isErr == false
|
decodedEmptyPagingInfo.isErr == false
|
||||||
decodedEmptyPagingInfo.value == emptyPagingInfo
|
decodedEmptyPagingInfo.value == emptyPagingInfo
|
||||||
|
|
||||||
test "HistoryQuery Protobuf encod/init test":
|
test "HistoryQuery Protobuf encode/init test":
|
||||||
let
|
let
|
||||||
index = computeIndex(WakuMessage(payload: @[byte 1], contentTopic: ContentTopic(1)))
|
index = computeIndex(WakuMessage(payload: @[byte 1], contentTopic: ContentTopic(1)))
|
||||||
pagingInfo = PagingInfo(pageSize: 1, cursor: index, direction: PagingDirection.BACKWARD)
|
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()
|
pb = query.encode()
|
||||||
decodedQuery = HistoryQuery.init(pb.buffer)
|
decodedQuery = HistoryQuery.init(pb.buffer)
|
||||||
|
|
||||||
|
@ -146,6 +146,10 @@ proc init*(T: type HistoryQuery, buffer: seq[byte]): ProtoResult[T] =
|
|||||||
|
|
||||||
msg.pagingInfo = ? PagingInfo.init(pagingInfoBuffer)
|
msg.pagingInfo = ? PagingInfo.init(pagingInfoBuffer)
|
||||||
|
|
||||||
|
discard ? pb.getField(3, msg.startTime)
|
||||||
|
discard ? pb.getField(4, msg.endTime)
|
||||||
|
|
||||||
|
|
||||||
ok(msg)
|
ok(msg)
|
||||||
|
|
||||||
proc init*(T: type HistoryResponse, buffer: seq[byte]): ProtoResult[T] =
|
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(2, query.pagingInfo.encode())
|
||||||
|
|
||||||
|
result.write(3, query.startTime)
|
||||||
|
result.write(4, query.endTime)
|
||||||
|
|
||||||
proc encode*(response: HistoryResponse): ProtoBuffer =
|
proc encode*(response: HistoryResponse): ProtoBuffer =
|
||||||
result = initProtoBuffer()
|
result = initProtoBuffer()
|
||||||
|
|
||||||
|
@ -39,6 +39,8 @@ type
|
|||||||
HistoryQuery* = object
|
HistoryQuery* = object
|
||||||
topics*: seq[ContentTopic]
|
topics*: seq[ContentTopic]
|
||||||
pagingInfo*: PagingInfo # used for pagination
|
pagingInfo*: PagingInfo # used for pagination
|
||||||
|
startTime*: float64 # used for time-window query
|
||||||
|
endTime*: float64 # used for time-window query
|
||||||
|
|
||||||
HistoryResponse* = object
|
HistoryResponse* = object
|
||||||
messages*: seq[WakuMessage]
|
messages*: seq[WakuMessage]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user