Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
avoid explicit Into::into for error types where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
drahnr committed Aug 7, 2020
1 parent 57bd7ca commit 4f72fc1
Showing 1 changed file with 19 additions and 25 deletions.
44 changes: 19 additions & 25 deletions node/network/availability-distribution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ enum Error {
RuntimeApi(RuntimeApiError),
#[from]
ChainApi(ChainApiError),

Logic,
}

type Result<T> = std::result::Result<T, Error>;
Expand Down Expand Up @@ -886,9 +884,7 @@ where
.map_err::<Error, _>(Into::into)?;

let all_para_ids: Vec<_> = rx
.await
.map_err::<Error, _>(Into::into)?
.map_err::<Error, _>(Into::into)?;
.await??;

let occupied_para_ids = all_para_ids
.into_iter()
Expand Down Expand Up @@ -985,10 +981,8 @@ where
relay_parent,
RuntimeApiRequest::CandidatePendingAvailability(para, tx),
)))
.await
.map_err::<Error, _>(Into::into)?;
rx.await
.map_err::<Error, _>(Into::into)?
.await?;
rx.await?
.map_err::<Error, _>(Into::into)
}

Expand All @@ -1007,10 +1001,8 @@ where
));

ctx.send_message(query_validators)
.await
.map_err::<Error, _>(Into::into)?;
rx.await
.map_err::<Error, _>(Into::into)?
.await?;
rx.await?
.map_err::<Error, _>(Into::into)
}

Expand All @@ -1031,10 +1023,8 @@ where
});

ctx.send_message(query_ancestors)
.await
.map_err::<Error, _>(Into::into)?;
rx.await
.map_err::<Error, _>(Into::into)?
.await?;
rx.await?
.map_err::<Error, _>(Into::into)
}

Expand All @@ -1053,10 +1043,8 @@ where
));

ctx.send_message(query_session_idx_for_child)
.await
.map_err::<Error, _>(Into::into)?;
rx.await
.map_err::<Error, _>(Into::into)?
.await?;
rx.await?
.map_err::<Error, _>(Into::into)
}

Expand Down Expand Up @@ -1179,7 +1167,6 @@ mod test {
msg: AvailabilityDistributionMessage,
) {
log::trace!("Sending message:\n{:?}", &msg);
delay!(10);
overseer
.send(FromOverseer::Communication { msg })
.timeout(TIMEOUT)
Expand All @@ -1191,7 +1178,6 @@ mod test {
overseer: &mut test_helpers::TestSubsystemContextHandle<AvailabilityDistributionMessage>,
) -> AllMessages {
log::trace!("Waiting for message ...");
delay!(10);
let msg = overseer
.recv()
.timeout(TIMEOUT)
Expand Down Expand Up @@ -1782,6 +1768,8 @@ mod test {
),
).await;

delay!(300);

/////////////////////////////////////////////////////////
// ready for action

Expand Down Expand Up @@ -1815,6 +1803,8 @@ mod test {
let valid: AvailabilityGossipMessage =
make_valid_availability_gossip(&test_state, candidate_a.hash(), validator_index, 2, pov_block_a.clone());

delay!(300);

// valid (first, from b)
overseer_send(
&mut virtual_overseer,
Expand All @@ -1836,6 +1826,8 @@ mod test {
}
);

delay!(300);

// valid (duplicate, from b)
overseer_send(
&mut virtual_overseer,
Expand All @@ -1857,6 +1849,8 @@ mod test {
}
);

delay!(300);

// valid (second, from a)
overseer_send(
&mut virtual_overseer,
Expand All @@ -1878,6 +1872,8 @@ mod test {
}
);

delay!(300);

// peer a is not interested in anything anymore
overseer_send(
&mut virtual_overseer,
Expand All @@ -1894,7 +1890,6 @@ mod test {
),
).await;

delay!(50);
assert_matches!(
overseer_recv(&mut virtual_overseer).await,
AllMessages::NetworkBridge(
Expand All @@ -1917,7 +1912,6 @@ mod test {
),
).await;


// send another message
let valid2: AvailabilityGossipMessage =
make_valid_availability_gossip(&test_state, candidate_c.hash(), validator_index, 1, pov_block_c.clone());
Expand Down

0 comments on commit 4f72fc1

Please sign in to comment.