feat: timeout on block/stat
this wasn't actually needed to pass the test, unsure why.
This commit is contained in:
parent
fbe90ab8ec
commit
62e0986c41
@ -211,6 +211,7 @@ async fn rm_query<T: IpfsTypes>(
|
|||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct StatQuery {
|
pub struct StatQuery {
|
||||||
arg: String,
|
arg: String,
|
||||||
|
timeout: Option<StringSerialized<humantime::Duration>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
@ -225,7 +226,13 @@ async fn stat_query<T: IpfsTypes>(
|
|||||||
query: StatQuery,
|
query: StatQuery,
|
||||||
) -> Result<impl Reply, Rejection> {
|
) -> Result<impl Reply, Rejection> {
|
||||||
let cid: Cid = query.arg.parse().map_err(StringError::from)?;
|
let cid: Cid = query.arg.parse().map_err(StringError::from)?;
|
||||||
let block = ipfs.get_block(&cid).await.map_err(StringError::from)?;
|
let block = ipfs
|
||||||
|
.get_block(&cid)
|
||||||
|
.maybe_timeout(query.timeout.map(StringSerialized::into_inner))
|
||||||
|
.await
|
||||||
|
.map_err(StringError::from)?
|
||||||
|
.map_err(StringError::from)?;
|
||||||
|
|
||||||
let response = StatResponse {
|
let response = StatResponse {
|
||||||
key: query.arg,
|
key: query.arg,
|
||||||
size: block.data().len(),
|
size: block.data().len(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user