@@ -161,10 +161,10 @@ func HandleRequestProof(req Request) {
161161 CID := req .CID
162162 hash := req .Hash
163163 if ipfs .IsPinned (CID ) == true {
164+ fmt .Println ("Sending proof of access to validation node" )
164165 validationHash := validation .CreatProofHash (hash , CID )
165166 SendProof (req , validationHash , hash , localdata .NodeName )
166167 } else {
167- fmt .Println ("Sending proof of access to validation node" )
168168 SendProof (req , hash , req .Seed , localdata .NodeName )
169169 }
170170
@@ -474,12 +474,31 @@ func SyncNode(req Request) {
474474 log .Println ("Pins data:" , req .Pins )
475475 return
476476 }
477+ // Lock to safely read from shared data
477478 localdata .Lock .Lock ()
478479 allPins := localdata .PeerCids [req .User ]
479480 localdata .Lock .Unlock ()
480- for _ , value := range pins {
481- allPins = append (allPins , value )
481+
482+ // Create a map to use as a set for unique values
483+ uniquePins := make (map [string ]struct {})
484+
485+ // Populate the map with the existing pins
486+ for _ , pin := range allPins {
487+ uniquePins [pin ] = struct {}{}
482488 }
489+
490+ // Add new pins to the map, automatically removing duplicates
491+ for _ , pin := range pins {
492+ uniquePins [pin ] = struct {}{}
493+ }
494+
495+ // Convert the map keys back into a slice
496+ allPins = make ([]string , 0 , len (uniquePins ))
497+ for pin := range uniquePins {
498+ allPins = append (allPins , pin )
499+ }
500+
501+ // Lock to safely write to shared data
483502 localdata .Lock .Lock ()
484503 localdata .PeerCids [req .User ] = allPins
485504 localdata .PeerSyncSeed [req .Seed ] = localdata .PeerSyncSeed [req .Seed ] + 1
0 commit comments