cli: also check new ApplicationConfiguration for consistency
Most of the settings can't be changed, only services can.
This commit is contained in:
parent
3fca3352d8
commit
94099de3c3
3 changed files with 48 additions and 0 deletions
|
@ -538,6 +538,10 @@ Main:
|
|||
log.Warn("ProtocolConfiguration changed, signal ignored")
|
||||
break // Continue working.
|
||||
}
|
||||
if !cfg.ApplicationConfiguration.EqualsButServices(&cfgnew.ApplicationConfiguration) {
|
||||
log.Warn("ApplicationConfiguration changed in incompatible way, signal ignored")
|
||||
break // Continue working.
|
||||
}
|
||||
switch sig {
|
||||
case syscall.SIGHUP:
|
||||
rpcServer.Shutdown()
|
||||
|
|
|
@ -29,3 +29,25 @@ type ApplicationConfiguration struct {
|
|||
// ExtensiblePoolSize is the maximum amount of the extensible payloads from a single sender.
|
||||
ExtensiblePoolSize int `yaml:"ExtensiblePoolSize"`
|
||||
}
|
||||
|
||||
// EqualsButServices returns true when the o is the same as a except for services
|
||||
// (Oracle, P2PNotary, Pprof, Prometheus, RPC, StateRoot and UnlockWallet sections).
|
||||
func (a *ApplicationConfiguration) EqualsButServices(o *ApplicationConfiguration) bool {
|
||||
if a.Address != o.Address ||
|
||||
a.AnnouncedNodePort != o.AnnouncedNodePort ||
|
||||
a.AttemptConnPeers != o.AttemptConnPeers ||
|
||||
a.DBConfiguration != o.DBConfiguration ||
|
||||
a.DialTimeout != o.DialTimeout ||
|
||||
a.ExtensiblePoolSize != o.ExtensiblePoolSize ||
|
||||
a.LogPath != o.LogPath ||
|
||||
a.MaxPeers != o.MaxPeers ||
|
||||
a.MinPeers != o.MinPeers ||
|
||||
a.NodePort != o.NodePort ||
|
||||
a.PingInterval != o.PingInterval ||
|
||||
a.PingTimeout != o.PingTimeout ||
|
||||
a.ProtoTickInterval != o.ProtoTickInterval ||
|
||||
a.Relay != o.Relay {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
22
pkg/config/application_config_test.go
Normal file
22
pkg/config/application_config_test.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestApplicationConfigurationEquals(t *testing.T) {
|
||||
a := &ApplicationConfiguration{}
|
||||
o := &ApplicationConfiguration{}
|
||||
require.True(t, a.EqualsButServices(o))
|
||||
require.True(t, o.EqualsButServices(a))
|
||||
require.True(t, a.EqualsButServices(a))
|
||||
|
||||
cfg1, err := LoadFile(filepath.Join("..", "..", "config", "protocol.mainnet.yml"))
|
||||
require.NoError(t, err)
|
||||
cfg2, err := LoadFile(filepath.Join("..", "..", "config", "protocol.testnet.yml"))
|
||||
require.NoError(t, err)
|
||||
require.False(t, cfg1.ApplicationConfiguration.EqualsButServices(&cfg2.ApplicationConfiguration))
|
||||
}
|
Loading…
Reference in a new issue