mirror of https://github.com/waku-org/nwaku.git
Updates store json rpc api (#499)
* updates the store jsonrpc api and its usage across the codebase * deletes unused codes * deletes commented codes * minor * spacing issue
This commit is contained in:
parent
d7de633793
commit
a04643e9a2
|
@ -21,7 +21,7 @@ import
|
|||
private_api],
|
||||
../../waku/v2/protocol/message_notifier,
|
||||
../../waku/v2/protocol/waku_relay,
|
||||
../../waku/v2/protocol/waku_store/waku_store,
|
||||
../../waku/v2/protocol/waku_store/[waku_store, waku_store_types],
|
||||
../../waku/v2/protocol/waku_swap/waku_swap,
|
||||
../../waku/v2/protocol/waku_filter/waku_filter,
|
||||
../test_helpers
|
||||
|
@ -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(@[defaultContentTopic], some(StorePagingOptions()))
|
||||
let response = await client.get_waku_v2_store_v1_messages(@[HistoryContentFilter(contentTopic: defaultContentTopic)], 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(topics: seq[ContentTopic], pagingOptions: Option[StorePagingOptions]): StoreResponse
|
||||
proc get_waku_v2_store_v1_messages(contentFilters: seq[HistoryContentFilter], 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(contentTopics: seq[ContentTopic], pagingOptions: Option[StorePagingOptions]) -> StoreResponse:
|
||||
rpcsrv.rpc("get_waku_v2_store_v1_messages") do(contentFilters: seq[HistoryContentFilter], pagingOptions: Option[StorePagingOptions]) -> StoreResponse:
|
||||
## Returns history for a list of content topics with optional paging
|
||||
debug "get_waku_v2_store_v1_messages"
|
||||
|
||||
|
@ -27,10 +27,6 @@ proc installStoreApiHandlers*(node: WakuNode, rpcsrv: RpcServer) =
|
|||
debug "get_waku_v2_store_v1_messages response"
|
||||
responseFut.complete(response.toStoreResponse())
|
||||
|
||||
var contentFilters: seq[HistoryContentFilter] = @[]
|
||||
# items in contentTopics map to the contentTopic field of waku message (not to be confused with pubsub topic)
|
||||
for ct in contentTopics:
|
||||
contentFilters.add(HistoryContentFilter(contentTopic: ct))
|
||||
let historyQuery = HistoryQuery(contentFilters: contentFilters,
|
||||
pagingInfo: if pagingOptions.isSome: pagingOptions.get.toPagingInfo() else: PagingInfo())
|
||||
|
||||
|
@ -41,4 +37,4 @@ proc installStoreApiHandlers*(node: WakuNode, rpcsrv: RpcServer) =
|
|||
return responseFut.read()
|
||||
else:
|
||||
# Future failed to complete
|
||||
raise newException(ValueError, "No history response received")
|
||||
raise newException(ValueError, "No history response received")
|
|
@ -32,5 +32,5 @@ echo "Input is:", input
|
|||
var node = newRpcHttpClient()
|
||||
waitfor node.connect("localhost", rpcPort)
|
||||
|
||||
var res = waitfor node.get_waku_v2_store_v1_messages(@[ContentTopic(input)], none(StorePagingOptions))
|
||||
var res = waitfor node.get_waku_v2_store_v1_messages(@[HistoryContentFilter(contentTopic: ContentTopic(input))], none(StorePagingOptions))
|
||||
echo "Waku query response: ", res
|
||||
|
|
Loading…
Reference in New Issue