diff --git a/router/connection.go b/router/connection.go index a79abca8..e004d65e 100644 --- a/router/connection.go +++ b/router/connection.go @@ -514,15 +514,7 @@ func (conn *LocalConnection) receiveTCP(decoder *gob.Decoder) { // receiver merges it with its own topology model. If the // payload is a subset of the receiver's topology, no // further action is taken. Otherwise, the receiver sends - // out to all its connections an "improved" update: - // - elements which the original payload added to the - // receiver are included - // - elements which the original payload updated in the - // receiver are included - // - elements which are equal between the receiver and - // the payload are not included - // - elements where the payload was older than the - // receiver's version are updated + // out to all its connections an "improved" update. conn.SendTCP(Concat(ProtocolUpdateByte, conn.Router.Peers.EncodeAllPeers())) case ProtocolUpdate: newUpdate, err := conn.Router.Peers.ApplyUpdate(msg[1:]) diff --git a/router/peers.go b/router/peers.go index 071fb5e0..cb85ad47 100644 --- a/router/peers.go +++ b/router/peers.go @@ -57,6 +57,16 @@ func (peers *Peers) ForEach(fun func(PeerName, *Peer)) { } } +// Merge an incoming update with our own topology, and +// create an "improved" update: +// - elements which the original payload added to the receiver are +// included +// - elements which the original payload updated in the receiver are +// included +// - elements which are equal between the receiver and the payload are +// not included +// - elements where the payload was older than the receiver's version +// are updated func (peers *Peers) ApplyUpdate(update []byte) ([]byte, error) { peers.Lock()