The motivation for this PR is to reduce the scope of cs_main locking in misbehavior logic. It is the first set of commits from a larger branch to move the misbehavior data out of CNodeState and into a new struct that doesn’t take cs_main.
There are some very minor behavior changes in this branch, such as:
- Not checking for discouragement/disconnect in
ProcessMessages()
(and instead relying on the following check inSendMessages()
) - Checking for discouragement/disconnect as the first action in
SendMessages()
(and not doing ping message sending first) - Continuing through
SendMessages()
ifMaybeDiscourageAndDisconnect()
doesn’t disconnect the peer (rather than dropping out ofSendMessages()