Merge pull request #4089 from fguisso/acceptor
rpcserver: parameterize acceptortimeout
This commit is contained in:
commit
9f5f48b20d
38
config.go
38
config.go
@ -125,6 +125,10 @@ const (
|
|||||||
// HTLCs on our channels.
|
// HTLCs on our channels.
|
||||||
minTimeLockDelta = 4
|
minTimeLockDelta = 4
|
||||||
|
|
||||||
|
// defaultAcceptorTimeout is the time after which an RPCAcceptor will time
|
||||||
|
// out and return false if it hasn't yet received a response.
|
||||||
|
defaultAcceptorTimeout = 15 * time.Second
|
||||||
|
|
||||||
defaultAlias = ""
|
defaultAlias = ""
|
||||||
defaultColor = "#3399FF"
|
defaultColor = "#3399FF"
|
||||||
)
|
)
|
||||||
@ -252,13 +256,14 @@ type config struct {
|
|||||||
TLSExtraDomains []string `long:"tlsextradomain" description:"Adds an extra domain to the generated certificate"`
|
TLSExtraDomains []string `long:"tlsextradomain" description:"Adds an extra domain to the generated certificate"`
|
||||||
TLSAutoRefresh bool `long:"tlsautorefresh" description:"Re-generate TLS certificate and key if the IPs or domains are changed"`
|
TLSAutoRefresh bool `long:"tlsautorefresh" description:"Re-generate TLS certificate and key if the IPs or domains are changed"`
|
||||||
|
|
||||||
NoMacaroons bool `long:"no-macaroons" description:"Disable macaroon authentication"`
|
NoMacaroons bool `long:"no-macaroons" description:"Disable macaroon authentication"`
|
||||||
AdminMacPath string `long:"adminmacaroonpath" description:"Path to write the admin macaroon for lnd's RPC and REST services if it doesn't exist"`
|
AdminMacPath string `long:"adminmacaroonpath" description:"Path to write the admin macaroon for lnd's RPC and REST services if it doesn't exist"`
|
||||||
ReadMacPath string `long:"readonlymacaroonpath" description:"Path to write the read-only macaroon for lnd's RPC and REST services if it doesn't exist"`
|
ReadMacPath string `long:"readonlymacaroonpath" description:"Path to write the read-only macaroon for lnd's RPC and REST services if it doesn't exist"`
|
||||||
InvoiceMacPath string `long:"invoicemacaroonpath" description:"Path to the invoice-only macaroon for lnd's RPC and REST services if it doesn't exist"`
|
InvoiceMacPath string `long:"invoicemacaroonpath" description:"Path to the invoice-only macaroon for lnd's RPC and REST services if it doesn't exist"`
|
||||||
LogDir string `long:"logdir" description:"Directory to log output."`
|
LogDir string `long:"logdir" description:"Directory to log output."`
|
||||||
MaxLogFiles int `long:"maxlogfiles" description:"Maximum logfiles to keep (0 for no rotation)"`
|
MaxLogFiles int `long:"maxlogfiles" description:"Maximum logfiles to keep (0 for no rotation)"`
|
||||||
MaxLogFileSize int `long:"maxlogfilesize" description:"Maximum logfile size in MB"`
|
MaxLogFileSize int `long:"maxlogfilesize" description:"Maximum logfile size in MB"`
|
||||||
|
AcceptorTimeout time.Duration `long:"acceptortimeout" description:"Time after which an RPCAcceptor will time out and return false if it hasn't yet received a response"`
|
||||||
|
|
||||||
// We'll parse these 'raw' string arguments into real net.Addrs in the
|
// We'll parse these 'raw' string arguments into real net.Addrs in the
|
||||||
// loadConfig function. We need to expose the 'raw' strings so the
|
// loadConfig function. We need to expose the 'raw' strings so the
|
||||||
@ -368,15 +373,16 @@ type config struct {
|
|||||||
// 4) Parse CLI options and overwrite/add any specified options
|
// 4) Parse CLI options and overwrite/add any specified options
|
||||||
func loadConfig() (*config, error) {
|
func loadConfig() (*config, error) {
|
||||||
defaultCfg := config{
|
defaultCfg := config{
|
||||||
LndDir: defaultLndDir,
|
LndDir: defaultLndDir,
|
||||||
ConfigFile: defaultConfigFile,
|
ConfigFile: defaultConfigFile,
|
||||||
DataDir: defaultDataDir,
|
DataDir: defaultDataDir,
|
||||||
DebugLevel: defaultLogLevel,
|
DebugLevel: defaultLogLevel,
|
||||||
TLSCertPath: defaultTLSCertPath,
|
TLSCertPath: defaultTLSCertPath,
|
||||||
TLSKeyPath: defaultTLSKeyPath,
|
TLSKeyPath: defaultTLSKeyPath,
|
||||||
LogDir: defaultLogDir,
|
LogDir: defaultLogDir,
|
||||||
MaxLogFiles: defaultMaxLogFiles,
|
MaxLogFiles: defaultMaxLogFiles,
|
||||||
MaxLogFileSize: defaultMaxLogFileSize,
|
MaxLogFileSize: defaultMaxLogFileSize,
|
||||||
|
AcceptorTimeout: defaultAcceptorTimeout,
|
||||||
Bitcoin: &chainConfig{
|
Bitcoin: &chainConfig{
|
||||||
MinHTLCIn: defaultBitcoinMinHTLCInMSat,
|
MinHTLCIn: defaultBitcoinMinHTLCInMSat,
|
||||||
MinHTLCOut: defaultBitcoinMinHTLCOutMSat,
|
MinHTLCOut: defaultBitcoinMinHTLCOutMSat,
|
||||||
|
14
rpcserver.go
14
rpcserver.go
@ -85,12 +85,6 @@ var (
|
|||||||
// It is set to the value under the Bitcoin chain as default.
|
// It is set to the value under the Bitcoin chain as default.
|
||||||
MaxPaymentMSat = maxBtcPaymentMSat
|
MaxPaymentMSat = maxBtcPaymentMSat
|
||||||
|
|
||||||
// defaultAcceptorTimeout is the time after which an RPCAcceptor will time
|
|
||||||
// out and return false if it hasn't yet received a response.
|
|
||||||
//
|
|
||||||
// TODO: Make this configurable
|
|
||||||
defaultAcceptorTimeout = 15 * time.Second
|
|
||||||
|
|
||||||
// readPermissions is a slice of all entities that allow read
|
// readPermissions is a slice of all entities that allow read
|
||||||
// permissions for authorization purposes, all lowercase.
|
// permissions for authorization purposes, all lowercase.
|
||||||
readPermissions = []bakery.Op{
|
readPermissions = []bakery.Op{
|
||||||
@ -6020,14 +6014,14 @@ func (r *rpcServer) ChannelAcceptor(stream lnrpc.Lightning_ChannelAcceptorServer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// timeout is the time after which ChannelAcceptRequests expire.
|
// timeout is the time after which ChannelAcceptRequests expire.
|
||||||
timeout := time.After(defaultAcceptorTimeout)
|
timeout := time.After(cfg.AcceptorTimeout)
|
||||||
|
|
||||||
// Send the request to the newRequests channel.
|
// Send the request to the newRequests channel.
|
||||||
select {
|
select {
|
||||||
case newRequests <- newRequest:
|
case newRequests <- newRequest:
|
||||||
case <-timeout:
|
case <-timeout:
|
||||||
rpcsLog.Errorf("RPCAcceptor returned false - reached timeout of %d",
|
rpcsLog.Errorf("RPCAcceptor returned false - reached timeout of %d",
|
||||||
defaultAcceptorTimeout)
|
cfg.AcceptorTimeout)
|
||||||
return false
|
return false
|
||||||
case <-quit:
|
case <-quit:
|
||||||
return false
|
return false
|
||||||
@ -6036,13 +6030,13 @@ func (r *rpcServer) ChannelAcceptor(stream lnrpc.Lightning_ChannelAcceptorServer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Receive the response and return it. If no response has been received
|
// Receive the response and return it. If no response has been received
|
||||||
// in defaultAcceptorTimeout, then return false.
|
// in AcceptorTimeout, then return false.
|
||||||
select {
|
select {
|
||||||
case resp := <-respChan:
|
case resp := <-respChan:
|
||||||
return resp
|
return resp
|
||||||
case <-timeout:
|
case <-timeout:
|
||||||
rpcsLog.Errorf("RPCAcceptor returned false - reached timeout of %d",
|
rpcsLog.Errorf("RPCAcceptor returned false - reached timeout of %d",
|
||||||
defaultAcceptorTimeout)
|
cfg.AcceptorTimeout)
|
||||||
return false
|
return false
|
||||||
case <-quit:
|
case <-quit:
|
||||||
return false
|
return false
|
||||||
|
@ -22,6 +22,11 @@
|
|||||||
; Max log file size in MB before it is rotated.
|
; Max log file size in MB before it is rotated.
|
||||||
; maxlogfilesize=10
|
; maxlogfilesize=10
|
||||||
|
|
||||||
|
; Time after which an RPCAcceptor will time out and return false if
|
||||||
|
; it hasn't yet received a response.
|
||||||
|
; acceptortimeout=15s
|
||||||
|
|
||||||
|
|
||||||
; Path to TLS certificate for lnd's RPC and REST services.
|
; Path to TLS certificate for lnd's RPC and REST services.
|
||||||
; tlscertpath=~/.lnd/tls.cert
|
; tlscertpath=~/.lnd/tls.cert
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user