sort resolved node list in network by lowest priority

This commit is contained in:
Asim Aslam 2019-12-10 17:57:04 +00:00
parent 8da77a3ddc
commit e966944ae5

View File

@ -6,6 +6,7 @@ import (
"hash/fnv" "hash/fnv"
"io" "io"
"math" "math"
"sort"
"sync" "sync"
"time" "time"
@ -363,6 +364,11 @@ func (n *network) resolveNodes() ([]string, error) {
log.Debugf("Network failed to resolve nodes: %v", err) log.Debugf("Network failed to resolve nodes: %v", err)
} }
// sort by lowest priority
if err == nil {
sort.Slice(records, func(i, j int) bool { return records[i].Priority < records[j].Priority })
}
// keep processing // keep processing
nodeMap := make(map[string]bool) nodeMap := make(map[string]bool)