diff --git a/cli/server/server.go b/cli/server/server.go index 5f80bf42b..e864642d4 100644 --- a/cli/server/server.go +++ b/cli/server/server.go @@ -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() diff --git a/pkg/config/application_config.go b/pkg/config/application_config.go index cbf7be3d1..ac6db77af 100644 --- a/pkg/config/application_config.go +++ b/pkg/config/application_config.go @@ -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 +} diff --git a/pkg/config/application_config_test.go b/pkg/config/application_config_test.go new file mode 100644 index 000000000..8b5428e8f --- /dev/null +++ b/pkg/config/application_config_test.go @@ -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)) +}