simplify refact-left-over code

This commit is contained in:
decauwsemaecker.glen@gmail.com 2017-04-25 10:01:39 -05:00
parent 4c66a72410
commit 9a19400b08

View File

@ -119,10 +119,8 @@ func (c *Consensus) ExternalIP() (net.IP, error) {
} }
// wait for all votes to come in, // wait for all votes to come in,
// or until the voting process times out // or until their process times out
select { wg.Wait()
case <-waitWG(&wg):
}
// if no votes were casted succesfully, // if no votes were casted succesfully,
// return early with an error // return early with an error
@ -148,14 +146,3 @@ func (c *Consensus) ExternalIP() (net.IP, error) {
// we know it cannot be nil and is valid // we know it cannot be nil and is valid
return net.ParseIP(externalIP), nil return net.ParseIP(externalIP), nil
} }
// waitWG, waits for a waiting group,
// transformed into a channel to be composable.
func waitWG(wg *sync.WaitGroup) chan struct{} {
ch := make(chan struct{})
go func() {
wg.Wait()
close(ch)
}()
return ch
}