Cache offers in json rpc APIs.

This commit is contained in:
bhartnett 2024-11-04 22:28:09 +08:00
parent 64045655a8
commit a76d7122e4
No known key found for this signature in database
GPG Key ID: 076F2830DA6BD535
3 changed files with 4 additions and 4 deletions

View File

@ -116,7 +116,7 @@ proc installPortalBeaconApiHandlers*(rpcServer: RpcServer, p: PortalProtocol) =
contentId = p.toContentId(key).valueOr:
raise invalidKeyErr()
p.storeContent(key, contentId, contentValueBytes)
p.storeContent(key, contentId, contentValueBytes, cacheOffer = true)
rpcServer.rpc("portal_beaconLocalContent") do(contentKey: string) -> string:
let

View File

@ -116,7 +116,7 @@ proc installPortalHistoryApiHandlers*(rpcServer: RpcServer, p: PortalProtocol) =
contentId = p.toContentId(key).valueOr:
raise invalidKeyErr()
p.storeContent(key, contentId, contentValueBytes)
p.storeContent(key, contentId, contentValueBytes, cacheOffer = true)
rpcServer.rpc("portal_historyLocalContent") do(contentKey: string) -> string:
let

View File

@ -137,7 +137,7 @@ proc installPortalStateApiHandlers*(rpcServer: RpcServer, p: PortalProtocol) =
contentValue = validateOfferGetValue(Opt.none(Hash32), key, contentBytes).valueOr:
raise invalidValueErr()
p.storeContent(keyBytes, contentId, contentValue)
p.storeContent(keyBytes, contentId, contentValue, cacheOffer = true)
rpcServer.rpc("portal_stateLocalContent") do(contentKey: string) -> string:
let
@ -159,7 +159,7 @@ proc installPortalStateApiHandlers*(rpcServer: RpcServer, p: PortalProtocol) =
contentValue = validateOfferGetValue(Opt.none(Hash32), key, contentBytes).valueOr:
raise invalidValueErr()
p.storeContent(keyBytes, contentId, contentValue)
p.storeContent(keyBytes, contentId, contentValue, cacheOffer = true)
await p.neighborhoodGossip(
Opt.none(NodeId), ContentKeysList(@[keyBytes]), @[contentBytes]