Add LocalContent call to Portal JSON-RPC API (#1383)
This commit is contained in:
parent
727b2445b7
commit
3f74f084c3
|
@ -20,6 +20,7 @@ proc portal_stateOffer(contentKey: string, contentValue: string): int
|
||||||
proc portal_stateRecursiveFindNodes(nodeId: NodeId): seq[Record]
|
proc portal_stateRecursiveFindNodes(nodeId: NodeId): seq[Record]
|
||||||
proc portal_stateRecursiveFindContent(contentKey: string): string
|
proc portal_stateRecursiveFindContent(contentKey: string): string
|
||||||
proc portal_stateStore(contentKey: string, contentValue: string): bool
|
proc portal_stateStore(contentKey: string, contentValue: string): bool
|
||||||
|
proc portal_stateLocalContent(contentKey: string): string
|
||||||
|
|
||||||
## Portal History Network json-rpc calls
|
## Portal History Network json-rpc calls
|
||||||
proc portal_historyNodeInfo(): NodeInfo
|
proc portal_historyNodeInfo(): NodeInfo
|
||||||
|
@ -43,3 +44,4 @@ proc portal_historyOffer(contentKey: string, contentValue: string): int
|
||||||
proc portal_historyRecursiveFindNodes(nodeId: NodeId): seq[Record]
|
proc portal_historyRecursiveFindNodes(nodeId: NodeId): seq[Record]
|
||||||
proc portal_historyRecursiveFindContent(contentKey: string): string
|
proc portal_historyRecursiveFindContent(contentKey: string): string
|
||||||
proc portal_historyStore(contentKey: string, contentValue: string): bool
|
proc portal_historyStore(contentKey: string, contentValue: string): bool
|
||||||
|
proc portal_historyLocalContent(contentKey: string): string
|
||||||
|
|
|
@ -205,3 +205,16 @@ proc installPortalApiHandlers*(
|
||||||
return true
|
return true
|
||||||
else:
|
else:
|
||||||
raise newException(ValueError, "Invalid content key")
|
raise newException(ValueError, "Invalid content key")
|
||||||
|
|
||||||
|
rpcServer.rpc("portal_" & network & "LocalContent") do(
|
||||||
|
contentKey: string) -> string:
|
||||||
|
let
|
||||||
|
key = ByteList.init(hexToSeqByte(contentKey))
|
||||||
|
contentId = p.toContentId(key).valueOr:
|
||||||
|
raise newException(ValueError, "Invalid content key")
|
||||||
|
|
||||||
|
let contentResult = p.dbGet(key, contentId)
|
||||||
|
if contentResult.isOk():
|
||||||
|
return contentResult.get().toHex()
|
||||||
|
else:
|
||||||
|
return "0x0"
|
||||||
|
|
Loading…
Reference in New Issue