]> git.bitcoin.ninja Git - rust-lightning/commit
Fix (and DRY) the conditionals before calling `peer_disconnected`
authorMatt Corallo <git@bluematt.me>
Wed, 15 Feb 2023 01:13:57 +0000 (01:13 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 21 Feb 2023 17:12:27 +0000 (17:12 +0000)
commit3554678e9c778c8893fc091a6566240a313998f4
treea0a3017a2134c7fd32a9ab68edf1b215e3d0165c
parent2edb3f198302dc876aeb00e020b1b4cbd219b453
Fix (and DRY) the conditionals before calling `peer_disconnected`

If we have a peer that sends a non-`Init` first message, we'll call
`peer_disconnected` without ever having called `peer_connected`
(which has to wait until we have an `Init` message). This is a
violation of our API guarantees, though should generally not be an
issue.

Because this bug was repeated in a few places, we also take this
opportunity to DRY up the logic which checks the peer state before
calling `peer_disconnected`.

Found by the new `ChannelManager` assertions and the
`full_stack_target` fuzzer.
lightning/src/ln/peer_handler.rs