Skip to content

core: allow serialization of SyncResponse #1954

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
2 changes: 2 additions & 0 deletions crates/core/src/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ use crate::BlockId;
/// Checkpoints are cheaply cloneable and are useful to find the agreement point between two sparse
/// block chains.
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct CheckPoint(Arc<CPInner>);

/// The internal contents of [`CheckPoint`].
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
struct CPInner {
/// Block id (hash and height).
block: BlockId,
Expand Down
8 changes: 4 additions & 4 deletions crates/core/src/spk_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,14 +387,14 @@ impl<I> SyncRequest<I> {
/// See also [`SyncRequest`].
#[must_use]
#[derive(Debug)]
pub struct SyncResponse<A = ConfirmationBlockTime> {
pub struct SyncResponse<A: Ord = ConfirmationBlockTime> {
/// Relevant transaction data discovered during the scan.
pub tx_update: crate::TxUpdate<A>,
/// Changes to the chain discovered during the scan.
pub chain_update: Option<CheckPoint>,
}

impl<A> Default for SyncResponse<A> {
impl<A: Ord> Default for SyncResponse<A> {
fn default() -> Self {
Self {
tx_update: Default::default(),
Expand Down Expand Up @@ -540,7 +540,7 @@ impl<K: Ord + Clone> FullScanRequest<K> {
/// See also [`FullScanRequest`].
#[must_use]
#[derive(Debug)]
pub struct FullScanResponse<K, A = ConfirmationBlockTime> {
pub struct FullScanResponse<K, A: Ord = ConfirmationBlockTime> {
/// Relevant transaction data discovered during the scan.
pub tx_update: crate::TxUpdate<A>,
/// Last active indices for the corresponding keychains (`K`). An index is active if it had a
Expand All @@ -550,7 +550,7 @@ pub struct FullScanResponse<K, A = ConfirmationBlockTime> {
pub chain_update: Option<CheckPoint>,
}

impl<K, A> Default for FullScanResponse<K, A> {
impl<K, A: Ord> Default for FullScanResponse<K, A> {
fn default() -> Self {
Self {
tx_update: Default::default(),
Expand Down
5 changes: 3 additions & 2 deletions crates/core/src/tx_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ use bitcoin::{OutPoint, Transaction, TxOut, Txid};
/// tx_update.anchors.insert((anchor, txid));
/// ```
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[non_exhaustive]
pub struct TxUpdate<A = ()> {
pub struct TxUpdate<A: Ord = ()> {
/// Full transactions. These are transactions that were determined to be relevant to the wallet
/// given the request.
pub txs: Vec<Arc<Transaction>>,
Expand Down Expand Up @@ -52,7 +53,7 @@ pub struct TxUpdate<A = ()> {
pub evicted_ats: HashSet<(Txid, u64)>,
}

impl<A> Default for TxUpdate<A> {
impl<A: Ord> Default for TxUpdate<A> {
fn default() -> Self {
Self {
txs: Default::default(),
Expand Down
Loading