Skip to content

Commit

Permalink
add env var controlling msgs sync epochs
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzo committed Nov 5, 2020
1 parent 0e40a04 commit dab20ef
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions node/modules/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package modules

import (
"context"
"os"
"strconv"
"time"

"github.com/ipfs/go-datastore"
Expand Down Expand Up @@ -36,6 +38,19 @@ import (
"github.com/filecoin-project/lotus/node/repo"
)

var pubsubMsgsSyncEpochs = 10

func init() {
if s := os.Getenv("LOTUS_MSGS_SYNC_EPOCHS"); s != "" {
val, err := strconv.Atoi(s)
if err != nil {
log.Errorf("failed to parse LOTUS_MSGS_SYNC_EPOCHS: %s", err)
return
}
pubsubMsgsSyncEpochs = val
}
}

func RunHello(mctx helpers.MetricsCtx, lc fx.Lifecycle, h host.Host, svc *hello.Service) error {
h.SetStreamHandler(hello.ProtocolID, svc.HandleStream)

Expand Down Expand Up @@ -169,8 +184,8 @@ func HandleIncomingMessages(mctx helpers.MetricsCtx, lc fx.Lifecycle, ps *pubsub
return
}

// wait until we are synced within 10 epochs
waitForSync(stmgr, 10, subscribe)
// wait until we are synced within 10 epochs -- env var can override
waitForSync(stmgr, pubsubMsgsSyncEpochs, subscribe)
}

func NewLocalDiscovery(lc fx.Lifecycle, ds dtypes.MetadataDS) (*discoveryimpl.Local, error) {
Expand Down

0 comments on commit dab20ef

Please sign in to comment.