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

Method Init

backend/wireguard/peer_store.go:25–38  ·  view source on GitHub ↗

Init bulk initializes the peer store. Should ONLY be used during startup when the store is known to be empty.

(peers []*PeerInfo)

Source from the content-addressed store, hash-verified

23// Init bulk initializes the peer store.
24// Should ONLY be used during startup when the store is known to be empty.
25func (ps *PeerStore) Init(peers []*PeerInfo) {
26 ps.mu.Lock()
27 defer ps.mu.Unlock()
28
29 for _, peer := range peers {
30 if peer == nil {
31 continue
32 }
33 peerCopy := clonePeerInfo(peer)
34 keyStr := peerCopy.PublicKey.String()
35 ps.peers[keyStr] = peerCopy
36 ps.emailToKey[peerCopy.Email] = keyStr
37 }
38}
39
40// ApplyChanges commits removals and upserts in one lock scope.
41// It returns the keys actually removed from the store.

Calls 2

clonePeerInfoFunction · 0.85
StringMethod · 0.45