Skip to content

Commit b217e99

Browse files
committed
Drop redundant tokio::timeouts for VSS IO
Now that we rely on `reqwest` v0.12.* retry logic as well as client-side timeouts, we can address the remaining TODOs here and simply drop the redundant `tokio::timeout`s we previously added as a safeguard to blocking tasks (even though in the worst cases we saw they never actually fired).
1 parent 7ceb65a commit b217e99

File tree

1 file changed

+4
-42
lines changed

1 file changed

+4
-42
lines changed

src/io/vss_store.rs

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use std::panic::RefUnwindSafe;
1313
use std::pin::Pin;
1414
use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering};
1515
use std::sync::{Arc, Mutex};
16-
use std::time::Duration;
1716

1817
use bitcoin::hashes::{sha256, Hash, HashEngine, Hmac, HmacEngine};
1918
use lightning::io::{self, Error, ErrorKind};
@@ -35,7 +34,6 @@ use crate::io::utils::check_namespace_key_validity;
3534
// We set this to a small number of threads that would still allow to make some progress if one
3635
// would hit a blocking case
3736
const INTERNAL_RUNTIME_WORKERS: usize = 2;
38-
const VSS_IO_TIMEOUT: Duration = Duration::from_secs(5);
3937

4038
/// A [`KVStoreSync`] implementation that writes to and reads from a [VSS](https://github.com/lightningdevkit/vss-server/blob/main/README.md) backend.
4139
pub struct VssStore {
@@ -118,16 +116,7 @@ impl KVStoreSync for VssStore {
118116
let inner = Arc::clone(&self.inner);
119117
let fut =
120118
async move { inner.read_internal(primary_namespace, secondary_namespace, key).await };
121-
// TODO: We could drop the timeout here once we ensured vss-client's Retry logic always
122-
// times out.
123-
tokio::task::block_in_place(move || {
124-
internal_runtime.block_on(async move {
125-
tokio::time::timeout(VSS_IO_TIMEOUT, fut).await.map_err(|_| {
126-
let msg = "VssStore::read timed out";
127-
Error::new(ErrorKind::Other, msg)
128-
})
129-
})?
130-
})
119+
tokio::task::block_in_place(move || internal_runtime.block_on(fut))
131120
}
132121

133122
fn write(
@@ -157,16 +146,7 @@ impl KVStoreSync for VssStore {
157146
)
158147
.await
159148
};
160-
// TODO: We could drop the timeout here once we ensured vss-client's Retry logic always
161-
// times out.
162-
tokio::task::block_in_place(move || {
163-
internal_runtime.block_on(async move {
164-
tokio::time::timeout(VSS_IO_TIMEOUT, fut).await.map_err(|_| {
165-
let msg = "VssStore::write timed out";
166-
Error::new(ErrorKind::Other, msg)
167-
})
168-
})?
169-
})
149+
tokio::task::block_in_place(move || internal_runtime.block_on(fut))
170150
}
171151

172152
fn remove(
@@ -195,16 +175,7 @@ impl KVStoreSync for VssStore {
195175
)
196176
.await
197177
};
198-
// TODO: We could drop the timeout here once we ensured vss-client's Retry logic always
199-
// times out.
200-
tokio::task::block_in_place(move || {
201-
internal_runtime.block_on(async move {
202-
tokio::time::timeout(VSS_IO_TIMEOUT, fut).await.map_err(|_| {
203-
let msg = "VssStore::remove timed out";
204-
Error::new(ErrorKind::Other, msg)
205-
})
206-
})?
207-
})
178+
tokio::task::block_in_place(move || internal_runtime.block_on(fut))
208179
}
209180

210181
fn list(&self, primary_namespace: &str, secondary_namespace: &str) -> io::Result<Vec<String>> {
@@ -217,16 +188,7 @@ impl KVStoreSync for VssStore {
217188
let secondary_namespace = secondary_namespace.to_string();
218189
let inner = Arc::clone(&self.inner);
219190
let fut = async move { inner.list_internal(primary_namespace, secondary_namespace).await };
220-
// TODO: We could drop the timeout here once we ensured vss-client's Retry logic always
221-
// times out.
222-
tokio::task::block_in_place(move || {
223-
internal_runtime.block_on(async move {
224-
tokio::time::timeout(VSS_IO_TIMEOUT, fut).await.map_err(|_| {
225-
let msg = "VssStore::list timed out";
226-
Error::new(ErrorKind::Other, msg)
227-
})
228-
})?
229-
})
191+
tokio::task::block_in_place(move || internal_runtime.block_on(fut))
230192
}
231193
}
232194

0 commit comments

Comments
 (0)