config: use CLI worker configuration instead of NumCPU()

This commit is contained in:
Conner Fromknecht 2019-03-13 20:32:39 -07:00
parent 3f181b3c06
commit 76116f0d1a
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7
2 changed files with 10 additions and 4 deletions

View File

@ -252,6 +252,8 @@ type config struct {
net tor.Net
Routing *routing.Conf `group:"routing" namespace:"routing"`
Workers *lncfg.Workers `group:"workers" namespace:"workers"`
}
// loadConfig initializes and parses the config using a config file and command
@ -334,6 +336,11 @@ func loadConfig() (*config, error) {
Control: defaultTorControl,
},
net: &tor.ClearNet{},
Workers: &lncfg.Workers{
Read: lncfg.DefaultReadWorkers,
Write: lncfg.DefaultWriteWorkers,
Sig: lncfg.DefaultSigWorkers,
},
}
// Pre-parse the command line options to pick up an alternative config

View File

@ -11,7 +11,6 @@ import (
"net"
"path/filepath"
"regexp"
"runtime"
"strconv"
"sync"
"sync/atomic"
@ -272,7 +271,7 @@ func newServer(listenAddrs []net.Addr, chanDB *channeldb.DB, cc *chainControl,
)
writePool := pool.NewWrite(
writeBufferPool, runtime.NumCPU(), pool.DefaultWorkerTimeout,
writeBufferPool, cfg.Workers.Write, pool.DefaultWorkerTimeout,
)
readBufferPool := pool.NewReadBuffer(
@ -281,13 +280,13 @@ func newServer(listenAddrs []net.Addr, chanDB *channeldb.DB, cc *chainControl,
)
readPool := pool.NewRead(
readBufferPool, runtime.NumCPU(), pool.DefaultWorkerTimeout,
readBufferPool, cfg.Workers.Read, pool.DefaultWorkerTimeout,
)
s := &server{
chanDB: chanDB,
cc: cc,
sigPool: lnwallet.NewSigPool(runtime.NumCPU()*2, cc.signer),
sigPool: lnwallet.NewSigPool(cfg.Workers.Sig, cc.signer),
writePool: writePool,
readPool: readPool,