]> 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 23:45:13 +0000 (15:45 -0800)
commit873014875c9a9797bd1e062e6b1cfacd9f958b97
treee2f9b599cde5cb47105514912556401f3ffe6bec
parent035dda67080431f460c18bd1087e511c0ab778ec
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