Skip to content

Commit 87c4cf9

Browse files
committed
Implement PartialEq manually
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.
1 parent 48fa2fd commit 87c4cf9

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

lightning/src/chain/onchaintx.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ type PackageID = [u8; 32];
215215

216216
/// OnchainTxHandler receives claiming requests, aggregates them if it's sound, broadcast and
217217
/// do RBF bumping if possible.
218-
#[derive(PartialEq)]
219218
pub struct OnchainTxHandler<ChannelSigner: WriteableEcdsaChannelSigner> {
220219
destination_script: Script,
221220
holder_commitment: HolderCommitmentTransaction,
@@ -265,6 +264,22 @@ pub struct OnchainTxHandler<ChannelSigner: WriteableEcdsaChannelSigner> {
265264
pub(super) secp_ctx: Secp256k1<secp256k1::All>,
266265
}
267266

267+
impl<ChannelSigner: WriteableEcdsaChannelSigner> PartialEq for OnchainTxHandler<ChannelSigner> {
268+
fn eq(&self, other: &Self) -> bool {
269+
// `signer`, `secp_ctx`, and `pending_claim_events` are excluded on purpose.
270+
self.destination_script == other.destination_script &&
271+
self.holder_commitment == other.holder_commitment &&
272+
self.holder_htlc_sigs == other.holder_htlc_sigs &&
273+
self.prev_holder_commitment == other.prev_holder_commitment &&
274+
self.prev_holder_htlc_sigs == other.prev_holder_htlc_sigs &&
275+
self.channel_transaction_parameters == other.channel_transaction_parameters &&
276+
self.pending_claim_requests == other.pending_claim_requests &&
277+
self.claimable_outpoints == other.claimable_outpoints &&
278+
self.locktimed_packages == other.locktimed_packages &&
279+
self.onchain_events_awaiting_threshold_conf == other.onchain_events_awaiting_threshold_conf
280+
}
281+
}
282+
268283
const SERIALIZATION_VERSION: u8 = 1;
269284
const MIN_SERIALIZATION_VERSION: u8 = 1;
270285

0 commit comments

Comments
 (0)