@@ -87,6 +87,17 @@ struct chain_event {
8787 bool we_opened ;
8888};
8989
90+ /* Every 10 seconds, give progress indication */
91+ static bool give_progress (struct timemono * prev )
92+ {
93+ struct timemono now = time_mono ();
94+ if (time_to_sec (timemono_between (now , * prev )) >= 10 ) {
95+ * prev = now ;
96+ return true;
97+ }
98+ return false;
99+ }
100+
90101static struct chain_event * stmt2chain_event (const tal_t * ctx , struct db_stmt * stmt )
91102{
92103 struct chain_event * e = tal (ctx , struct chain_event );
@@ -354,6 +365,7 @@ void migrate_from_account_db(struct lightningd *ld, struct db *db)
354365 size_t descriptions_migrated = 0 ;
355366 struct db_stmt * stmt ;
356367 int version ;
368+ struct timemono prev ;
357369
358370 /* Initialize wait indices: we're going to use it to generate ids. */
359371 load_indexes (db , ld -> indexes );
@@ -379,6 +391,7 @@ void migrate_from_account_db(struct lightningd *ld, struct db *db)
379391 }
380392
381393 /* Load events */
394+ prev = time_mono ();
382395 db_begin_transaction (account_db );
383396 version = db_get_version (account_db );
384397 /* -1 means empty database (Postgres usually). */
@@ -396,6 +409,8 @@ void migrate_from_account_db(struct lightningd *ld, struct db *db)
396409 db_commit_transaction (account_db );
397410 tal_free (account_db );
398411
412+ log_debug (ld -> log , "Transferring %zu chain_events" ,
413+ tal_count (chain_events ));
399414 for (size_t i = 0 ; i < tal_count (chain_events ); i ++ ) {
400415 const struct chain_event * ev = chain_events [i ];
401416 struct mvt_account_id * account = tal (ev , struct mvt_account_id );
@@ -486,8 +501,12 @@ void migrate_from_account_db(struct lightningd *ld, struct db *db)
486501 wallet_datastore_save_utxo_description (db , & ev -> outpoint , ev -> desc );
487502 descriptions_migrated ++ ;
488503 }
504+ if (give_progress (& prev ))
505+ log_info (ld -> log , "Inserted %zu/%zu chain_events" , i , tal_count (chain_events ));
489506 }
490507
508+ log_debug (ld -> log , "Transferring %zu channel_events" ,
509+ tal_count (channel_events ));
491510 for (size_t i = 0 ; i < tal_count (channel_events ); i ++ ) {
492511 const struct channel_event * ev = channel_events [i ];
493512 struct mvt_account_id * account = tal (ev , struct mvt_account_id );
@@ -546,6 +565,8 @@ void migrate_from_account_db(struct lightningd *ld, struct db *db)
546565 wallet_datastore_save_payment_description (db , ev -> payment_id , ev -> desc );
547566 descriptions_migrated ++ ;
548567 }
568+ if (give_progress (& prev ))
569+ log_info (ld -> log , "Inserted %zu/%zu channel_events" , i , tal_count (channel_events ));
549570 }
550571
551572 log_info (ld -> log , "bookkeeper migration complete: migrated %zu chainmoves, %zu channelmoves, %zu descriptions" ,
0 commit comments