Portal JSON-RPC API fixes (#1511)

This commit is contained in:
Kim De Mey 2023-03-20 17:25:34 +01:00 committed by GitHub
parent 633f135c72
commit 249cabd64e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 29 deletions

View File

@ -98,31 +98,6 @@ proc installDiscoveryApiHandlers*(rpcServer: RpcServer|RpcProxy,
else:
raise newException(ValueError, "Record not found in DHT lookup.")
# Note:
# These are difficult to support in our current discv5 implementation and it
# should be proven first that they are deemed useful before implementing them.
rpcServer.rpc("discv5_sendPing") do(enr: Record) -> string:
raise newException(ValueError, "This JSON-RPC is not supported")
rpcServer.rpc("discv5_sendPong") do(enr: Record, requestId: string) -> bool:
raise newException(ValueError, "This JSON-RPC is not supported")
rpcServer.rpc("discv5_sendFindNode") do(
enr: Record, distances: seq[uint16]) -> string:
raise newException(ValueError, "This JSON-RPC is not supported")
rpcServer.rpc("discv5_sendNodes") do(
enr: Record, nodes: seq[Record], requestId: string) -> uint8:
raise newException(ValueError, "This JSON-RPC is not supported")
rpcServer.rpc("discv5_sendTalkRequest") do(
enr: Record, protocolId: string, payload: string) -> string:
raise newException(ValueError, "This JSON-RPC is not supported")
rpcServer.rpc("discv5_sendTalkResponse") do(
enr: Record, payload: string, requestId: string) -> bool:
raise newException(ValueError, "This JSON-RPC is not supported")
rpcServer.rpc("discv5_ping") do(enr: Record) -> PongResponse:
let
node = toNodeWithAddress(enr)

View File

@ -195,9 +195,9 @@ proc installPortalApiHandlers*(
raise newException(ValueError, "Invalid content key")
contentResult = (await p.contentLookup(key, contentId)).valueOr:
raise newException(ValueError, "Content not found")
return "0x"
return contentResult.content.toHex()
return "0x" & contentResult.content.toHex()
rpcServer.rpc("portal_" & network & "Store") do(
contentKey: string, contentValue: string) -> bool:
@ -219,9 +219,9 @@ proc installPortalApiHandlers*(
let contentResult = p.dbGet(key, contentId)
if contentResult.isOk():
return contentResult.get().toHex()
return "0x" & contentResult.get().toHex()
else:
return "0x0"
return "0x"
rpcServer.rpc("portal_" & network & "Gossip") do(
contentKey: string, contentValue: string) -> int: