mirror of
https://github.com/fiatjaf/nak.git
synced 2025-12-08 16:48:51 +00:00
adapt serve to variable max eventstores.
This commit is contained in:
11
serve.go
11
serve.go
@@ -4,7 +4,6 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -38,7 +37,7 @@ var serve = &cli.Command{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Action: func(ctx context.Context, c *cli.Command) error {
|
Action: func(ctx context.Context, c *cli.Command) error {
|
||||||
db := &slicestore.SliceStore{MaxLimit: math.MaxInt}
|
db := &slicestore.SliceStore{}
|
||||||
|
|
||||||
var scanner *bufio.Scanner
|
var scanner *bufio.Scanner
|
||||||
if path := c.String("events"); path != "" {
|
if path := c.String("events"); path != "" {
|
||||||
@@ -71,7 +70,7 @@ var serve = &cli.Command{
|
|||||||
rl.Info.Software = "https://github.com/fiatjaf/nak"
|
rl.Info.Software = "https://github.com/fiatjaf/nak"
|
||||||
rl.Info.Version = version
|
rl.Info.Version = version
|
||||||
|
|
||||||
rl.UseEventstore(db)
|
rl.UseEventstore(db, 1_000_000)
|
||||||
|
|
||||||
started := make(chan bool)
|
started := make(chan bool)
|
||||||
exited := make(chan error)
|
exited := make(chan error)
|
||||||
@@ -108,9 +107,9 @@ var serve = &cli.Command{
|
|||||||
d := debounce.New(time.Second * 2)
|
d := debounce.New(time.Second * 2)
|
||||||
printStatus = func() {
|
printStatus = func() {
|
||||||
d(func() {
|
d(func() {
|
||||||
totalEvents := 0
|
totalEvents, err := db.CountEvents(nostr.Filter{})
|
||||||
for range db.QueryEvents(nostr.Filter{}) {
|
if err != nil {
|
||||||
totalEvents++
|
log("failed to count: %s\n", err)
|
||||||
}
|
}
|
||||||
subs := rl.GetListeningFilters()
|
subs := rl.GetListeningFilters()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user