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

Commit 0a676a8

Browse files
committed
more steps
1 parent 343cc42 commit 0a676a8

File tree

1 file changed

+18
-11
lines changed
  • node/core/provisioner/src

1 file changed

+18
-11
lines changed

node/core/provisioner/src/lib.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ use polkadot_primitives::v1::{
4242
SignedAvailabilityBitfield,
4343
};
4444
use std::{collections::HashMap, convert::TryFrom, pin::Pin};
45+
use thiserror::Error;
4546

4647
struct ProvisioningJob {
4748
relay_parent: Hash,
@@ -115,19 +116,25 @@ impl TryFrom<AllMessages> for FromJob {
115116
}
116117
}
117118

118-
#[derive(Debug, derive_more::From)]
119+
#[derive(Debug, Error)]
119120
enum Error {
120-
#[from]
121-
Sending(mpsc::SendError),
122-
#[from]
121+
#[error(transparent)]
123122
Util(util::Error),
124-
#[from]
123+
124+
#[error(transparent)]
125125
OneshotRecv(oneshot::Canceled),
126-
#[from]
126+
127+
#[error(transparent)]
127128
ChainApi(ChainApiError),
128-
#[from]
129+
130+
#[error(transparent)]
129131
Runtime(RuntimeApiError),
130-
OneshotSend,
132+
133+
#[error("Failed to send message to ChainAPI")]
134+
ChainApiMessageSend(#[source] mpsc::SendError),
135+
136+
#[error("Failed to send return message with Inherents")]
137+
InherentDataReturnChannel(#[source] mpsc::SendError),
131138
}
132139

133140
impl JobTrait for ProvisioningJob {
@@ -299,7 +306,7 @@ async fn send_inherent_data(
299306

300307
return_sender
301308
.send((bitfields, candidates))
302-
.map_err(|_| Error::OneshotSend)?;
309+
.map_err(|e| Error::InherentDataReturnChannel(e))?;
303310
Ok(())
304311
}
305312

@@ -423,7 +430,7 @@ async fn get_block_number_under_construction(
423430
tx,
424431
)))
425432
.await
426-
.map_err(|_| Error::OneshotSend)?;
433+
.map_err(|e| Error::ChainApiMessageSend(e))?;
427434
match rx.await? {
428435
Ok(Some(n)) => Ok(n + 1),
429436
Ok(None) => Ok(0),
@@ -801,7 +808,7 @@ mod tests {
801808
Delay::new(std::time::Duration::from_millis(50)).await;
802809
let result = select_candidates(&[], &[], &[], Default::default(), &mut tx).await;
803810
println!("{:?}", result);
804-
assert!(std::matches!(result, Err(Error::OneshotSend)));
811+
assert!(std::matches!(result, Err(Error::ChainApiMessageSend(_))));
805812
};
806813

807814
test_harness(overseer, test);

0 commit comments

Comments
 (0)