-
Notifications
You must be signed in to change notification settings - Fork 58
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
Conversation
aperture.go
Outdated
challenger, err = NewLndChallenger(cfg.Authenticator, | ||
genInvoiceReq, | ||
nil) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
?
Thanks @wpaulino for the look. Added those changes, rebased, and cleaned up commits. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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{ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Sorry about the delay on this, side project. I'll try to get the fixes in this weekend, thanks! |
@anthonyronning, remember to re-request review from reviewers for your latest update |
1 similar comment
@anthonyronning, remember to re-request review from reviewers for your latest update |
Closing due to inactivity. |
Discussion here: #45