mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2025-04-02 22:45:41 +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>>;
|
async fn check_file_finalized(&self, tx_seq_or_root: TxSeqOrRoot) -> RpcResult<Option<bool>>;
|
||||||
|
|
||||||
#[method(name = "getFileInfo")]
|
#[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")]
|
#[method(name = "getFileInfoByTxSeq")]
|
||||||
async fn get_file_info_by_tx_seq(&self, tx_seq: u64) -> RpcResult<Option<FileInfo>>;
|
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>> {
|
) -> RpcResult<Option<SegmentWithProof>> {
|
||||||
info!(%data_root, %index, "zgs_downloadSegmentWithProof");
|
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
|
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");
|
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?))
|
Ok(Some(self.get_file_info_by_tx(tx).await?))
|
||||||
}
|
}
|
||||||
@ -288,7 +288,7 @@ impl RpcServerImpl {
|
|||||||
let maybe_tx = self
|
let maybe_tx = self
|
||||||
.ctx
|
.ctx
|
||||||
.log_store
|
.log_store
|
||||||
.get_tx_by_data_root(&segment.root)
|
.get_tx_by_data_root(&segment.root, false)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
self.put_segment_with_maybe_tx(segment, maybe_tx).await
|
self.put_segment_with_maybe_tx(segment, maybe_tx).await
|
||||||
|
@ -65,14 +65,16 @@ impl Store {
|
|||||||
.await
|
.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 root = *data_root;
|
||||||
|
|
||||||
let res = self.spawn(move |store| store.get_tx_by_data_root(&root))
|
let res = self.spawn(move |store| store.get_tx_by_data_root(&root))
|
||||||
.await?;
|
.await?;
|
||||||
if let Some(tx) = res.clone() {
|
if skip_old {
|
||||||
if self.store.check_tx_pruned(tx.seq)? {
|
if let Some(tx) = res.clone() {
|
||||||
return Ok(None);
|
if self.store.check_tx_pruned(tx.seq)? {
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(res)
|
Ok(res)
|
||||||
|
Loading…
Reference in New Issue
Block a user