Skip to content
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

feat: delete old ldk payments #1092

Merged
merged 2 commits into from
Feb 14, 2025
Merged

feat: delete old ldk payments #1092

merged 2 commits into from
Feb 14, 2025

Conversation

rolznz
Copy link
Contributor

@rolznz rolznz commented Feb 13, 2025

Fixes #1073

When we store a lot of payments in VSS it slows down startup a lot, because LDK must fetch all the data one key at a time to build the node. We do not need the old expired payments to be stored by LDK because we also store transactions stored in Alby Hub.

This does set the maximum of invoice expiry to 1 day to ensure we do not remove old payments that are not expired yet. I do not think any service needs longer invoice expiry than one day though?

@rolznz rolznz requested review from rdmitr and im-adithya February 13, 2025 10:08
@rolznz rolznz added this to the v1.14.1 milestone Feb 13, 2025
for _, payment := range payments {
paymentCreatedAt := time.Unix(int64(payment.CreatedAt), 0)
if paymentCreatedAt.Add(maxInvoiceExpiry * time.Second).Before(now) {
logger.Logger.WithField("created_at", paymentCreatedAt).Debug("Deleting old payment")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log payment id here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

@@ -50,6 +50,7 @@ type LDKService struct {
}

const resetRouterKey = "ResetRouter"
const maxInvoiceExpiry = 86400 // 1 day
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: use time.Duration for readability and ergonomics? I.e. time.Hour * 24

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks

@rolznz rolznz merged commit 6ca11b2 into master Feb 14, 2025
10 checks passed
@rolznz rolznz deleted the feat/delete-old-ldk-payments branch February 14, 2025 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hubs with VSS sometimes take a long time to start
2 participants