Skip to content

Commit

Permalink
rpc: add method to get the sub dag index of a node
Browse files Browse the repository at this point in the history
  • Loading branch information
daltoncoder committed May 29, 2024
1 parent 0eb3010 commit 2677ca6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/rpc/src/api/flk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ pub trait FleekApi {
#[method(name = "get_last_epoch_hash")]
async fn get_last_epoch_hash(&self) -> RpcResult<([u8; 32], Epoch)>;

#[method(name = "get_sub_dag_index")]
async fn get_sub_dag_index(&self) -> RpcResult<(u64, Epoch)>;

#[method(name = "send_txn")]
async fn send_txn(&self, tx: TransactionRequest) -> RpcResult<()>;

Expand Down
8 changes: 8 additions & 0 deletions core/rpc/src/logic/flk_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,14 @@ impl<C: Collection> FleekApiServer for FleekApi<C> {
))
}

async fn get_sub_dag_index(&self) -> RpcResult<(u64, Epoch)> {
let sub_dag_index = match self.data.query_runner.get_metadata(&Metadata::SubDagIndex) {
Some(Value::SubDagIndex(index)) => index,
_ => 0,
};
Ok((sub_dag_index, self.data.query_runner.get_epoch_info().epoch))
}

async fn send_txn(&self, tx: TransactionRequest) -> RpcResult<()> {
Ok(self
.data
Expand Down

0 comments on commit 2677ca6

Please sign in to comment.