2023-12-01 17:20:52 +01:00
|
|
|
# Fluffy
|
2024-01-25 11:04:09 +01:00
|
|
|
# Copyright (c) 2022-2024 Status Research & Development GmbH
|
2022-01-14 16:07:14 +01: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 13:38:08 +01:00
|
|
|
{.push raises: [].}
|
2022-01-14 16:07:14 +01:00
|
|
|
|
|
|
|
import
|
2024-09-18 15:46:50 +08:00
|
|
|
json_rpc/rpcserver,
|
2022-01-14 16:07:14 +01:00
|
|
|
../network/wire/portal_protocol,
|
2023-01-05 15:26:58 +01:00
|
|
|
../eth_data/history_data_seeding,
|
2024-07-10 23:02:15 +02:00
|
|
|
../database/content_db
|
2022-01-14 16:07:14 +01:00
|
|
|
|
|
|
|
export rpcserver
|
|
|
|
|
2024-10-10 16:42:57 +02: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 22:33:02 +08:00
|
|
|
proc installPortalDebugHistoryApiHandlers*(rpcServer: RpcServer, p: PortalProtocol) =
|
2024-02-15 16:49:22 +01:00
|
|
|
## Portal debug API calls related to storage and seeding from Era1 files.
|
2024-10-08 15:21:27 +08:00
|
|
|
rpcServer.rpc("portal_debug_historyGossipHeaders") do(
|
2024-07-11 17:42:45 +02:00
|
|
|
era1File: string, epochRecordFile: Opt[string]
|
2024-02-28 18:31:45 +01:00
|
|
|
) -> bool:
|
2024-07-11 17:42:45 +02:00
|
|
|
let res = await p.historyGossipHeadersWithProof(era1File, epochRecordFile)
|
2024-02-15 16:49:22 +01:00
|
|
|
if res.isOk():
|
|
|
|
return true
|
|
|
|
else:
|
|
|
|
raise newException(ValueError, $res.error)
|
|
|
|
|
2024-10-08 15:21:27 +08:00
|
|
|
rpcServer.rpc("portal_debug_historyGossipBlockContent") do(era1File: string) -> bool:
|
2024-02-15 16:49:22 +01:00
|
|
|
let res = await p.historyGossipBlockContent(era1File)
|
|
|
|
if res.isOk():
|
|
|
|
return true
|
|
|
|
else:
|
|
|
|
raise newException(ValueError, $res.error)
|