mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-13 16:25:00 +00:00
Enable time-based history query in the store rpc api (#560)
* adds time based query * updates the changelog
This commit is contained in:
parent
2691b3e506
commit
c9e94cba41
12
CHANGELOG.md
12
CHANGELOG.md
@ -1,5 +1,17 @@
|
||||
# Changelog
|
||||
|
||||
## v0.4
|
||||
This release contains the following:
|
||||
|
||||
### Features
|
||||
### Changes
|
||||
#### General refactoring
|
||||
#### Docs
|
||||
#### Schema
|
||||
#### API
|
||||
- [JSON-RPC Store API](https://rfc.vac.dev/spec/16): Added an optional time-based query to filter historical messages.
|
||||
### Fixes
|
||||
|
||||
## 2021-05-11 v0.3
|
||||
|
||||
This release contains the following:
|
||||
|
@ -242,16 +242,16 @@ procSuite "Waku v2 JSON-RPC API":
|
||||
|
||||
# Now prime it with some history before tests
|
||||
var
|
||||
msgList = @[WakuMessage(payload: @[byte 0], contentTopic: ContentTopic("2")),
|
||||
WakuMessage(payload: @[byte 1], contentTopic: defaultContentTopic),
|
||||
WakuMessage(payload: @[byte 2], contentTopic: defaultContentTopic),
|
||||
WakuMessage(payload: @[byte 3], contentTopic: defaultContentTopic),
|
||||
WakuMessage(payload: @[byte 4], contentTopic: defaultContentTopic),
|
||||
WakuMessage(payload: @[byte 5], contentTopic: defaultContentTopic),
|
||||
WakuMessage(payload: @[byte 6], contentTopic: defaultContentTopic),
|
||||
WakuMessage(payload: @[byte 7], contentTopic: defaultContentTopic),
|
||||
WakuMessage(payload: @[byte 8], contentTopic: defaultContentTopic),
|
||||
WakuMessage(payload: @[byte 9], contentTopic: ContentTopic("2"))]
|
||||
msgList = @[WakuMessage(payload: @[byte 0], contentTopic: ContentTopic("2"), timestamp: 0),
|
||||
WakuMessage(payload: @[byte 1], contentTopic: defaultContentTopic, timestamp: 1),
|
||||
WakuMessage(payload: @[byte 2], contentTopic: defaultContentTopic, timestamp: 2),
|
||||
WakuMessage(payload: @[byte 3], contentTopic: defaultContentTopic, timestamp: 3),
|
||||
WakuMessage(payload: @[byte 4], contentTopic: defaultContentTopic, timestamp: 4),
|
||||
WakuMessage(payload: @[byte 5], contentTopic: defaultContentTopic, timestamp: 5),
|
||||
WakuMessage(payload: @[byte 6], contentTopic: defaultContentTopic, timestamp: 6),
|
||||
WakuMessage(payload: @[byte 7], contentTopic: defaultContentTopic, timestamp: 7),
|
||||
WakuMessage(payload: @[byte 8], contentTopic: defaultContentTopic, timestamp: 8),
|
||||
WakuMessage(payload: @[byte 9], contentTopic: ContentTopic("2"), timestamp: 9)]
|
||||
|
||||
for wakuMsg in msgList:
|
||||
waitFor subscriptions.notify(defaultTopic, wakuMsg)
|
||||
@ -259,7 +259,7 @@ procSuite "Waku v2 JSON-RPC API":
|
||||
let client = newRpcHttpClient()
|
||||
await client.connect("127.0.0.1", rpcPort)
|
||||
|
||||
let response = await client.get_waku_v2_store_v1_messages(some(defaultTopic), some(@[HistoryContentFilter(contentTopic: defaultContentTopic)]), some(StorePagingOptions()))
|
||||
let response = await client.get_waku_v2_store_v1_messages(some(defaultTopic), some(@[HistoryContentFilter(contentTopic: defaultContentTopic)]), some(0.float64), some(9.float64), some(StorePagingOptions()))
|
||||
check:
|
||||
response.messages.len() == 8
|
||||
response.pagingOptions.isNone
|
||||
|
@ -16,7 +16,7 @@ proc delete_waku_v2_relay_v1_subscriptions(topics: seq[string]): bool
|
||||
|
||||
# Store API
|
||||
|
||||
proc get_waku_v2_store_v1_messages(pubsubTopicOption: Option[string], contentFiltersOption: Option[seq[HistoryContentFilter]], pagingOptions: Option[StorePagingOptions]): StoreResponse
|
||||
proc get_waku_v2_store_v1_messages(pubsubTopicOption: Option[string], contentFiltersOption: Option[seq[HistoryContentFilter]], startTime: Option[float64], endTime: Option[float64], pagingOptions: Option[StorePagingOptions]): StoreResponse
|
||||
|
||||
# Filter API
|
||||
|
||||
|
@ -17,7 +17,7 @@ proc installStoreApiHandlers*(node: WakuNode, rpcsrv: RpcServer) =
|
||||
|
||||
## Store API version 1 definitions
|
||||
|
||||
rpcsrv.rpc("get_waku_v2_store_v1_messages") do(pubsubTopicOption: Option[string], contentFiltersOption: Option[seq[HistoryContentFilter]], pagingOptions: Option[StorePagingOptions]) -> StoreResponse:
|
||||
rpcsrv.rpc("get_waku_v2_store_v1_messages") do(pubsubTopicOption: Option[string], contentFiltersOption: Option[seq[HistoryContentFilter]], startTime: Option[float64], endTime: Option[float64], pagingOptions: Option[StorePagingOptions]) -> StoreResponse:
|
||||
## Returns history for a list of content topics with optional paging
|
||||
debug "get_waku_v2_store_v1_messages"
|
||||
|
||||
@ -29,6 +29,8 @@ proc installStoreApiHandlers*(node: WakuNode, rpcsrv: RpcServer) =
|
||||
|
||||
let historyQuery = HistoryQuery(pubsubTopic: if pubsubTopicOption.isSome: pubsubTopicOption.get() else: "",
|
||||
contentFilters: if contentFiltersOption.isSome: contentFiltersOption.get() else: @[],
|
||||
startTime: if startTime.isSome: startTime.get() else: 0.float64,
|
||||
endTime: if endTime.isSome: endTime.get() else: 0.float64,
|
||||
pagingInfo: if pagingOptions.isSome: pagingOptions.get.toPagingInfo() else: PagingInfo())
|
||||
|
||||
await node.query(historyQuery, queryFuncHandler)
|
||||
|
Loading…
x
Reference in New Issue
Block a user