Skip to content

Commit

Permalink
Fix GoDoc for storage.NewBoltClient(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippgille committed Oct 7, 2018
1 parent 4e8be51 commit 8ad863a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vNext

- Fixed: When using the Echo middleware the invoice response status code was 200 OK instead of 402 Payment Required (issue [#30](https://github.com/philippgille/ln-paywall/issues/30))
- Fixed: When using the Echo middleware error responses (including the invoice) were wrapped in JSON instead of just text (issue [#30](https://github.com/philippgille/ln-paywall/issues/30))
- Fixed: GoDoc for `storage.NewBoltClient(...)` contained usage suggestions that would lead to the possibility of clients cheating with reusing preimages

v0.5.1 (2018-10-02)
-------------------
Expand Down
17 changes: 12 additions & 5 deletions storage/bolt.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,23 @@ var DefaultBoltOptions = BoltOptions{

// NewBoltClient creates a new BoltClient.
// Note: Bolt uses an exclusive write lock on the database file so it cannot be shared by multiple processes.
// This shouldn't be a problem when you use one file for one middleware, like this:
// For preventing clients from cheating (reusing preimages across different endpoints / middlewares that use
// different Bolt DB files) and for the previous mentioned reason you should use only one BoltClient.
// For example:
// // ...
// boltClient, err := storage.NewBoltClient(storage.DefaultBoltOptions) // Uses file "ln-paywall.db"
// storageClient, err := storage.NewBoltClient(storage.DefaultBoltOptions) // Uses file "ln-paywall.db"
// if err != nil {
// panic(err)
// }
// defer boltClient.Close()
// r.Use(wall.NewGinMiddleware(invoiceOptions, lndOptions, boltClient))
// cheapPaywall := wall.NewGinMiddleware(cheapInvoiceOptions, lnClient, storageClient)
// expensivePaywall := wall.NewGinMiddleware(expensiveInvoiceOptions, lnClient, storageClient)
// router.GET("/ping", cheapPaywall, pingHandler)
// router.GET("/compute", expensivePaywall, computeHandler)
// // ...
// Also don't worry about closing the Bolt DB, the middleware opens it once and uses it for the duration of its lifetime.
// If you want to start an additional web service, this would be an additional process, so you can't use the same
// DB file. You should look into the other storage options in this case, for example Redis.
//
// Don't worry about closing the Bolt DB, the middleware opens it once and uses it for the duration of its lifetime.
// When the web service is stopped, the DB file lock is released automatically.
func NewBoltClient(boltOptions BoltOptions) (BoltClient, error) {
result := BoltClient{}
Expand Down

0 comments on commit 8ad863a

Please sign in to comment.