propagate context to message read and write in p2p protocols #840
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adjusts protobuf message read and write calls to use context for cancelation, by either adding it or replacing with timeout variant. More cancelation control is provided with context, so functions with timeout are removed. These changes may improve overall communication in not perfect network conditions and with overloaded peers.
Since pseudosettle is changed to use context in handler while reading a message, TestPayment was very flaky, as the context cancled in Pay method would cancel the context passed to the handler through streamtest Recorder. Two changes were made to fix this. First not to couple client call context with handler context in streamtest Recorder, and the second is are improvements to TestPayment to check for record error and also to synchronize observer call with a channel.