Skip to content

Commit 97327e1

Browse files
committed
Merge #148: Implement savemempool method and test
565702f Implement savemempool method and test (GideonBature) Pull request description: Going by the conversations with tcharding for PR #116 on implementing one method at a time for easier review: This is the second method implementation `savemempool` which is a specific type that returns a (json null). Once this is approved, I’ll proceed with the next one. ACKs for top commit: tcharding: ACK 565702f Tree-SHA512: 85d0d2ef8fa48cc325efc4f7eb9dfbf1276fe9185ff0c3bc2639aaec924088795638b82fb51856cd8454d24a7c59332297921ee00db38efb7e02db35bddbc1fc
2 parents 8b7e587 + 565702f commit 97327e1

File tree

28 files changed

+119
-14
lines changed

28 files changed

+119
-14
lines changed

client/src/client_sync/v17/blockchain.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,22 @@ macro_rules! impl_client_v17__pruneblockchain {
302302
};
303303
}
304304

305+
/// Implements Bitcoin Core JSON-RPC API method `savemempool`
306+
#[macro_export]
307+
macro_rules! impl_client_v17__savemempool {
308+
() => {
309+
impl Client {
310+
pub fn save_mempool(&self) -> Result<()> {
311+
match self.call("savemempool", &[]) {
312+
Ok(serde_json::Value::Null) => Ok(()),
313+
Ok(res) => Err(Error::Returned(res.to_string())),
314+
Err(err) => Err(err.into()),
315+
}
316+
}
317+
}
318+
};
319+
}
320+
305321
/// Implements Bitcoin Core JSON-RPC API method `verifytxoutproof`
306322
#[macro_export]
307323
macro_rules! impl_client_v17__verifytxoutproof {

client/src/client_sync/v17/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ crate::impl_client_v17__gettxoutproof!();
4949
crate::impl_client_v17__gettxoutsetinfo!();
5050
crate::impl_client_v17__preciousblock!();
5151
crate::impl_client_v17__pruneblockchain!();
52+
crate::impl_client_v17__savemempool!();
5253
crate::impl_client_v17__verifytxoutproof!();
5354

5455
// == Control ==

client/src/client_sync/v18/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ crate::impl_client_v17__gettxoutproof!();
4343
crate::impl_client_v17__gettxoutsetinfo!();
4444
crate::impl_client_v17__preciousblock!();
4545
crate::impl_client_v17__pruneblockchain!();
46+
crate::impl_client_v17__savemempool!();
4647
crate::impl_client_v17__verifytxoutproof!();
4748

4849
// == Control ==

client/src/client_sync/v19/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ crate::impl_client_v17__gettxoutproof!();
4444
crate::impl_client_v17__gettxoutsetinfo!();
4545
crate::impl_client_v17__preciousblock!();
4646
crate::impl_client_v17__pruneblockchain!();
47+
crate::impl_client_v17__savemempool!();
4748
crate::impl_client_v17__verifytxoutproof!();
4849

4950
// == Control ==

client/src/client_sync/v20.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ crate::impl_client_v17__gettxoutproof!();
4141
crate::impl_client_v17__gettxoutsetinfo!();
4242
crate::impl_client_v17__preciousblock!();
4343
crate::impl_client_v17__pruneblockchain!();
44+
crate::impl_client_v17__savemempool!();
4445
crate::impl_client_v17__verifytxoutproof!();
4546

4647
// == Control ==

client/src/client_sync/v21/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ crate::impl_client_v17__gettxoutproof!();
4343
crate::impl_client_v17__gettxoutsetinfo!();
4444
crate::impl_client_v17__preciousblock!();
4545
crate::impl_client_v17__pruneblockchain!();
46+
crate::impl_client_v17__savemempool!();
4647
crate::impl_client_v17__verifytxoutproof!();
4748

4849
// == Control ==

client/src/client_sync/v22/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ crate::impl_client_v17__gettxoutproof!();
4444
crate::impl_client_v17__gettxoutsetinfo!();
4545
crate::impl_client_v17__preciousblock!();
4646
crate::impl_client_v17__pruneblockchain!();
47+
crate::impl_client_v17__savemempool!();
4748
crate::impl_client_v17__verifytxoutproof!();
4849

4950
// == Control ==
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// SPDX-License-Identifier: CC0-1.0
2+
3+
//! Macros for implementing JSON-RPC methods on a client.
4+
//!
5+
//! Specifically this is methods found under the `== Blockchain ==` section of the
6+
//! API docs of Bitcoin Core `v0.23`.
7+
//!
8+
//! All macros require `Client` to be in scope.
9+
//!
10+
//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`.
11+
/// Implements Bitcoin Core JSON-RPC API method `savemempool`
12+
#[macro_export]
13+
macro_rules! impl_client_v23__savemempool {
14+
() => {
15+
impl Client {
16+
pub fn save_mempool(&self) -> Result<SaveMempool> { self.call("savemempool", &[]) }
17+
}
18+
};
19+
}

client/src/client_sync/v23/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//!
55
//! We ignore option arguments unless they effect the shape of the returned JSON data.
66
7+
pub mod blockchain;
78
pub mod wallet;
89

910
use std::collections::BTreeMap;
@@ -44,6 +45,7 @@ crate::impl_client_v17__gettxoutproof!();
4445
crate::impl_client_v17__gettxoutsetinfo!();
4546
crate::impl_client_v17__preciousblock!();
4647
crate::impl_client_v17__pruneblockchain!();
48+
crate::impl_client_v23__savemempool!();
4749
crate::impl_client_v17__verifytxoutproof!();
4850

4951
// == Control ==

client/src/client_sync/v24.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ crate::impl_client_v17__gettxoutproof!();
4141
crate::impl_client_v17__gettxoutsetinfo!();
4242
crate::impl_client_v17__preciousblock!();
4343
crate::impl_client_v17__pruneblockchain!();
44+
crate::impl_client_v23__savemempool!();
4445
crate::impl_client_v17__verifytxoutproof!();
4546

4647
// == Control ==

0 commit comments

Comments
 (0)