Refactor inbound substream logic with async (#1325)

## Issue Addressed
#1112 

The logic is slightly different but still valid wrt to error handling.
- Inbound state is either Busy with a future that return the subtream (and info about the processing)
- The state machine works as follows:
  - `Idle` with pending responses => `Busy`
  - `Busy` => finished ? if so and there are new pending responses then `Busy`, if not then `Idle`
               => not finished remains `Busy`
- Add an `InboundInfo` for readability
- Other stuff:
  - Close inbound substreams when all expected responses are sent
  - Remove the error variants from `RPCCodedResponse` and use the codes instead
  - Fix various spelling mistakes because I got sloppy last time

Sorry for the delay

Co-authored-by: Age Manning <Age@AgeManning.com>
This commit is contained in:
divma
2020-07-23 12:30:43 +00:00
parent 3c4daec9af
commit ba10c80633
7 changed files with 232 additions and 520 deletions

View File

@@ -256,11 +256,8 @@ impl<TSpec: EthSpec> Behaviour<TSpec> {
error: RPCResponseErrorCode,
reason: String,
) {
self.eth2_rpc.send_response(
peer_id,
id,
RPCCodedResponse::from_error_code(error, reason),
)
self.eth2_rpc
.send_response(peer_id, id, RPCCodedResponse::Error(error, reason.into()))
}
/* Peer management functions */