Skip to content

Commit

Permalink
feat(rpc): Filecoin.F3GetProgress (#4878)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 authored Oct 11, 2024
1 parent 94dabc6 commit 0fb05f2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
4 changes: 4 additions & 0 deletions f3-sidecar/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
18 changes: 18 additions & 0 deletions src/rpc/methods/f3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,24 @@ impl RpcMethod<0> for F3IsRunning {
}
}

/// See <https://github.com/filecoin-project/lotus/blob/master/documentation/en/api-v1-unstable-methods.md#F3GetProgress>
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<impl Blockstore>, (): Self::Params) -> Result<Self::Ok, ServerError> {
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.
Expand Down
1 change: 1 addition & 0 deletions src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0fb05f2

Please sign in to comment.