Skip to content

Commit c2c5485

Browse files
committed
refactor(submit_package): use unwrap_or_default instead of .unwrap()
- use `unwrap_or_default()` instead of `.unwrap()`, ideally it should return a specific error variant, it'd be a breaking change though and can be added in a follow-up. - it's only possible to use the internal `minreq::Error` to wrap the `serde_json::Error`, but not the `reqwest::Error` as it does not have public constructors.
1 parent e0f7985 commit c2c5485

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

src/async.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ impl<S: Sleeper> AsyncClient<S> {
410410
let response = self
411411
.post_request_bytes(
412412
"/txs/package",
413-
serde_json::to_string(&serialized_txs).unwrap(),
413+
serde_json::to_string(&serialized_txs).unwrap_or_default(),
414414
Some(queryparams),
415415
)
416416
.await?;

src/blocking.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,8 @@ impl BlockingClient {
332332
let mut request = self.post_request(
333333
"/txs/package",
334334
serde_json::to_string(&serialized_txs)
335-
.unwrap()
336-
.as_bytes()
337-
.to_vec(),
335+
.unwrap_or_default()
336+
.into_bytes(),
338337
)?;
339338

340339
if let Some(maxfeerate) = maxfeerate {

0 commit comments

Comments
 (0)