Handle the not-found case implicitly in Broadcast and BroadcastAll
This commit is contained in:
1 parent
97fb90c37a
commit
c6edf8421f
1 file changed
+2
-10
+2
-10
@@ -65,21 +65,13 @@ func (routes *Routes) UnicastAll(name PeerName) (PeerName, bool) {
|
|||||||
func (routes *Routes) Broadcast(name PeerName) []PeerName {
|
func (routes *Routes) Broadcast(name PeerName) []PeerName {
|
||||||
routes.RLock()
|
routes.RLock()
|
||||||
defer routes.RUnlock()
|
defer routes.RUnlock()
|
||||||
hops, found := routes.broadcast[name]
|
return routes.broadcast[name]
|
||||||
if !found {
|
|
||||||
return []PeerName{}
|
|
||||||
}
|
|
||||||
return hops
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (routes *Routes) BroadcastAll(name PeerName) []PeerName {
|
func (routes *Routes) BroadcastAll(name PeerName) []PeerName {
|
||||||
routes.RLock()
|
routes.RLock()
|
||||||
defer routes.RUnlock()
|
defer routes.RUnlock()
|
||||||
hops, found := routes.broadcastAll[name]
|
return routes.broadcastAll[name]
|
||||||
if !found {
|
|
||||||
return []PeerName{}
|
|
||||||
}
|
|
||||||
return hops
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Choose min(log2(n_peers), n_neighbouring_peers) neighbours, with a
|
// Choose min(log2(n_peers), n_neighbouring_peers) neighbours, with a
|
||||||
|
|||||||
Reference in new issue
Block a user