Implement PartialEq manually
authorWilmer Paulino <wilmer@wilmerpaulino.com>
Tue, 14 Feb 2023 23:35:40 +0000 (15:35 -0800)
committerWilmer Paulino <wilmer@wilmerpaulino.com>
Mon, 20 Mar 2023 18:32:05 +0000 (11:32 -0700)
Since we don't store `pending_claim_events` within `OnchainTxHandler` as
they'll be regenerated on restarts, we opt to implement `PartialEq`
manually such that the field is not longer considered.

lightning/src/chain/onchaintx.rs

index d3ca02ca7a555114970976fc06dabbe408747b99..719d8314cbc5c4a515ab7c71cf8dacd25d9c9994 100644 (file)
@@ -215,7 +215,6 @@ type PackageID = [u8; 32];
 
 /// OnchainTxHandler receives claiming requests, aggregates them if it's sound, broadcast and
 /// do RBF bumping if possible.
-#[derive(PartialEq)]
 pub struct OnchainTxHandler<ChannelSigner: WriteableEcdsaChannelSigner> {
        destination_script: Script,
        holder_commitment: HolderCommitmentTransaction,
@@ -265,6 +264,22 @@ pub struct OnchainTxHandler<ChannelSigner: WriteableEcdsaChannelSigner> {
        pub(super) secp_ctx: Secp256k1<secp256k1::All>,
 }
 
+impl<ChannelSigner: WriteableEcdsaChannelSigner> PartialEq for OnchainTxHandler<ChannelSigner> {
+       fn eq(&self, other: &Self) -> bool {
+               // `signer`, `secp_ctx`, and `pending_claim_events` are excluded on purpose.
+               self.destination_script == other.destination_script &&
+                       self.holder_commitment == other.holder_commitment &&
+                       self.holder_htlc_sigs == other.holder_htlc_sigs &&
+                       self.prev_holder_commitment == other.prev_holder_commitment &&
+                       self.prev_holder_htlc_sigs == other.prev_holder_htlc_sigs &&
+                       self.channel_transaction_parameters == other.channel_transaction_parameters &&
+                       self.pending_claim_requests == other.pending_claim_requests &&
+                       self.claimable_outpoints == other.claimable_outpoints &&
+                       self.locktimed_packages == other.locktimed_packages &&
+                       self.onchain_events_awaiting_threshold_conf == other.onchain_events_awaiting_threshold_conf
+       }
+}
+
 const SERIALIZATION_VERSION: u8 = 1;
 const MIN_SERIALIZATION_VERSION: u8 = 1;