diff options
author | Jakob Borg <jakob@nym.se> | 2014-05-12 22:08:55 -0300 |
---|---|---|
committer | Jakob Borg <jakob@nym.se> | 2014-05-12 22:08:55 -0300 |
commit | 532b576fd59fd60d556f62bdbab70b3fbb6e54e0 (patch) | |
tree | 3c707f4d5af65e4e57fe295701cc46efe9dfe4f9 /discover | |
parent | dd1197236d3942232ec17bc4c3c0c4815603f387 (diff) |
Expose discovery cache over rest interface
Diffstat (limited to 'discover')
-rw-r--r-- | discover/discover.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/discover/discover.go b/discover/discover.go index 01c2da0253..6bfa95d809 100644 --- a/discover/discover.go +++ b/discover/discover.go @@ -98,6 +98,18 @@ func (d *Discoverer) Hint(node string, addrs []string) { }) } +func (d *Discoverer) All() map[string][]string { + d.registryLock.RLock() + nodes := make(map[string][]string, len(d.registry)) + for node, addrs := range d.registry { + addrsCopy := make([]string, len(addrs)) + copy(addrsCopy, addrs) + nodes[node] = addrsCopy + } + d.registryLock.RUnlock() + return nodes +} + func (d *Discoverer) announcementPkt() []byte { var addrs []Address for _, astr := range d.listenAddrs { |