remove Peer.SetVersionAndConnections
further shrinking Peer API
This commit is contained in:
1 parent
86ba3be4f7
commit
426d8edb31
3 files changed
+4
-10
No files matched your search
@@ -79,7 +79,8 @@ func (router *Router) tp(routers ...*Router) *Peer {
|
||||
p := NewPeer(r.Ourself.Peer.Name, "", r.Ourself.Peer.UID, r.Ourself.Peer.version)
|
||||
connections[r.Ourself.Peer.Name] = newMockConnection(peer, p)
|
||||
}
|
||||
peer.SetVersionAndConnections(router.Ourself.Peer.version, connections)
|
||||
peer.version = router.Ourself.Peer.version
|
||||
peer.connections = connections
|
||||
return peer
|
||||
}
|
||||
|
||||
|
||||
@@ -42,13 +42,6 @@ func (peer *Peer) Info() string {
|
||||
return fmt.Sprint(peer.String(), " (v", peer.version, ") (UID ", peer.UID, ")")
|
||||
}
|
||||
|
||||
func (peer *Peer) SetVersionAndConnections(version uint64, connections map[PeerName]Connection) {
|
||||
peer.Lock()
|
||||
defer peer.Unlock()
|
||||
peer.version = version
|
||||
peer.connections = connections
|
||||
}
|
||||
|
||||
// Calculate the routing table from this peer to all peers reachable
|
||||
// from it, returning a "next hop" map of PeerNameX -> PeerNameY,
|
||||
// which says "in order to send a message to X, the peer should send
|
||||
|
||||
+2
-2
@@ -270,8 +270,8 @@ func (peers *Peers) applyUpdate(decodedUpdate []*Peer, decodedConns [][]Connecti
|
||||
// for an update would be someone else calling
|
||||
// router.Peers.ApplyUpdate. But ApplyUpdate takes the Lock on
|
||||
// the router.Peers, so there can be no race here.
|
||||
conns := makeConnsMap(peer, connSummaries, peers.table)
|
||||
peer.SetVersionAndConnections(newPeer.version, conns)
|
||||
peer.version = newPeer.version
|
||||
peer.connections = makeConnsMap(peer, connSummaries, peers.table)
|
||||
newUpdate[name] = peer
|
||||
}
|
||||
return newUpdate
|
||||
|
||||
Reference in new issue
Block a user