2023-12-01 16:20:52 +00:00
|
|
|
# Fluffy
|
2024-01-25 10:04:09 +00:00
|
|
|
# Copyright (c) 2022-2024 Status Research & Development GmbH
|
2022-01-14 15:07:14 +00:00
|
|
|
# Licensed and distributed under either of
|
|
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
2023-01-31 12:38:08 +00:00
|
|
|
{.push raises: [].}
|
2022-01-14 15:07:14 +00:00
|
|
|
|
|
|
|
import
|
2024-09-18 07:46:50 +00:00
|
|
|
json_rpc/rpcserver,
|
2022-01-14 15:07:14 +00:00
|
|
|
../network/wire/portal_protocol,
|
2023-01-05 14:26:58 +00:00
|
|
|
../eth_data/history_data_seeding,
|
2024-07-10 21:02:15 +00:00
|
|
|
../database/content_db
|
2022-01-14 15:07:14 +00:00
|
|
|
|
|
|
|
export rpcserver
|
|
|
|
|
2024-10-10 14:42:57 +00:00
|
|
|
# Non-spec-RPCs that are used for seeding history content into the network without
|
|
|
|
# usage of the standalone portal_bridge. As source Era1 files are used.
|
2024-10-07 14:33:02 +00:00
|
|
|
proc installPortalDebugHistoryApiHandlers*(rpcServer: RpcServer, p: PortalProtocol) =
|
2024-02-15 15:49:22 +00:00
|
|
|
## Portal debug API calls related to storage and seeding from Era1 files.
|
2024-10-08 07:21:27 +00:00
|
|
|
rpcServer.rpc("portal_debug_historyGossipHeaders") do(
|
2024-07-11 15:42:45 +00:00
|
|
|
era1File: string, epochRecordFile: Opt[string]
|
2024-02-28 17:31:45 +00:00
|
|
|
) -> bool:
|
2024-07-11 15:42:45 +00:00
|
|
|
let res = await p.historyGossipHeadersWithProof(era1File, epochRecordFile)
|
2024-02-15 15:49:22 +00:00
|
|
|
if res.isOk():
|
|
|
|
return true
|
|
|
|
else:
|
|
|
|
raise newException(ValueError, $res.error)
|
|
|
|
|
2024-10-08 07:21:27 +00:00
|
|
|
rpcServer.rpc("portal_debug_historyGossipBlockContent") do(era1File: string) -> bool:
|
2024-02-15 15:49:22 +00:00
|
|
|
let res = await p.historyGossipBlockContent(era1File)
|
|
|
|
if res.isOk():
|
|
|
|
return true
|
|
|
|
else:
|
|
|
|
raise newException(ValueError, $res.error)
|