Skip to content

Commit

Permalink
feat(rpc): internal F3 RPC methods to power go-f3 sidecar
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 committed Aug 16, 2024
1 parent 187d8c6 commit d70b7fe
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 0 deletions.
104 changes: 104 additions & 0 deletions src/rpc/methods/f3.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// Copyright 2019-2024 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

//!
//! This module contains F3(fast finality) related V1 RPC methods
//! as well as some internal RPC methods(F3.*) that power
//! the go-f3 node in sidecar mode.
//!
mod types;
use types::*;

use crate::{
rpc::{ApiPaths, Ctx, Permission, RpcMethod, ServerError},
shim::clock::ChainEpoch,
};
use fvm_ipld_blockstore::Blockstore;

pub enum F3GetTipsetByEpoch {}
impl RpcMethod<1> for F3GetTipsetByEpoch {
const NAME: &'static str = "F3.GetTipsetByEpoch";
const PARAM_NAMES: [&'static str; 1] = ["epoch"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

type Params = (ChainEpoch,);
type Ok = F3TipSet;

async fn handle(
ctx: Ctx<impl Blockstore>,
(epoch,): Self::Params,
) -> Result<Self::Ok, ServerError> {
unimplemented!()
}
}

pub enum F3GetTipset {}
impl RpcMethod<1> for F3GetTipset {
const NAME: &'static str = "F3.GetTipset";
const PARAM_NAMES: [&'static str; 1] = ["tipset_key"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

type Params = (F3TipSetKey,);
type Ok = F3TipSet;

async fn handle(
ctx: Ctx<impl Blockstore>,
(epoch,): Self::Params,
) -> Result<Self::Ok, ServerError> {
unimplemented!()
}
}

pub enum F3GetHead {}
impl RpcMethod<0> for F3GetHead {
const NAME: &'static str = "F3.GetHead";
const PARAM_NAMES: [&'static str; 0] = [];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

type Params = ();
type Ok = F3TipSet;

async fn handle(ctx: Ctx<impl Blockstore>, _: Self::Params) -> Result<Self::Ok, ServerError> {
unimplemented!()
}
}

pub enum F3GetParent {}
impl RpcMethod<1> for F3GetParent {
const NAME: &'static str = "F3.GetParent";
const PARAM_NAMES: [&'static str; 1] = ["tipset"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

type Params = (F3TipSet,);
type Ok = F3TipSet;

async fn handle(
ctx: Ctx<impl Blockstore>,
(ts,): Self::Params,
) -> Result<Self::Ok, ServerError> {
unimplemented!()
}
}

pub enum F3GetPowerTable {}
impl RpcMethod<1> for F3GetPowerTable {
const NAME: &'static str = "F3.GetPowerTable";
const PARAM_NAMES: [&'static str; 1] = ["tipset_key"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

type Params = (F3TipSetKey,);
type Ok = Vec<F3PowerEntry>;

async fn handle(
ctx: Ctx<impl Blockstore>,
(ts,): Self::Params,
) -> Result<Self::Ok, ServerError> {
unimplemented!()
}
}
18 changes: 18 additions & 0 deletions src/rpc/methods/f3/types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2019-2024 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use crate::lotus_json::lotus_json_with_self;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct F3TipSetKey;
lotus_json_with_self!(F3TipSetKey);

#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct F3TipSet;
lotus_json_with_self!(F3TipSet);

#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct F3PowerEntry;
lotus_json_with_self!(F3PowerEntry);
1 change: 1 addition & 0 deletions src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ mod methods {
pub mod chain;
pub mod common;
pub mod eth;
pub mod f3;
pub mod gas;
pub mod miner;
pub mod mpool;
Expand Down

0 comments on commit d70b7fe

Please sign in to comment.