diff --git a/claimtrie/cmd/cmd/root.go b/claimtrie/cmd/cmd/root.go index 742b2d5e..8b2fb75f 100644 --- a/claimtrie/cmd/cmd/root.go +++ b/claimtrie/cmd/cmd/root.go @@ -6,6 +6,7 @@ import ( "github.com/btcsuite/btclog" "github.com/lbryio/lbcd/claimtrie/config" "github.com/lbryio/lbcd/claimtrie/param" + "github.com/lbryio/lbcd/limits" "github.com/lbryio/lbcd/wire" "github.com/spf13/cobra" @@ -51,5 +52,10 @@ func Execute() { log = backendLogger.Logger("CMDL") log.SetLevel(btclog.LevelDebug) + // Up some limits. + if err := limits.SetLimits(); err != nil { + log.Errorf("failed to set limits: %v\n", err) + } + rootCmd.Execute() // nolint : errchk } diff --git a/claimtrie/cmd/cmd/temporal.go b/claimtrie/cmd/cmd/temporal.go index 52613fcd..67d3397c 100644 --- a/claimtrie/cmd/cmd/temporal.go +++ b/claimtrie/cmd/cmd/temporal.go @@ -31,7 +31,11 @@ func NewTemporalCommand() *cobra.Command { return errors.Wrapf(err, "open temporal repo") } - for ht := fromHeight; ht < toHeight; ht++ { + if toHeight <= 0 { + toHeight = fromHeight + } + + for ht := fromHeight; ht <= toHeight; ht++ { names, err := repo.NodesAt(ht) if err != nil { return errors.Wrapf(err, "get node names from temporal") diff --git a/claimtrie/config/config.go b/claimtrie/config/config.go index 3e223ca0..73e2fb33 100644 --- a/claimtrie/config/config.go +++ b/claimtrie/config/config.go @@ -2,33 +2,11 @@ package config import ( "path/filepath" - "syscall" "github.com/lbryio/lbcd/claimtrie/param" btcutil "github.com/lbryio/lbcutil" ) -func init() { - // ensure that we have enough file handles - var rLimit syscall.Rlimit - err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit) - if err != nil { - panic("Error getting File Handle RLimit: " + err.Error()) - } - minRequiredFileHandles := uint64(24000) // seven databases and they each require ~2000, plus a few more to be safe - if rLimit.Max < minRequiredFileHandles { - panic("Error increasing File Handle RLimit: increasing file handle limit requires " + - "unavailable privileges. Allow at least 24000 handles.") - } - if rLimit.Cur < minRequiredFileHandles { - rLimit.Cur = minRequiredFileHandles - err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit) - if err != nil { - panic("Error setting File Handle RLimit to 24000: " + err.Error()) - } - } -} - var DefaultConfig = Config{ Params: param.MainNet, diff --git a/limits/limits_unix.go b/limits/limits_unix.go index 7972b05e..f8511458 100644 --- a/limits/limits_unix.go +++ b/limits/limits_unix.go @@ -13,8 +13,8 @@ import ( ) const ( - fileLimitWant = 2048 - fileLimitMin = 1024 + fileLimitWant = 2048 * 12 + fileLimitMin = 2048 * 8 ) // SetLimits raises some process limits to values which allow btcd and