Skip to content

Move TemplateRequest and TemplateRules into their proper module #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions client/src/client_sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,24 +259,3 @@ pub struct WalletCreateFundedPsbtInput {
txid: Txid,
vout: u32,
}

/// Arg for the `getblocktemplate` method.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub struct TemplateRequest {
/// A list of strings.
pub rules: Vec<TemplateRules>,
}

/// Client side supported softfork deployment.
#[derive(Copy, Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum TemplateRules {
/// SegWit v0 supported.
Segwit,
/// Signet supported.
Signet,
/// CSV supported.
Csv,
/// Taproot supported.
Taproot,
}
2 changes: 1 addition & 1 deletion client/src/client_sync/v17/mining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ macro_rules! impl_client_v17__getblocktemplate {
impl Client {
pub fn get_block_template(
&self,
request: &$crate::client_sync::TemplateRequest,
request: &$crate::client_sync::v17::TemplateRequest,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change forces us to add a new get_block_template to the v29 client. Instead of doing this we can just import the type from the correct module in v17/mod.rs. You can see an example of how we do this for v28 and AddressType (client/src/client_sync/v28/mod.rs).

) -> Result<GetBlockTemplate> {
self.call("getblocktemplate", &[into_json(request)?])
}
Expand Down
23 changes: 23 additions & 0 deletions client/src/client_sync/v17/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,26 @@ impl fmt::Display for AddressType {
fmt::Display::fmt(s, f)
}
}

/// Arg for the `getblocktemplate` method.
///
/// For Core versions 0.17 through to v28. For Core v29 and onwards use `v29::TemplateRequest`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub struct TemplateRequest {
/// A list of strings.
pub rules: Vec<TemplateRules>,
}

/// Client side supported softfork deployment.
#[derive(Copy, Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum TemplateRules {
/// SegWit v0 supported.
Segwit,
/// Signet supported.
Signet,
/// CSV supported.
Csv,
/// Taproot supported.
Taproot,
}
2 changes: 1 addition & 1 deletion integration_test/tests/mining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use bitcoin::SignedAmount;
use integration_test::{Node, NodeExt as _, Wallet};
use node::client::client_sync::{TemplateRequest, TemplateRules};
use node::client::client_sync::v17::{TemplateRequest, TemplateRules};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break when we add v29. Check out the solution around AddressType in node/src/client_versions.rs.

use node::vtype::*; // All the version specific types.
use node::mtype;

Expand Down