mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2025-04-01 14:06:10 +00:00
add an option to skip old tx seq number
This commit is contained in:
parent
90ae424e3c
commit
67a82412a0
@ -63,7 +63,7 @@ pub trait Rpc {
|
||||
async fn check_file_finalized(&self, tx_seq_or_root: TxSeqOrRoot) -> RpcResult<Option<bool>>;
|
||||
|
||||
#[method(name = "getFileInfo")]
|
||||
async fn get_file_info(&self, data_root: DataRoot) -> RpcResult<Option<FileInfo>>;
|
||||
async fn get_file_info(&self, data_root: DataRoot, skip_old: bool) -> RpcResult<Option<FileInfo>>;
|
||||
|
||||
#[method(name = "getFileInfoByTxSeq")]
|
||||
async fn get_file_info_by_tx_seq(&self, tx_seq: u64) -> RpcResult<Option<FileInfo>>;
|
||||
|
@ -121,7 +121,7 @@ impl RpcServer for RpcServerImpl {
|
||||
) -> RpcResult<Option<SegmentWithProof>> {
|
||||
info!(%data_root, %index, "zgs_downloadSegmentWithProof");
|
||||
|
||||
let tx = try_option!(self.ctx.log_store.get_tx_by_data_root(&data_root).await?);
|
||||
let tx = try_option!(self.ctx.log_store.get_tx_by_data_root(&data_root, false).await?);
|
||||
|
||||
self.get_segment_with_proof_by_tx(tx, index).await
|
||||
}
|
||||
@ -163,10 +163,10 @@ impl RpcServer for RpcServerImpl {
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_file_info(&self, data_root: DataRoot) -> RpcResult<Option<FileInfo>> {
|
||||
async fn get_file_info(&self, data_root: DataRoot, skip_old: bool) -> RpcResult<Option<FileInfo>> {
|
||||
debug!(%data_root, "zgs_getFileInfo");
|
||||
|
||||
let tx = try_option!(self.ctx.log_store.get_tx_by_data_root(&data_root).await?);
|
||||
let tx = try_option!(self.ctx.log_store.get_tx_by_data_root(&data_root, skip_old).await?);
|
||||
|
||||
Ok(Some(self.get_file_info_by_tx(tx).await?))
|
||||
}
|
||||
@ -288,7 +288,7 @@ impl RpcServerImpl {
|
||||
let maybe_tx = self
|
||||
.ctx
|
||||
.log_store
|
||||
.get_tx_by_data_root(&segment.root)
|
||||
.get_tx_by_data_root(&segment.root, false)
|
||||
.await?;
|
||||
|
||||
self.put_segment_with_maybe_tx(segment, maybe_tx).await
|
||||
|
@ -65,14 +65,16 @@ impl Store {
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get_tx_by_data_root(&self, data_root: &DataRoot) -> Result<Option<Transaction>> {
|
||||
pub async fn get_tx_by_data_root(&self, data_root: &DataRoot, skip_old: bool) -> Result<Option<Transaction>> {
|
||||
let root = *data_root;
|
||||
|
||||
let res = self.spawn(move |store| store.get_tx_by_data_root(&root))
|
||||
.await?;
|
||||
if let Some(tx) = res.clone() {
|
||||
if self.store.check_tx_pruned(tx.seq)? {
|
||||
return Ok(None);
|
||||
if skip_old {
|
||||
if let Some(tx) = res.clone() {
|
||||
if self.store.check_tx_pruned(tx.seq)? {
|
||||
return Ok(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(res)
|
||||
|
Loading…
Reference in New Issue
Block a user