mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	Return both current and previous config when replacing
This commit is contained in:
		
							parent
							
								
									2e72c7c93d
								
							
						
					
					
						commit
						9bc24f8dbf
					
				
					 1 changed files with 4 additions and 3 deletions
				
			
		| 
						 | 
					@ -23,13 +23,14 @@ func (s *NodeState) Get() (NodeConfig, NodeConfig) {
 | 
				
			||||||
	return s.Current, s.Previous
 | 
						return s.Current, s.Previous
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Replace the node configuration with new configuration
 | 
					// Replace the node configuration with new configuration. This method returns
 | 
				
			||||||
func (s *NodeState) Replace(n NodeConfig) NodeConfig {
 | 
					// both the new and the previous node configs
 | 
				
			||||||
 | 
					func (s *NodeState) Replace(n NodeConfig) (NodeConfig, NodeConfig) {
 | 
				
			||||||
	s.Mutex.Lock()
 | 
						s.Mutex.Lock()
 | 
				
			||||||
	defer s.Mutex.Unlock()
 | 
						defer s.Mutex.Unlock()
 | 
				
			||||||
	s.Previous = s.Current
 | 
						s.Previous = s.Current
 | 
				
			||||||
	s.Current = n
 | 
						s.Current = n
 | 
				
			||||||
	return s.Current
 | 
						return s.Current, s.Previous
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NodeConfig defines all configuration values needed to run a signle yggdrasil node
 | 
					// NodeConfig defines all configuration values needed to run a signle yggdrasil node
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue