mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-19 05:44:12 +01:00
topology: Two off-by-one error when catching up with the blockchain
There are two very hard problems in software engineering: 1. Off-by-one errors In this case we were rolling back further than needed and we were starting the catchup one block further than expected. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
4da3d407b4
commit
9ab28d1659
@ -573,7 +573,7 @@ static void get_init_blockhash(struct bitcoind *bitcoind, u32 blockcount,
|
||||
|
||||
/* Rollback to the given blockheight, so we start track
|
||||
* correctly again */
|
||||
wallet_blocks_rollback(topo->wallet, topo->first_blocknum - 1);
|
||||
wallet_blocks_rollback(topo->wallet, topo->first_blocknum);
|
||||
|
||||
/* Get up to speed with topology. */
|
||||
bitcoind_getblockhash(bitcoind, topo->first_blocknum,
|
||||
|
@ -2027,7 +2027,7 @@ void wallet_block_remove(struct wallet *w, struct block *b)
|
||||
void wallet_blocks_rollback(struct wallet *w, u32 height)
|
||||
{
|
||||
sqlite3_stmt *stmt = db_prepare(w->db, "DELETE FROM blocks "
|
||||
"WHERE height >= ?");
|
||||
"WHERE height > ?");
|
||||
sqlite3_bind_int(stmt, 1, height);
|
||||
db_exec_prepared(w->db, stmt);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user