Skip to content

Commit

Permalink
Add error handling to maker_protocol.rs
Browse files Browse the repository at this point in the history
Previously if there was any kind of error the maker would
just panic and close.

Now all errors are checked and handled. A protocol or network error
results in that client's connection being closed. A disk error
has the maker shutting down. A RPC error has the server not accepting
any more client connections until the RPC connection is reestablished.
  • Loading branch information
chris-belcher committed Jun 24, 2021
1 parent 3eb9ae9 commit c0e374f
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 135 deletions.
2 changes: 1 addition & 1 deletion src/contracts.rs
Expand Up @@ -285,7 +285,7 @@ pub fn verify_proof_of_funding(
return Err(Error::Protocol("funding tx not confirmed"));
}
} else {
return Err(Error::Protocol("output doesnt exist"));
return Err(Error::Protocol("funding tx output doesnt exist"));
}

//pattern match to check redeemscript is really a 2of2 multisig
Expand Down
6 changes: 3 additions & 3 deletions src/error.rs
Expand Up @@ -7,14 +7,14 @@ use bitcoincore_rpc;
// try to make functions return this
#[derive(Debug)]
pub enum Error {
Network(Box<dyn error::Error>),
Network(Box<dyn error::Error + Send>),
Disk(io::Error),
Protocol(&'static str),
Rpc(bitcoincore_rpc::Error),
}

impl From<Box<dyn error::Error>> for Error {
fn from(e: Box<dyn error::Error>) -> Error {
impl From<Box<dyn error::Error + Send>> for Error {
fn from(e: Box<dyn error::Error + Send>) -> Error {
Error::Network(e)
}
}
Expand Down

0 comments on commit c0e374f

Please sign in to comment.