]> git.bitcoin.ninja Git - rust-lightning/commit
Correctly update the last block hash on disconnect
authorJeffrey Czyz <jkczyz@gmail.com>
Thu, 4 Mar 2021 02:33:54 +0000 (18:33 -0800)
committerJeffrey Czyz <jkczyz@gmail.com>
Fri, 5 Mar 2021 03:10:57 +0000 (19:10 -0800)
commit390ff52e68d13dea32f648d58b745fd6a7d5c7f1
treeb688ea24a0ff74aafc68d0445d805d53b68ab72f
parent1c948a57666bc0d2b6e9ac4926df2ed655741227
Correctly update the last block hash on disconnect

When a block is disconnected, the hash of the disconnected block was
used to update the last connected block. However, this amounts to a
no-op because these hashes should be equal. Successive disconnections
would update the hash but leave it one block off.

Normally, this not a problem because the last block_disconnected should
be followed by block_connected since the former is triggered by a chain
re-org. However, this assumes the user calls the API correctly and that
no failure occurs that would prevent block_connected from being called
(e.g., if fetching the connected block fails).

Instead, update the last block hash with the disconnected block's
previous block hash.
lightning/src/chain/channelmonitor.rs
lightning/src/ln/channelmanager.rs