code: func (ps *peerSet) Register(p *peerConnection) error {
  	// Retrieve the current median RTT as a sane default
  	p.rtt = ps.medianRTT()
  
  	// Register the new peer with some meaningful defaults
  	ps.lock.Lock()
  	if _, ok := ps.peers[p.id]; ok {
  		ps.lock.Unlock()
  		return errAlreadyRegistered
  	}
  	if len(ps.peers) > 0 {
  		p.headerThroughput, p.blockThroughput, p.receiptThroughput, p.stateThroughput = 0, 0, 0, 0
  
  		for _, peer := range ps.peers {
  			peer.lock.RLock()
  			p.headerThroughput += peer.headerThroughput
  			p.blockThroughput += peer.blockThroughput
  			p.receiptThroughput += peer.receiptThroughput
  			p.stateThroughput += peer.stateThroughput
  			peer.lock.RUnlock()
  		}
  		p.headerThroughput /= float64(len(ps.peers))
  		p.blockThroughput /= float64(len(ps.peers))
  		p.receiptThroughput /= float64(len(ps.peers))
  		p.stateThroughput /= float64(len(ps.peers))
  	}
  	ps.peers[p.id] = p
  	ps.lock.Unlock()
  
  	ps.newPeerFeed.Send(p)
  	return nil
  }
docs: // Register injects a new peer into the working set, or returns an error if the
  // peer is already known.
  //
  // The method also sets the starting throughput values of the new peer to the
  // average of all existing peers, to give it a realistic chance of being used
  // for data retrievals.