Skip to content

Commit d72d193

Browse files
committed
return io::error
1 parent 4678f85 commit d72d193

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

lightning-persister/src/fs_store.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Objects related to [`FilesystemStore`] live here.
22
use crate::utils::{check_namespace_key_validity, is_valid_kvstore_str};
33

4-
use lightning::util::async_poll::AsyncResult;
4+
use lightning::util::async_poll::{AsyncResult, AsyncResultType};
55
use lightning::util::persist::{KVStore, MigratableKVStore};
66
use lightning::util::string::PrintableString;
77

@@ -333,7 +333,7 @@ impl KVStore for FilesystemStore {
333333

334334
fn write_async(
335335
&self, primary_namespace: &str, secondary_namespace: &str, key: &str, buf: &[u8],
336-
) -> AsyncResult<'static, ()> {
336+
) -> AsyncResultType<'static, (), lightning::io::Error> {
337337
todo!()
338338
}
339339
}

lightning/src/util/async_poll.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ pub(crate) fn dummy_waker() -> Waker {
9999
/// A type alias for a future that returns a result of type T.
100100
pub type AsyncResult<'a, T> = Pin<Box<dyn Future<Output = Result<T, ()>> + 'a + Send>>;
101101

102+
/// A type alias for a future that returns a result of type T with error type V.
103+
pub type AsyncResultType<'a, T, V> = Pin<Box<dyn Future<Output = Result<T, V>> + 'a + Send>>;
104+
102105
/// A type alias for a future that returns a result of type T.
103106
pub trait FutureSpawner: Send + Sync + 'static {
104107
/// Spawns a future on a runtime.

lightning/src/util/persist.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use crate::sync::Arc;
3232
use crate::util::logger::Logger;
3333
use crate::util::ser::{Readable, ReadableArgs, Writeable};
3434

35-
use super::async_poll::AsyncResult;
35+
use super::async_poll::{AsyncResult, AsyncResultType};
3636

3737
/// The alphabet of characters allowed for namespaces and keys.
3838
pub const KVSTORE_NAMESPACE_KEY_ALPHABET: &str =
@@ -143,7 +143,7 @@ pub trait KVStore {
143143
/// Asynchronously persists the given data under the given `key`.
144144
fn write_async(
145145
&self, primary_namespace: &str, secondary_namespace: &str, key: &str, buf: &[u8],
146-
) -> AsyncResult<'static, ()>;
146+
) -> AsyncResultType<'static, (), io::Error>;
147147
/// Removes any data that had previously been persisted under the given `key`.
148148
///
149149
/// If the `lazy` flag is set to `true`, the backend implementation might choose to lazily
@@ -284,6 +284,7 @@ impl<ChannelSigner: EcdsaChannelSigner, K: KVStore + ?Sized + Sync + Send + 'sta
284284
&encoded,
285285
)
286286
.await
287+
.map_err(|_| ())
287288
})
288289
}
289290

@@ -303,6 +304,7 @@ impl<ChannelSigner: EcdsaChannelSigner, K: KVStore + ?Sized + Sync + Send + 'sta
303304
&encoded,
304305
)
305306
.await
307+
.map_err(|_| ())
306308
})
307309
}
308310

@@ -843,6 +845,7 @@ where
843845
&monitor_bytes,
844846
)
845847
.await
848+
.map_err(|_| ())
846849
}
847850

848851
/// Persists a channel update, writing only the update to the parameterized [`KVStore`] if possible.
@@ -873,6 +876,7 @@ where
873876
&update,
874877
)
875878
.await
879+
.map_err(|_| ())
876880
} else {
877881
// In case of channel-close monitor update, we need to read old monitor before persisting
878882
// the new one in order to determine the cleanup range.

0 commit comments

Comments
 (0)