Skip to content

Commit e022b7c

Browse files
committed
Merge #395: Fix GetRawMempoolVerbose client macro and test
f409bf7 Fix integration test for getrawmempool verbose (jamillambert) 32d2f17 Fix incorrect client return type for verbose (jamillambert) f0b1c85 Add missing getrawmempool types in v18-v23 (jamillambert) Pull request description: The client macro for `getrawmempool` with verbose set to true returns the non verbose type. The test for this case was commented out. The inner type `MempoolEntry` changed multiple times from v18-v23, but `GetRawMempoolVerbose` still used the v17 type until v24. For v24 and up the correct `MempoolEntry` type version is used. - Add the `getrawmempool` types and `into_model` functions or reexports of the correct version for v18-v23 that use the updated `MempoolEntry` types. - Fix the type in the client macro. - Uncomment the test for verbose. Closes #389 ACKs for top commit: tcharding: ACK f409bf7 Tree-SHA512: 90cb3a0be54d95edbd8070afe723b7d1f6284819e79cf95ca22608afba2b405852a6d713a6e8179d360f303f31cf2de323fc2b65b7961cb92f56ef8bd14e5d65
2 parents 1ee8008 + f409bf7 commit e022b7c

File tree

16 files changed

+252
-91
lines changed

16 files changed

+252
-91
lines changed

client/src/client_sync/v17/blockchain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ macro_rules! impl_client_v17__get_raw_mempool {
230230
// Equivalent to self.call("getrawmempool", &[into_json(false)?])
231231
self.call("getrawmempool", &[])
232232
}
233-
pub fn get_raw_mempool_verbose(&self) -> Result<GetRawMempool> {
233+
pub fn get_raw_mempool_verbose(&self) -> Result<GetRawMempoolVerbose> {
234234
self.call("getrawmempool", &[into_json(true)?])
235235
}
236236
}

integration_test/tests/blockchain.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,13 @@ fn blockchain__get_raw_mempool__modelled() {
359359
// Sanity check.
360360
assert_eq!(mempool.0.len(), 1);
361361

362-
// FIXME: Fails: JsonRpc(Json(Error("invalid type: map, expected a sequence", line: 1, column: 0)))
363362
// verbose = true
364-
// let json: GetRawMempoolVerbose = node.client.get_raw_mempool_verbose().expect("getrawmempool verbose");
365-
// let model: Result<mtype::GetRawMempoolVerbose, GetRawMempoolVerboseError> = json.into_model();
366-
// let mempool = model.unwrap();
367-
// // Sanity check.
368-
// assert_eq!(mempool.0.len(), 1);
363+
let json: GetRawMempoolVerbose =
364+
node.client.get_raw_mempool_verbose().expect("getrawmempool verbose");
365+
let model: Result<mtype::GetRawMempoolVerbose, MapMempoolEntryError> = json.into_model();
366+
let mempool = model.unwrap();
367+
// Sanity check.
368+
assert_eq!(mempool.0.len(), 1);
369369
}
370370

371371
#[test]

types/src/v18/blockchain/into.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use bitcoin::{hex, Txid, Wtxid};
66

77
use super::{
88
GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants,
9-
GetMempoolDescendantsVerbose, GetMempoolEntry, MapMempoolEntryError, MempoolEntry,
10-
MempoolEntryError,
9+
GetMempoolDescendantsVerbose, GetMempoolEntry, GetRawMempool, GetRawMempoolVerbose,
10+
MapMempoolEntryError, MempoolEntry, MempoolEntryError,
1111
};
1212
use crate::model;
1313

@@ -111,3 +111,26 @@ impl MempoolEntry {
111111
})
112112
}
113113
}
114+
115+
impl GetRawMempool {
116+
/// Converts version specific type to a version nonspecific, more strongly typed type.
117+
pub fn into_model(self) -> Result<model::GetRawMempool, hex::HexToArrayError> {
118+
let v = self.0.iter().map(|t| t.parse::<Txid>()).collect::<Result<Vec<_>, _>>()?;
119+
Ok(model::GetRawMempool(v))
120+
}
121+
}
122+
123+
impl GetRawMempoolVerbose {
124+
/// Converts version specific type to a version nonspecific, more strongly typed type.
125+
pub fn into_model(self) -> Result<model::GetRawMempoolVerbose, MapMempoolEntryError> {
126+
use MapMempoolEntryError as E;
127+
128+
let mut map = BTreeMap::new();
129+
for (k, v) in self.0.into_iter() {
130+
let txid = k.parse::<Txid>().map_err(E::Txid)?;
131+
let relative = v.into_model().map_err(E::MempoolEntry)?;
132+
map.insert(txid, relative);
133+
}
134+
Ok(model::GetRawMempoolVerbose(map))
135+
}
136+
}

types/src/v18/blockchain/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,20 @@ pub struct MempoolEntry {
110110
#[serde(rename = "bip125-replaceable")]
111111
pub bip125_replaceable: bool,
112112
}
113+
114+
/// Result of JSON-RPC method `getrawmempool` with verbose set to `false`.
115+
/// > getrawmempool ( verbose )
116+
/// >
117+
/// > Returns all transaction ids in memory pool as a json array of string transaction ids.
118+
/// >
119+
/// > Hint: use getmempoolentry to fetch a specific transaction from the mempool.
120+
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
121+
#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))]
122+
pub struct GetRawMempool(pub Vec<String>);
123+
124+
/// Result of JSON-RPC method `getrawmempool` with verbose set to `true`.
125+
///
126+
/// Map of txid to [`MempoolEntry`].
127+
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
128+
#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))]
129+
pub struct GetRawMempoolVerbose(pub BTreeMap<String, MempoolEntry>);

types/src/v18/mod.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ mod zmq;
235235
pub use self::{
236236
blockchain::{
237237
GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants,
238-
GetMempoolDescendantsVerbose, GetMempoolEntry, MempoolEntry,
238+
GetMempoolDescendantsVerbose, GetMempoolEntry, GetRawMempool, GetRawMempoolVerbose,
239+
MempoolEntry,
239240
},
240241
control::{ActiveCommand, GetRpcInfo},
241242
network::{GetNodeAddresses, GetPeerInfo, NodeAddress, PeerInfo},
@@ -268,17 +269,17 @@ pub use crate::v17::{
268269
GetBlockVerboseZero, GetBlockchainInfo, GetBlockchainInfoError, GetChainTips, GetChainTxStats,
269270
GetChainTxStatsError, GetConnectionCount, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo,
270271
GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress,
271-
GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetRawChangeAddress, GetRawMempool,
272-
GetRawMempoolVerbose, GetRawTransaction, GetRawTransactionVerbose,
273-
GetRawTransactionVerboseError, GetReceivedByAddress, GetTransaction, GetTransactionDetail,
274-
GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo,
275-
GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings,
276-
ListAddressGroupingsError, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent,
277-
ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock,
278-
ListSinceBlockError, ListTransactions, ListUnspentItemError, ListWallets, LoadWallet,
279-
LockUnspent, Locked, Logging, MapMempoolEntryError, MempoolAcceptance, MempoolEntryError,
280-
MempoolEntryFees, MempoolEntryFeesError, NumericError, PruneBlockchain, PsbtInput, PsbtOutput,
281-
PsbtScript, RawTransaction, RawTransactionError, RawTransactionInput, RawTransactionOutput,
272+
GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetRawChangeAddress,
273+
GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError,
274+
GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetTransactionDetailError,
275+
GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError,
276+
GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError,
277+
ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem,
278+
ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError,
279+
ListTransactions, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, Logging,
280+
MapMempoolEntryError, MempoolAcceptance, MempoolEntryError, MempoolEntryFees,
281+
MempoolEntryFeesError, NumericError, PruneBlockchain, PsbtInput, PsbtOutput, PsbtScript,
282+
RawTransaction, RawTransactionError, RawTransactionInput, RawTransactionOutput,
282283
RescanBlockchain, ScriptType, SendMany, SendRawTransaction, SendToAddress, SetNetworkActive,
283284
SetTxFee, SignFail, SignFailError, SignMessage, SignMessageWithPrivKey, SignRawTransaction,
284285
SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, Softfork,

types/src/v19/blockchain/into.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use super::error::{
1212
use super::{
1313
GetBlockFilter, GetBlockchainInfo, GetChainTxStats, GetChainTxStatsError, GetMempoolAncestors,
1414
GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose,
15-
GetMempoolEntry, GetMempoolInfo, GetMempoolInfoError, MempoolEntry, MempoolEntryFees,
15+
GetMempoolEntry, GetMempoolInfo, GetMempoolInfoError, GetRawMempool, GetRawMempoolVerbose,
16+
MempoolEntry, MempoolEntryFees,
1617
};
1718
use crate::model;
1819

@@ -236,3 +237,26 @@ impl GetMempoolInfo {
236237
})
237238
}
238239
}
240+
241+
impl GetRawMempool {
242+
/// Converts version specific type to a version nonspecific, more strongly typed type.
243+
pub fn into_model(self) -> Result<model::GetRawMempool, hex::HexToArrayError> {
244+
let v = self.0.iter().map(|t| t.parse::<Txid>()).collect::<Result<Vec<_>, _>>()?;
245+
Ok(model::GetRawMempool(v))
246+
}
247+
}
248+
249+
impl GetRawMempoolVerbose {
250+
/// Converts version specific type to a version nonspecific, more strongly typed type.
251+
pub fn into_model(self) -> Result<model::GetRawMempoolVerbose, MapMempoolEntryError> {
252+
use MapMempoolEntryError as E;
253+
254+
let mut map = BTreeMap::new();
255+
for (k, v) in self.0.into_iter() {
256+
let txid = k.parse::<Txid>().map_err(E::Txid)?;
257+
let relative = v.into_model().map_err(E::MempoolEntry)?;
258+
map.insert(txid, relative);
259+
}
260+
Ok(model::GetRawMempoolVerbose(map))
261+
}
262+
}

types/src/v19/blockchain/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,3 +341,20 @@ pub struct GetMempoolInfo {
341341
#[serde(rename = "minrelaytxfee")]
342342
pub min_relay_tx_fee: f64,
343343
}
344+
345+
/// Result of JSON-RPC method `getrawmempool` with verbose set to `false`.
346+
/// > getrawmempool ( verbose )
347+
/// >
348+
/// > Returns all transaction ids in memory pool as a json array of string transaction ids.
349+
/// >
350+
/// > Hint: use getmempoolentry to fetch a specific transaction from the mempool.
351+
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
352+
#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))]
353+
pub struct GetRawMempool(pub Vec<String>);
354+
355+
/// Result of JSON-RPC method `getrawmempool` with verbose set to `true`.
356+
///
357+
/// Map of txid to [`MempoolEntry`].
358+
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
359+
#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))]
360+
pub struct GetRawMempoolVerbose(pub BTreeMap<String, MempoolEntry>);

types/src/v19/mod.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,9 @@ pub use self::{
237237
Bip9SoftforkInfo, Bip9SoftforkStatistics, Bip9SoftforkStatus, GetBlockFilter,
238238
GetBlockFilterError, GetBlockchainInfo, GetBlockchainInfoError, GetChainTxStats,
239239
GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants,
240-
GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, MapMempoolEntryError,
241-
MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, Softfork,
242-
SoftforkType,
240+
GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetRawMempool,
241+
GetRawMempoolVerbose, MapMempoolEntryError, MempoolEntry, MempoolEntryError,
242+
MempoolEntryFees, MempoolEntryFeesError, Softfork, SoftforkType,
243243
},
244244
control::GetRpcInfo,
245245
network::{GetNetworkInfo, GetPeerInfo, PeerInfo},
@@ -264,21 +264,20 @@ pub use crate::v17::{
264264
GetBlockTemplate, GetBlockTemplateError, GetBlockVerboseOne, GetBlockVerboseOneError,
265265
GetBlockVerboseZero, GetChainTips, GetChainTxStatsError, GetConnectionCount, GetDifficulty,
266266
GetMemoryInfoStats, GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfoAddress,
267-
GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetRawChangeAddress, GetRawMempool,
268-
GetRawMempoolVerbose, GetRawTransaction, GetRawTransactionVerbose,
269-
GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetail,
270-
GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo,
271-
GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings,
272-
ListAddressGroupingsError, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent,
273-
ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock,
274-
ListSinceBlockError, ListTransactions, ListUnspentItemError, ListWallets, LoadWallet,
275-
LockUnspent, Locked, Logging, NumericError, PruneBlockchain, RawTransactionError,
276-
RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendMany,
277-
SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage,
278-
SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey,
279-
SignRawTransactionWithWallet, SoftforkReject, TestMempoolAccept, TransactionCategory,
280-
TransactionItem, TransactionItemError, UploadTarget, ValidateAddress, ValidateAddressError,
281-
VerifyChain, VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt,
267+
GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetRawChangeAddress,
268+
GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError,
269+
GetReceivedByAddress, GetTransactionDetail, GetTransactionDetailError, GetTransactionError,
270+
GetTxOut, GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance,
271+
GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem,
272+
ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError,
273+
ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, ListTransactions,
274+
ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, Logging, NumericError,
275+
PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput,
276+
RescanBlockchain, ScriptType, SendMany, SendRawTransaction, SendToAddress, SetNetworkActive,
277+
SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError,
278+
SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TestMempoolAccept,
279+
TransactionCategory, TransactionItem, TransactionItemError, UploadTarget, ValidateAddress,
280+
ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt,
282281
WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo,
283282
};
284283
#[doc(inline)]

types/src/v20/mod.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -260,20 +260,20 @@ pub use crate::{
260260
GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, GetChainTxStatsError,
261261
GetConnectionCount, GetDifficulty, GetMemoryInfoStats, GetMempoolInfoError, GetMiningInfo,
262262
GetNetTotals, GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork,
263-
GetNewAddress, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose, GetRawTransaction,
264-
GetRawTransactionVerbose, GetRawTransactionVerboseError, GetReceivedByAddress,
265-
GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo,
266-
GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings,
267-
ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent,
268-
ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError,
269-
ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, NumericError,
270-
PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput,
271-
RescanBlockchain, ScriptType, SendMany, SendRawTransaction, SendToAddress,
272-
SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction,
273-
SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet,
274-
SoftforkReject, TestMempoolAccept, TransactionCategory, UploadTarget, ValidateAddress,
275-
ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt,
276-
WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo,
263+
GetNewAddress, GetRawChangeAddress, GetRawTransaction, GetRawTransactionVerbose,
264+
GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError,
265+
GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError,
266+
GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError,
267+
ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem,
268+
ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets,
269+
LoadWallet, LockUnspent, Locked, NumericError, PruneBlockchain, RawTransactionError,
270+
RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendMany,
271+
SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage,
272+
SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError,
273+
SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TestMempoolAccept,
274+
TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain,
275+
VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError,
276+
WalletProcessPsbt, WitnessUtxo,
277277
},
278278
v18::{
279279
ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing,
@@ -289,8 +289,8 @@ pub use crate::{
289289
GetBlockFilterError, GetBlockchainInfo, GetBlockchainInfoError, GetChainTxStats,
290290
GetDescriptorInfo, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants,
291291
GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetNetworkInfo, GetPeerInfo,
292-
GetRpcInfo, GetWalletInfo, GetWalletInfoScanning, MapMempoolEntryError, MempoolEntry,
293-
MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PeerInfo, SetWalletFlag,
294-
Softfork, SoftforkType,
292+
GetRawMempool, GetRawMempoolVerbose, GetRpcInfo, GetWalletInfo, GetWalletInfoScanning,
293+
MapMempoolEntryError, MempoolEntry, MempoolEntryError, MempoolEntryFees,
294+
MempoolEntryFeesError, PeerInfo, SetWalletFlag, Softfork, SoftforkType,
295295
},
296296
};

types/src/v21/blockchain/into.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ use bitcoin::{hex, BlockHash, Network, Txid, Work, Wtxid};
77
use super::{
88
GetBlockchainInfo, GetBlockchainInfoError, GetMempoolAncestors, GetMempoolAncestorsVerbose,
99
GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo,
10-
GetMempoolInfoError, MapMempoolEntryError, MempoolEntry, MempoolEntryError,
10+
GetMempoolInfoError, GetRawMempool, GetRawMempoolVerbose, MapMempoolEntryError, MempoolEntry,
11+
MempoolEntryError,
1112
};
1213
use crate::model;
1314

@@ -179,3 +180,26 @@ impl GetMempoolInfo {
179180
})
180181
}
181182
}
183+
184+
impl GetRawMempool {
185+
/// Converts version specific type to a version nonspecific, more strongly typed type.
186+
pub fn into_model(self) -> Result<model::GetRawMempool, hex::HexToArrayError> {
187+
let v = self.0.iter().map(|t| t.parse::<Txid>()).collect::<Result<Vec<_>, _>>()?;
188+
Ok(model::GetRawMempool(v))
189+
}
190+
}
191+
192+
impl GetRawMempoolVerbose {
193+
/// Converts version specific type to a version nonspecific, more strongly typed type.
194+
pub fn into_model(self) -> Result<model::GetRawMempoolVerbose, MapMempoolEntryError> {
195+
use MapMempoolEntryError as E;
196+
197+
let mut map = BTreeMap::new();
198+
for (k, v) in self.0.into_iter() {
199+
let txid = k.parse::<Txid>().map_err(E::Txid)?;
200+
let relative = v.into_model().map_err(E::MempoolEntry)?;
201+
map.insert(txid, relative);
202+
}
203+
Ok(model::GetRawMempoolVerbose(map))
204+
}
205+
}

0 commit comments

Comments
 (0)