-
Notifications
You must be signed in to change notification settings - Fork 407
[Peers] Tech Debt: Revisit InitialSyncState behavior and object relationships #708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hmm, do you have a concrete design in mind? We don't get a lot of feedback from the user (by design - the API mirrors exactly what the user can get from the system in a cross-platform manner - roughly POSIX), so about the only thing we know is when the write buffer is empty. |
I had to look at this part of the code to track down some existing bugs as part of #714 and I think I came up with a reasonable separation that cleans it up. There are two code smells that the design should address:
These result in code that knows too much about implementation details while filling the queue to the soft limit. A cleaner design might look something like this:
This trait would be implemented by a new The This could be paired with
A design like this also addresses the testability of the This object can also be moved into the |
Ah, you're suggesting basically just abstract out the state into some object instead of forcing a certain API - sure, that sounds good too, as long as its just as easy for users to implement (and hard to mis-use, which is the main feature of the current design that something abstract doesn't capture - the "obvious" way to implement would be a copy of the state which just DoS'es yourself). |
The sync message generation and subsequent Peer state updates are done as a side effect of flushing the outbound queue.
This could use a cleaner design and is hard to test through the front door of the PeerManager.
Should the OutboundQueue be separated into a SocketDescriptorWriter object that handles the sync generation post-Init so it can be tested?
Should the Peer state updates that happen as a side-effect be replaced by turning InitSyncState into a real object that can be tested in isolation?
The text was updated successfully, but these errors were encountered: