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

multi: add payment request processing. #140

Merged
merged 1 commit into from
Dec 3, 2019

Conversation

dnldd
Copy link
Member

@dnldd dnldd commented Nov 13, 2019

This implements payment processing infrastructure to the pool and fixes an off-by-one bug regarding pruning eligible payments based on the minimum allowed amount.

@dnldd dnldd marked this pull request as ready for review November 25, 2019 09:53
Copy link
Member

@jholdstock jholdstock left a comment

Choose a reason for hiding this comment

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

Looks good to me, just added one question

maturePayments, err := FetchMaturePendingPayments(db, height)
if err != nil {
return nil, err
}

bundles := generatePaymentBundles(maturePayments)
for idx := 0; idx < len(bundles); idx++ {
for idx := len(bundles) - 1; idx >= 0; idx-- {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason this is iterating backwards? Might be nice to explain this unusual loop with a comment

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, iterating backwards is convenient here because the slice gets updated (via deletion) during iteration. When that happens the current index decrements (i--), iterating backwards already takes care of the decrement if there should be a deletion. It's ideal as result.

Copy link
Member

Choose a reason for hiding this comment

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

Clever. Definitely worth a comment to ensure people don't try and change this in future

This implements payment processing infrastructure to
the pool and fixes an off-by-one bug regarding pruning
eligible payments based on the minimum allowed amount.
@dnldd dnldd merged commit 4c8602b into decred:master Dec 3, 2019
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.

3 participants