-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
246 additions
and
76 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
zebra-rpc/src/methods/get_block_template_rpcs/types/get_block_template/proposal.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
//! `ProposalResponse` is the output of the `getblocktemplate` RPC method in 'proposal' mode. | ||
use super::{GetBlockTemplate, Response}; | ||
|
||
/// Error response to a `getblocktemplate` RPC request in proposal mode. | ||
/// | ||
/// See <https://en.bitcoin.it/wiki/BIP_0022#Appendix:_Example_Rejection_Reasons> | ||
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] | ||
#[serde(rename_all = "kebab-case")] | ||
pub enum ProposalRejectReason { | ||
/// Block proposal rejected as invalid. | ||
Rejected, | ||
} | ||
|
||
/// Response to a `getblocktemplate` RPC request in proposal mode. | ||
/// | ||
/// See <https://en.bitcoin.it/wiki/BIP_0023#Block_Proposal> | ||
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] | ||
#[serde(untagged, rename_all = "kebab-case")] | ||
pub enum ProposalResponse { | ||
/// Block proposal was rejected as invalid, returns `reject-reason` and server `capabilities`. | ||
ErrorResponse { | ||
/// Reason the proposal was invalid as-is. | ||
reject_reason: ProposalRejectReason, | ||
|
||
/// The getblocktemplate RPC capabilities supported by Zebra. | ||
capabilities: Vec<String>, | ||
}, | ||
|
||
/// Block proposal was successfully validated, returns null. | ||
Valid, | ||
} | ||
|
||
impl From<ProposalRejectReason> for ProposalResponse { | ||
fn from(reject_reason: ProposalRejectReason) -> Self { | ||
Self::ErrorResponse { | ||
reject_reason, | ||
capabilities: GetBlockTemplate::capabilities(), | ||
} | ||
} | ||
} | ||
|
||
impl From<ProposalRejectReason> for Response { | ||
fn from(error_response: ProposalRejectReason) -> Self { | ||
Self::ProposalMode(ProposalResponse::from(error_response)) | ||
} | ||
} | ||
|
||
impl From<ProposalResponse> for Response { | ||
fn from(proposal_response: ProposalResponse) -> Self { | ||
Self::ProposalMode(proposal_response) | ||
} | ||
} | ||
|
||
impl From<GetBlockTemplate> for Response { | ||
fn from(template: GetBlockTemplate) -> Self { | ||
Self::TemplateMode(Box::new(template)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.