Skip to content

Commit e8e70e4

Browse files
committed
app: clarify mainchain connection issues
Separate the two distinct problems: 1. We're unable to connect to mainchain 2. Mainchain doesn't support the functionality we need
1 parent 0d1e08e commit e8e70e4

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

app/app.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ pub enum Error {
3333
"Unable to verify existence of CUSF mainchain service(s) at {0}: {1}"
3434
)]
3535
VerifyMainchainServices(url::Url, tonic::Status),
36+
#[error("failed to connect to CUSF mainchain enforcer at {0}")]
37+
ConnectMainchain(url::Url, #[source] tonic::Status),
3638
#[error("io error")]
3739
Io(#[from] std::io::Error),
3840
#[error("miner error")]
@@ -210,11 +212,21 @@ impl App {
210212
.connect_lazy();
211213
let (cusf_mainchain, cusf_mainchain_wallet) = if runtime
212214
.block_on(Self::check_proto_support(transport.clone()))
213-
.map_err(|err| {
214-
Error::VerifyMainchainServices(
215+
.map_err(|err| match err {
216+
status
217+
// Kind of crude, but I'm unable to match this on a std::io::Error...
218+
if status.code() == tonic::Code::Unavailable
219+
&& status.message().contains("tcp connect error") =>
220+
{
221+
Error::ConnectMainchain(
222+
config.mainchain_grpc_address.clone(),
223+
status,
224+
)
225+
}
226+
_ => Error::VerifyMainchainServices(
215227
config.mainchain_grpc_address.clone(),
216228
err,
217-
)
229+
),
218230
})? {
219231
(
220232
mainchain::ValidatorClient::new(transport.clone()),

0 commit comments

Comments
 (0)