From 0fb05f293a4c221e08411e4d9b9f132d6ba800df Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Fri, 11 Oct 2024 15:59:13 +0800 Subject: [PATCH] feat(rpc): Filecoin.F3GetProgress (#4878) --- CHANGELOG.md | 3 +++ f3-sidecar/api.go | 4 ++++ src/rpc/methods/f3.rs | 18 ++++++++++++++++++ src/rpc/mod.rs | 1 + 4 files changed, 26 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebd94e94b87..487719fde55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,9 @@ - [#4865](https://github.com/ChainSafe/forest/issues/4865) Add support for the `Filecoin.F3IsRunning` RPC method. +- [#4878](https://github.com/ChainSafe/forest/issues/4878) Add support for the + `Filecoin.F3GetProgress` RPC method. + - [#4857](https://github.com/ChainSafe/forest/pull/4857) Add support for nv24 (TukTuk). diff --git a/f3-sidecar/api.go b/f3-sidecar/api.go index 54ddb13655f..ad1dc030679 100644 --- a/f3-sidecar/api.go +++ b/f3-sidecar/api.go @@ -53,3 +53,7 @@ func (h *F3ServerHandler) F3GetF3PowerTable(ctx context.Context, tsk []byte) (gp func (h *F3ServerHandler) F3IsRunning(_ context.Context) bool { return h.f3.IsRunning() } + +func (h *F3ServerHandler) F3GetProgress(_ context.Context) gpbft.Instant { + return h.f3.Progress() +} diff --git a/src/rpc/methods/f3.rs b/src/rpc/methods/f3.rs index 415ce544925..763d966c2e8 100644 --- a/src/rpc/methods/f3.rs +++ b/src/rpc/methods/f3.rs @@ -589,6 +589,24 @@ impl RpcMethod<0> for F3IsRunning { } } +/// See +pub enum F3GetProgress {} +impl RpcMethod<0> for F3GetProgress { + const NAME: &'static str = "Filecoin.F3GetProgress"; + const PARAM_NAMES: [&'static str; 0] = []; + const API_PATHS: ApiPaths = ApiPaths::V1; + const PERMISSION: Permission = Permission::Read; + + type Params = (); + type Ok = serde_json::Value; + + async fn handle(_: Ctx, (): Self::Params) -> Result { + let client = get_rpc_http_client()?; + let response = client.request(Self::NAME, ArrayParams::new()).await?; + Ok(response) + } +} + /// F3Participate should be called by a storage provider to participate in signing F3 consensus. /// Calling this API gives the node a lease to sign in F3 on behalf of given SP. /// The lease should be active only on one node. The lease will expire at the newLeaseExpiration. diff --git a/src/rpc/mod.rs b/src/rpc/mod.rs index 66cf4924c9e..c389709159c 100644 --- a/src/rpc/mod.rs +++ b/src/rpc/mod.rs @@ -239,6 +239,7 @@ macro_rules! for_each_method { $callback!(crate::rpc::f3::F3GetECPowerTable); $callback!(crate::rpc::f3::F3GetF3PowerTable); $callback!(crate::rpc::f3::F3IsRunning); + $callback!(crate::rpc::f3::F3GetProgress); $callback!(crate::rpc::f3::F3GetLatestCertificate); $callback!(crate::rpc::f3::F3Participate); $callback!(crate::rpc::f3::GetHead);