Merge branch '1.4'

This commit is contained in:
Matthias Radestock committed 2016-03-22 14:13:24 +00:00
commit 63a9f879fb
4 files changed
+88 -3

No files matched your search

+21 -2
View File
@@ -94,6 +94,9 @@ func (e1 *Entry) merge(e2 *Entry) bool {
e1.Version = e2.Version
e1.Tombstone = e2.Tombstone
return true
} else if e2.Version == e1.Version && e2.Tombstone > e1.Tombstone {
e1.Tombstone = e2.Tombstone
return true
}
return false
}
@@ -106,6 +109,11 @@ func (e1 *Entry) addLowercase() {
e1.lHostname = strings.ToLower(e1.Hostname)
}
func (e *Entry) tombstone() {
e.Version++
e.Tombstone = now()
}
func check(es SortableEntries) error {
if !sort.IsSorted(es) {
return fmt.Errorf("Not sorted!")
@@ -183,8 +191,7 @@ func (es *Entries) tombstone(ourname mesh.PeerName, f func(*Entry) bool) Entries
tombstoned := Entries{}
for i, e := range *es {
if f(&e) && e.Origin == ourname {
e.Version++
e.Tombstone = now()
e.tombstone()
(*es)[i] = e
tombstoned = append(tombstoned, e)
}
@@ -192,6 +199,7 @@ func (es *Entries) tombstone(ourname mesh.PeerName, f func(*Entry) bool) Entries
return tombstoned
}
// note f() may only modify entries such that they remain in order defined by less()
func (es *Entries) filter(f func(*Entry) bool) {
defer es.checkAndPanic().checkAndPanic()
@@ -206,6 +214,17 @@ func (es *Entries) filter(f func(*Entry) bool) {
*es = (*es)[:i]
}
func (es Entries) findEqual(e *Entry) (*Entry, bool) {
i := sort.Search(len(es), func(i int) bool {
return !es[i].insensitiveLess(e)
})
if i < len(es) && es[i].equal(*e) {
return &es[i], true
} else {
return nil, false
}
}
func (es Entries) lookup(hostname string) Entries {
es.checkAndPanic()