libbitcoin / libbitcoin-network

Bitcoin P2P Network Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inbound channels do not close immediately on peer drop.

evoskuil opened this issue · comments

Close does occur upon process close and when self drops (for expiration).

This is a consequence of the block protocols, owing to their reorg subscriptions capturing self. The reorg subscription lasts for the network lifetime and as such is released only on shutdown.

This is limited to inbound channels in the above testing only because the node that is connecting outbound is pulling in new blocks and therefore receives reorg notifications while stopped, resulting in the clearing of the subscription - and the node connected on an inbound channel is sending blocks out and therefore not receiving any reorg notifications.

This issue lasts only as long as the time between reorg notifications. So a live node will fail to clear dropped connections until it encounters the next valid block assigned to the main chain. This presents a DoS vector although it is no more severe than others in v3, so this is not a release blocker.

Could create an error code dedicated to subscriber clearing, such as error::ignore. The downside is that all subscribers would need to handle the code (and resubscribe vs. fail). The alternative is to send null object pointers along with a success code. This allows the documentation to simply require subscribers check for data existence with any a success code.

It would be sent by any object stop where the object captured itself on an external subscriber (like channel->node).

Implemented using null pointer sentinels.