Extract lookup function for owned addresses

This commit is contained in:
Bryan Boreham committed 2015-06-10 17:27:07 +01:00
1 parent 7d881a0f0c
commit c27cd5b4ab
2 files changed
+18 -15

No files matched your search

+3 -8
View File
@@ -24,14 +24,9 @@ func (g *allocate) Try(alloc *Allocator) bool {
return true
}
// If we have previously stored an address for this container in this subnet, return it.
if addrs, found := alloc.owned[g.ident]; found {
for _, addr := range addrs {
if g.r.Contains(addr) {
g.resultChan <- allocateResult{addr, nil}
return true
}
}
if addr, found := alloc.lookupOwned(g.ident, g.r); found {
g.resultChan <- allocateResult{addr, nil}
return true
}
if !alloc.universe.Overlaps(g.r) {