Allow 1 count block request to return 0 blocks #5554
Merged
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.
Issue Addressed
Noted the following bug in ReqResp logic:
RPCError::IncompleteStream
Not having a block or blob is tolerated as per the req resp spec. It's the downstream caller that should decide if the peer should have or not that specific element.
Proposed Changes
Rename
expected_responses
tomax_responses
, as for multiple responses that what the number really represents. The peer is allow to return less than the request count of elements, including 0.Add a new function
expect_exactly_one_response
to differentiate those request where closing the stream before the first element is actually a protocol violation (e.g. status method)I have reversed some of the if else cases, (from
if !condition A else B
toif condition B else A
, but the actual logic is unchanged.Additional Info
Please provide any additional information. For example, future considerations
or information useful for reviewers.