From a782cf2d54a8b7ec6a96c5b18371d748dc406f4d Mon Sep 17 00:00:00 2001 From: MiniFrenchBread <103425574+MiniFrenchBread@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:28:05 +0800 Subject: [PATCH] feat: add all_shards in admin_getFileLocation (#138) --- node/rpc/src/admin/api.rs | 6 +++++- node/rpc/src/admin/impl.rs | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/node/rpc/src/admin/api.rs b/node/rpc/src/admin/api.rs index 260409e..d26962c 100644 --- a/node/rpc/src/admin/api.rs +++ b/node/rpc/src/admin/api.rs @@ -40,5 +40,9 @@ pub trait Rpc { async fn get_peers(&self) -> RpcResult>; #[method(name = "getFileLocation")] - async fn get_file_location(&self, tx_seq: u64) -> RpcResult>>; + async fn get_file_location( + &self, + tx_seq: u64, + all_shards: bool, + ) -> RpcResult>>; } diff --git a/node/rpc/src/admin/impl.rs b/node/rpc/src/admin/impl.rs index afabe7f..8ec5b4f 100644 --- a/node/rpc/src/admin/impl.rs +++ b/node/rpc/src/admin/impl.rs @@ -185,7 +185,11 @@ impl RpcServer for RpcServerImpl { .collect()) } - async fn get_file_location(&self, tx_seq: u64) -> RpcResult>> { + async fn get_file_location( + &self, + tx_seq: u64, + all_shards: bool, + ) -> RpcResult>> { let tx = match self.ctx.log_store.get_tx_by_seq_number(tx_seq).await? { Some(tx) => tx, None => { @@ -221,7 +225,7 @@ impl RpcServer for RpcServerImpl { shard_config: shard_config.unwrap(), }) .collect(); - if all_shards_available(info.iter().map(|info| info.shard_config).collect()) { + if all_shards && all_shards_available(info.iter().map(|info| info.shard_config).collect()) { Ok(Some(info)) } else { Ok(None)