MCPcopy Create free account
hub / github.com/PasarGuard/node / UpdateStatsBatch

Method UpdateStatsBatch

pkg/stats/tracker.go:49–61  ·  view source on GitHub ↗

UpdateStatsBatch applies many peer stats updates under a single lock.

(samples []Sample)

Source from the content-addressed store, hash-verified

47
48// UpdateStatsBatch applies many peer stats updates under a single lock.
49func (st *Tracker) UpdateStatsBatch(samples []Sample) {
50 if len(samples) == 0 {
51 return
52 }
53
54 st.mu.Lock()
55 defer st.mu.Unlock()
56
57 now := time.Now()
58 for _, sample := range samples {
59 st.applySampleLocked(sample, now)
60 }
61}
62
63func (st *Tracker) applySampleLocked(sample Sample, activeAt time.Time) {
64 entry, exists := st.stats[sample.PublicKey]

Calls 1

applySampleLockedMethod · 0.95