-
Notifications
You must be signed in to change notification settings - Fork 411
Avoid generating redundant claims after initial confirmation #1753
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -430,7 +430,43 @@ impl<ChannelSigner: Sign> OnchainTxHandler<ChannelSigner> { | |
where F::Target: FeeEstimator, | ||
L::Target: Logger, | ||
{ | ||
if cached_request.outpoints().len() == 0 { return None } // But don't prune pending claiming request yet, we may have to resurrect HTLCs | ||
let request_outpoints = cached_request.outpoints(); | ||
if request_outpoints.is_empty() { | ||
// Don't prune pending claiming request yet, we may have to resurrect HTLCs. Untractable | ||
// packages cannot be aggregated and will never be split, so we cannot end up with an | ||
// empty claim. | ||
debug_assert!(cached_request.is_malleable()); | ||
return None; | ||
} | ||
// If we've seen transaction inclusion in the chain for all outpoints in our request, we | ||
// don't need to continue generating more claims. We'll keep tracking the request to fully | ||
// remove it once it reaches the confirmation threshold, or to generate a new claim if the | ||
// transaction is reorged out. | ||
let mut all_inputs_have_confirmed_spend = true; | ||
for outpoint in &request_outpoints { | ||
if let Some(first_claim_txid_height) = self.claimable_outpoints.get(outpoint) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. btw, this variable name is a bit confusing, because it sounds like it's the height of the txid, but it's actually the (txid, height) tuple There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that said, I don't have any better ideas ¯_(ツ)_/¯ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its copied from another of other places, so if we want to change it ISTM we should do it broadly through the file and in a followup. |
||
// We check for outpoint spends within claims individually rather than as a set | ||
// since requests can have outpoints split off. | ||
if !self.onchain_events_awaiting_threshold_conf.iter() | ||
.any(|event_entry| if let OnchainEvent::Claim { claim_request } = event_entry.event { | ||
first_claim_txid_height.0 == claim_request | ||
} else { | ||
// The onchain event is not a claim, keep seeking until we find one. | ||
false | ||
}) | ||
{ | ||
// Either we had no `OnchainEvent::Claim`, or we did but none matched the | ||
// outpoint's registered spend. | ||
all_inputs_have_confirmed_spend = false; | ||
} | ||
} else { | ||
// The request's outpoint spend does not exist yet. | ||
all_inputs_have_confirmed_spend = false; | ||
} | ||
} | ||
if all_inputs_have_confirmed_spend { | ||
return None; | ||
} | ||
|
||
// Compute new height timer to decide when we need to regenerate a new bumped version of the claim tx (if we | ||
// didn't receive confirmation of it before, or not enough reorg-safe depth on top of it). | ||
|
Uh oh!
There was an error while loading. Please reload this page.