MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / computePerPathUpdatesLocked

Method computePerPathUpdatesLocked

internal/watcher/clients.go:294–319  ·  view source on GitHub ↗
(oldByID, newByID map[string]*coreauth.Auth)

Source from the content-addressed store, hash-verified

292}
293
294func (w *Watcher) computePerPathUpdatesLocked(oldByID, newByID map[string]*coreauth.Auth) []AuthUpdate {
295 if w.currentAuths == nil {
296 w.currentAuths = make(map[string]*coreauth.Auth)
297 }
298 updates := make([]AuthUpdate, 0, len(oldByID)+len(newByID))
299 for id, newAuth := range newByID {
300 existing, ok := w.currentAuths[id]
301 if !ok {
302 w.currentAuths[id] = newAuth.Clone()
303 updates = append(updates, AuthUpdate{Action: AuthUpdateActionAdd, ID: id, Auth: newAuth.Clone()})
304 continue
305 }
306 if !authEqual(existing, newAuth) {
307 w.currentAuths[id] = newAuth.Clone()
308 updates = append(updates, AuthUpdate{Action: AuthUpdateActionModify, ID: id, Auth: newAuth.Clone()})
309 }
310 }
311 for id := range oldByID {
312 if _, stillExists := newByID[id]; stillExists {
313 continue
314 }
315 delete(w.currentAuths, id)
316 updates = append(updates, AuthUpdate{Action: AuthUpdateActionDelete, ID: id})
317 }
318 return updates
319}
320
321func authSliceToMap(auths []*coreauth.Auth) map[string]*coreauth.Auth {
322 byID := make(map[string]*coreauth.Auth, len(auths))

Callers 2

removeClientLockedMethod · 0.95

Calls 2

authEqualFunction · 0.85
CloneMethod · 0.45

Tested by

no test coverage detected