code: func (p *Peer) StatsSnapshot() *StatsSnap {
  	p.statsMtx.RLock()
  
  	p.flagsMtx.Lock()
  	id := p.id
  	addr := p.addr
  	userAgent := p.userAgent
  	services := p.services
  	protocolVersion := p.advertisedProtoVer
  	p.flagsMtx.Unlock()
  
  	// Get a copy of all relevant flags and stats.
  	statsSnap := &StatsSnap{
  		ID:             id,
  		Addr:           addr,
  		UserAgent:      userAgent,
  		Services:       services,
  		LastSend:       p.LastSend(),
  		LastRecv:       p.LastRecv(),
  		BytesSent:      p.BytesSent(),
  		BytesRecv:      p.BytesReceived(),
  		ConnTime:       p.timeConnected,
  		TimeOffset:     p.timeOffset,
  		Version:        protocolVersion,
  		Inbound:        p.inbound,
  		StartingHeight: p.startingHeight,
  		LastBlock:      p.lastBlock,
  		LastPingNonce:  p.lastPingNonce,
  		LastPingMicros: p.lastPingMicros,
  		LastPingTime:   p.lastPingTime,
  	}
  
  	p.statsMtx.RUnlock()
  	return statsSnap
  }
docs: // StatsSnapshot returns a snapshot of the current peer flags and statistics.
  //
  // This function is safe for concurrent access.