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

Aperture as a library - nice to have's #44

Closed
wants to merge 3 commits into from
Closed

Aperture as a library - nice to have's #44

wants to merge 3 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Sep 19, 2020

Discussion here: #45

aperture.go Outdated
Comment on lines 114 to 116
challenger, err = NewLndChallenger(cfg.Authenticator,
genInvoiceReq,
nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: our preferred style here would be:

challenger, err = NewLndChallenger(
    cfg.Authenticator, genInvoiceReq, nil,
)

challenger.go Outdated
//
// NOTE: This is part of the auth.InvoiceChecker interface.
func (l *LndChallenger) VerifyInvoiceStatus(hash lntypes.Hash,
state lnrpc.Invoice_InvoiceState, timeout time.Duration) error {
if l.verifyInvoiceStatus != nil {
Copy link
Contributor

@wpaulino wpaulino Sep 23, 2020

Choose a reason for hiding this comment

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

Is this check necessary given that NewLndChallenger sets this to non-nil when provided a nil VerifyInvoiceStatus?

@ghost
Copy link
Author

ghost commented Oct 3, 2020

Thanks @wpaulino for the look. Added those changes, rebased, and cleaned up commits.

Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Great idea, solid concept ACK from me 💯

Just a few nits and a small thing that is missing, otherwise looks pretty good!

capabilities map[lsat.Service]lsat.Caveat
constraints map[lsat.Service][]lsat.Caveat
type StaticServiceLimiter struct {
Capabilities map[lsat.Service]lsat.Caveat
Copy link
Member

Choose a reason for hiding this comment

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

nit: Exported fields should have godoc comments.

@@ -41,8 +41,8 @@ type InvoiceClient interface {
// LndChallenger is a challenger that uses an lnd backend to create new LSAT
// payment challenges.
type LndChallenger struct {
client InvoiceClient
genInvoiceReq InvoiceRequestGenerator
Client InvoiceClient
Copy link
Member

Choose a reason for hiding this comment

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

nit: exported fields should have godoc comments. This also removes the need for the large indentation as the fields will be separated a bit.

@@ -21,6 +21,9 @@ import (
// lnrpc.AddInvoice call.
type InvoiceRequestGenerator func(price int64) (*lnrpc.Invoice, error)

type VerifyInvoiceStatusFunc func(hash lntypes.Hash,
Copy link
Member

Choose a reason for hiding this comment

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

nit: godoc missing.

@@ -84,15 +88,20 @@ func NewLndChallenger(cfg *authConfig, genInvoiceReq InvoiceRequestGenerator,
}

invoicesMtx := &sync.Mutex{}
return &LndChallenger{
c := &LndChallenger{
Copy link
Member

Choose a reason for hiding this comment

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

Need to add the verifyInvoiceStatus to the struct, otherwise it won't be set if it's non-nil.

Copy link
Author

Choose a reason for hiding this comment

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

Oh wow nice catch, I think while restructuring things I completely left it out here.

Client: mockClient,
GenInvoiceReq: genInvoiceReq,
invoiceStates: make(map[lntypes.Hash]lnrpc.Invoice_InvoiceState),
quit: make(chan struct{}),
invoicesMtx: invoicesMtx,
invoicesCond: sync.NewCond(invoicesMtx),
errChan: mainErrChan,
}, mockClient, mainErrChan
}
c.VerifyInvoiceStatusFunc = c.DefaultVerifyInvoiceStatus
Copy link
Member

Choose a reason for hiding this comment

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

nit: can add directly to the struct initialization.

Copy link
Author

Choose a reason for hiding this comment

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

I think there's a problem trying to assign it directly in the struct because it relies on an initialized challenge in DefaultVerifyInvoiceStatus. Wasn't sure how much of an anti pattern it was to do it the way I did or not but the side effect of it is that it can't be initialized directly.

@wpaulino wpaulino self-requested a review October 13, 2020 01:10
@ghost
Copy link
Author

ghost commented Oct 24, 2020

Sorry about the delay on this, side project. I'll try to get the fixes in this weekend, thanks!

@wpaulino wpaulino removed their request for review January 4, 2021 23:46
@lightninglabs-deploy
Copy link
Collaborator

@anthonyronning, remember to re-request review from reviewers for your latest update

1 similar comment
@lightninglabs-deploy
Copy link
Collaborator

@anthonyronning, remember to re-request review from reviewers for your latest update

@guggero
Copy link
Member

guggero commented Dec 12, 2021

Closing due to inactivity.

@guggero guggero closed this Dec 12, 2021
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