5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-09-20 03:42:32 +00:00

Return both current and previous config when replacing

This commit is contained in:
Neil Alexander 2019-04-15 22:00:38 +01:00
parent 2e72c7c93d
commit 9bc24f8dbf
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944

View File

@ -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