@@ -253,7 +253,7 @@ pub(crate) fn read_output_sweeper(
253253 kv_store,
254254 logger. clone ( ) ,
255255 ) ;
256- OutputSweeper :: read ( & mut reader, args) . map_err ( |e| {
256+ OutputSweeper :: read_with_kv_store_sync ( & mut reader, args) . map_err ( |e| {
257257 log_error ! ( logger, "Failed to deserialize OutputSweeper: {}" , e) ;
258258 std:: io:: Error :: new ( std:: io:: ErrorKind :: InvalidData , "Failed to deserialize OutputSweeper" )
259259 } )
@@ -277,81 +277,81 @@ pub(crate) fn migrate_deprecated_spendable_outputs<L: Deref>(
277277where
278278 L :: Target : LdkLogger ,
279279{
280- let best_block = sweeper. current_best_block ( ) ;
281-
282- for stored_key in kv_store. list (
283- DEPRECATED_SPENDABLE_OUTPUT_INFO_PERSISTENCE_PRIMARY_NAMESPACE ,
284- DEPRECATED_SPENDABLE_OUTPUT_INFO_PERSISTENCE_SECONDARY_NAMESPACE ,
285- ) ? {
286- let mut reader = Cursor :: new ( kv_store. read (
287- DEPRECATED_SPENDABLE_OUTPUT_INFO_PERSISTENCE_PRIMARY_NAMESPACE ,
288- DEPRECATED_SPENDABLE_OUTPUT_INFO_PERSISTENCE_SECONDARY_NAMESPACE ,
289- & stored_key,
290- ) ?) ;
291- let output = DeprecatedSpendableOutputInfo :: read ( & mut reader) . map_err ( |e| {
292- log_error ! ( logger, "Failed to deserialize SpendableOutputInfo: {}" , e) ;
293- std:: io:: Error :: new (
294- std:: io:: ErrorKind :: InvalidData ,
295- "Failed to deserialize SpendableOutputInfo" ,
296- )
297- } ) ?;
298- let descriptors = vec ! [ output. descriptor. clone( ) ] ;
299- let spend_delay = Some ( best_block. height + 2 ) ;
300- sweeper
301- . track_spendable_outputs ( descriptors, output. channel_id , true , spend_delay)
302- . map_err ( |_| {
303- log_error ! ( logger, "Failed to track spendable outputs. Aborting migration, will retry in the future." ) ;
304- std:: io:: Error :: new (
305- std:: io:: ErrorKind :: InvalidData ,
306- "Failed to track spendable outputs. Aborting migration, will retry in the future." ,
307- )
308- } ) ?;
309-
310- if let Some ( tracked_spendable_output) =
311- sweeper. tracked_spendable_outputs ( ) . iter ( ) . find ( |o| o. descriptor == output. descriptor )
312- {
313- match tracked_spendable_output. status {
314- OutputSpendStatus :: PendingInitialBroadcast { delayed_until_height } => {
315- if delayed_until_height == spend_delay {
316- kv_store. remove (
317- DEPRECATED_SPENDABLE_OUTPUT_INFO_PERSISTENCE_PRIMARY_NAMESPACE ,
318- DEPRECATED_SPENDABLE_OUTPUT_INFO_PERSISTENCE_SECONDARY_NAMESPACE ,
319- & stored_key,
320- false ,
321- ) ?;
322- } else {
323- debug_assert ! ( false , "Unexpected status in OutputSweeper migration." ) ;
324- log_error ! ( logger, "Unexpected status in OutputSweeper migration." ) ;
325- return Err ( std:: io:: Error :: new (
326- std:: io:: ErrorKind :: Other ,
327- "Failed to migrate OutputSweeper state." ,
328- ) ) ;
329- }
330- } ,
331- _ => {
332- debug_assert ! ( false , "Unexpected status in OutputSweeper migration." ) ;
333- log_error ! ( logger, "Unexpected status in OutputSweeper migration." ) ;
334- return Err ( std:: io:: Error :: new (
335- std:: io:: ErrorKind :: Other ,
336- "Failed to migrate OutputSweeper state." ,
337- ) ) ;
338- } ,
339- }
340- } else {
341- debug_assert ! (
342- false ,
343- "OutputSweeper failed to track and persist outputs during migration."
344- ) ;
345- log_error ! (
346- logger,
347- "OutputSweeper failed to track and persist outputs during migration."
348- ) ;
349- return Err ( std:: io:: Error :: new (
350- std:: io:: ErrorKind :: Other ,
351- "Failed to migrate OutputSweeper state." ,
352- ) ) ;
353- }
354- }
280+ // let best_block = sweeper.current_best_block();
281+
282+ // for stored_key in kv_store.list(
283+ // DEPRECATED_SPENDABLE_OUTPUT_INFO_PERSISTENCE_PRIMARY_NAMESPACE,
284+ // DEPRECATED_SPENDABLE_OUTPUT_INFO_PERSISTENCE_SECONDARY_NAMESPACE,
285+ // )? {
286+ // let mut reader = Cursor::new(kv_store.read(
287+ // DEPRECATED_SPENDABLE_OUTPUT_INFO_PERSISTENCE_PRIMARY_NAMESPACE,
288+ // DEPRECATED_SPENDABLE_OUTPUT_INFO_PERSISTENCE_SECONDARY_NAMESPACE,
289+ // &stored_key,
290+ // )?);
291+ // let output = DeprecatedSpendableOutputInfo::read(&mut reader).map_err(|e| {
292+ // log_error!(logger, "Failed to deserialize SpendableOutputInfo: {}", e);
293+ // std::io::Error::new(
294+ // std::io::ErrorKind::InvalidData,
295+ // "Failed to deserialize SpendableOutputInfo",
296+ // )
297+ // })?;
298+ // let descriptors = vec![output.descriptor.clone()];
299+ // let spend_delay = Some(best_block.height + 2);
300+ // sweeper
301+ // .track_spendable_outputs(descriptors, output.channel_id, true, spend_delay)
302+ // .map_err(|_| {
303+ // log_error!(logger, "Failed to track spendable outputs. Aborting migration, will retry in the future.");
304+ // std::io::Error::new(
305+ // std::io::ErrorKind::InvalidData,
306+ // "Failed to track spendable outputs. Aborting migration, will retry in the future.",
307+ // )
308+ // })?;
309+
310+ // if let Some(tracked_spendable_output) =
311+ // sweeper.tracked_spendable_outputs().iter().find(|o| o.descriptor == output.descriptor)
312+ // {
313+ // match tracked_spendable_output.status {
314+ // OutputSpendStatus::PendingInitialBroadcast { delayed_until_height } => {
315+ // if delayed_until_height == spend_delay {
316+ // kv_store.remove(
317+ // DEPRECATED_SPENDABLE_OUTPUT_INFO_PERSISTENCE_PRIMARY_NAMESPACE,
318+ // DEPRECATED_SPENDABLE_OUTPUT_INFO_PERSISTENCE_SECONDARY_NAMESPACE,
319+ // &stored_key,
320+ // false,
321+ // )?;
322+ // } else {
323+ // debug_assert!(false, "Unexpected status in OutputSweeper migration.");
324+ // log_error!(logger, "Unexpected status in OutputSweeper migration.");
325+ // return Err(std::io::Error::new(
326+ // std::io::ErrorKind::Other,
327+ // "Failed to migrate OutputSweeper state.",
328+ // ));
329+ // }
330+ // },
331+ // _ => {
332+ // debug_assert!(false, "Unexpected status in OutputSweeper migration.");
333+ // log_error!(logger, "Unexpected status in OutputSweeper migration.");
334+ // return Err(std::io::Error::new(
335+ // std::io::ErrorKind::Other,
336+ // "Failed to migrate OutputSweeper state.",
337+ // ));
338+ // },
339+ // }
340+ // } else {
341+ // debug_assert!(
342+ // false,
343+ // "OutputSweeper failed to track and persist outputs during migration."
344+ // );
345+ // log_error!(
346+ // logger,
347+ // "OutputSweeper failed to track and persist outputs during migration."
348+ // );
349+ // return Err(std::io::Error::new(
350+ // std::io::ErrorKind::Other,
351+ // "Failed to migrate OutputSweeper state.",
352+ // ));
353+ // }
354+ // }
355355
356356 Ok ( ( ) )
357357}
0 commit comments