Skip to content

Commit acec673

Browse files
committed
Remove GenerateBlockError in v21-24
This only has one field and the error can be returned directly. From v25 onwards there are 2 distinct types and the error enum has been left.
1 parent 6f92d18 commit acec673

File tree

8 files changed

+17
-57
lines changed

8 files changed

+17
-57
lines changed

integration_test/tests/generating.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@ fn generating__generate_block__modelled() {
2929
{
3030
// No `submit` argument
3131
json = node.client.generate_block(&mining_addr.to_string(), &transactions).expect("generateblock");
32+
let model: Result<mtype::GenerateBlock, _> = json.into_model();
33+
model.unwrap();
3234
}
3335

3436
#[cfg(not(feature = "v24_and_below"))]
3537
{
3638
// Check with `submit = false` so that `hex` is returned. v25 and later only.
3739
json = node.client.generate_block(&mining_addr.to_string(), &transactions, false).expect("generateblock");
40+
let model: Result<mtype::GenerateBlock, GenerateBlockError> = json.into_model();
3841
}
39-
let model: Result<mtype::GenerateBlock, GenerateBlockError> = json.into_model();
40-
model.unwrap();
4142
}
4243

4344
#[test]

types/src/v21/generating/error.rs

Lines changed: 0 additions & 35 deletions
This file was deleted.

types/src/v21/generating/into.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@
44
//!
55
//! Types for methods found under the `== Generating ==` section of the API docs.
66
7-
use bitcoin::BlockHash;
7+
use bitcoin::{hex, BlockHash};
88

9-
use super::{GenerateBlock, GenerateBlockError};
9+
use super::GenerateBlock;
1010
use crate::model;
1111

1212
impl GenerateBlock {
1313
/// Converts version specific type to a version nonspecific, more strongly typed type.
14-
pub fn into_model(self) -> Result<model::GenerateBlock, GenerateBlockError> {
15-
use GenerateBlockError as E;
16-
17-
let hash = self.hash.parse::<BlockHash>().map_err(E::Hash)?;
14+
pub fn into_model(self) -> Result<model::GenerateBlock, hex::HexToArrayError> {
15+
let hash = self.hash.parse::<BlockHash>()?;
1816
Ok(model::GenerateBlock {
1917
hash,
2018
hex: None, // v25 and later only.

types/src/v21/generating/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@
44
//!
55
//! Types for methods found under the `== Generating ==` section of the API docs.
66
7-
mod error;
87
mod into;
98

109
use serde::{Deserialize, Serialize};
1110

12-
pub use self::error::GenerateBlockError;
13-
1411
/// Result of JSON-RPC method `generateblock`.
1512
///
1613
/// > Mine a block with a set of ordered transactions immediately to a specified address or descriptor (before the RPC call returns)

types/src/v21/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ pub use self::{
244244
Bip9SoftforkInfo, GetBlockchainInfo, GetMempoolEntry, GetMempoolInfo, Softfork,
245245
SoftforkType,
246246
},
247-
generating::{GenerateBlock, GenerateBlockError},
247+
generating::GenerateBlock,
248248
network::{GetNetworkInfo, GetPeerInfo},
249249
util::{GetIndexInfo, GetIndexInfoName},
250250
wallet::{

types/src/v22/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,9 @@ pub use crate::{
306306
},
307307
v20::{CreateMultisig, GenerateToDescriptor, GetTransaction, GetTransactionDetail},
308308
v21::{
309-
Bip9SoftforkInfo, GenerateBlock, GenerateBlockError, GetBlockchainInfo, GetIndexInfo,
310-
GetIndexInfoName, GetMempoolEntry, GetNetworkInfo, ImportDescriptors,
311-
ImportDescriptorsResult, PsbtBumpFee, PsbtBumpFeeError, Send, SendError, Softfork,
312-
SoftforkType, UnloadWallet, UpgradeWallet,
309+
Bip9SoftforkInfo, GenerateBlock, GetBlockchainInfo, GetIndexInfo, GetIndexInfoName,
310+
GetMempoolEntry, GetNetworkInfo, ImportDescriptors, ImportDescriptorsResult, PsbtBumpFee,
311+
PsbtBumpFeeError, Send, SendError, Softfork, SoftforkType, UnloadWallet, UpgradeWallet,
313312
},
314313
ScriptPubkey,
315314
};

types/src/v23/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,9 @@ pub use crate::{
306306
},
307307
v20::{GenerateToDescriptor, GetTransactionDetail},
308308
v21::{
309-
GenerateBlock, GenerateBlockError, GetIndexInfo, GetIndexInfoName, GetNetworkInfo,
310-
ImportDescriptors, ImportDescriptorsResult, PsbtBumpFee, PsbtBumpFeeError, Send, SendError,
311-
UnloadWallet, UpgradeWallet,
309+
GenerateBlock, GetIndexInfo, GetIndexInfoName, GetNetworkInfo, ImportDescriptors,
310+
ImportDescriptorsResult, PsbtBumpFee, PsbtBumpFeeError, Send, SendError, UnloadWallet,
311+
UpgradeWallet,
312312
},
313313
v22::{Banned, GetMempoolInfo, ListBanned, ScriptPubkey},
314314
};

types/src/v24/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,9 @@ pub use crate::{
307307
},
308308
v20::GenerateToDescriptor,
309309
v21::{
310-
GenerateBlock, GenerateBlockError, GetIndexInfo, GetIndexInfoName, GetNetworkInfo,
311-
ImportDescriptors, ImportDescriptorsResult, PsbtBumpFee, PsbtBumpFeeError, Send, SendError,
312-
UnloadWallet, UpgradeWallet,
310+
GenerateBlock, GetIndexInfo, GetIndexInfoName, GetNetworkInfo, ImportDescriptors,
311+
ImportDescriptorsResult, PsbtBumpFee, PsbtBumpFeeError, Send, SendError, UnloadWallet,
312+
UpgradeWallet,
313313
},
314314
v22::{Banned, ListBanned, ScriptPubkey},
315315
v23::{

0 commit comments

Comments
 (0)