From 9bc24f8dbfff90344f765c3a8ea3c965f537308f Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 15 Apr 2019 22:00:38 +0100 Subject: [PATCH] Return both current and previous config when replacing --- src/config/config.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/config/config.go b/src/config/config.go index 861e57a..8137cac 100644 --- a/src/config/config.go +++ b/src/config/config.go @@ -23,13 +23,14 @@ func (s *NodeState) Get() (NodeConfig, NodeConfig) { return s.Current, s.Previous } -// Replace the node configuration with new configuration -func (s *NodeState) Replace(n NodeConfig) NodeConfig { +// Replace the node configuration with new configuration. This method returns +// both the new and the previous node configs +func (s *NodeState) Replace(n NodeConfig) (NodeConfig, NodeConfig) { s.Mutex.Lock() defer s.Mutex.Unlock() s.Previous = s.Current s.Current = n - return s.Current + return s.Current, s.Previous } // NodeConfig defines all configuration values needed to run a signle yggdrasil node