mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-03 14:33:12 +00:00
adds startTime and endTime to the HistoryQuery (#451)
This commit is contained in:
parent
0ffd17006e
commit
af7de3e189
@ -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)
|
||||
|
||||
|
||||
@ -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()
|
||||
|
||||
|
||||
@ -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]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user