-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(p2p): open peer before sending session ack
This commit addresses an edge case bug whereby one peer finishes the handshake before the other and begins sending regular packets. It is possible for the other peer to attempt to process these regular packets while it is executing asynchronous code to complete the handshake, which results in the regular packets being discarded as "unsolicited." The key change is marking the peer as `opened` after receiving and authenticating the `SessionInitPacket`, as well as validating the peer (not banned, not ourselves, not an incompatible version, etc...), but before we send the `SessionAckPacket`. This ensures that we are ready to accept packets before the peer is ready to send packets. This involves restructuring the open flow, splitting it into two methods (`beginOpen` and `completeOpen`). The first establishes the socket connection and begins the handshake. The second marks the peer as `opened` and compelts the handshake. In between we validate the peer, and afterwards we perform the routine for newly opened peers including sharing and asking for open orders. Fixes #839.
- Loading branch information
Showing
5 changed files
with
224 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.