wallet: Lowerbound the rescan by going at most back to LNs origin

Repeated crashes could result in the `last_processed_block` variable being
pushed further and further into the past (in some cases going as far back as
scanning blocks from 2012...). This is a stop-gap solution that just lower
bounds the value to what is the first possible block we might be interested in
LN, until we have the 0-rescan fix I'm working on.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker 2018-04-08 12:26:08 +02:00 committed by Rusty Russell
parent a121b7dbc3
commit ba3ceb2abf
1 changed files with 4 additions and 0 deletions

View File

@ -826,6 +826,10 @@ u32 wallet_first_blocknum(struct wallet *w, u32 first_possible)
first_utxo = db_get_intvar(w->db, "last_processed_block", UINT32_MAX);
#endif
/* Never go below the start of the Lightning Network */
if (first_utxo < first_possible)
first_utxo = first_possible;
if (first_utxo < first_channel)
return first_utxo;
else