fix: hash peerID

This commit is contained in:
Richard Ramos 2023-02-16 13:39:21 -04:00
parent 855743e24c
commit 79db21455f
No known key found for this signature in database
GPG Key ID: 1CE87DB518195760

View File

@ -1,7 +1,9 @@
package telemetry package telemetry
import ( import (
"crypto/sha256"
"database/sql" "database/sql"
"encoding/hex"
"encoding/json" "encoding/json"
"fmt" "fmt"
"log" "log"
@ -94,6 +96,9 @@ func (s *Server) createProtocolStats(w http.ResponseWriter, r *http.Request) {
} }
defer r.Body.Close() defer r.Body.Close()
peerIDHash := sha256.Sum256([]byte(protocolStats.PeerID))
protocolStats.PeerID = hex.EncodeToString(peerIDHash[:])
if err := protocolStats.put(s.DB); err != nil { if err := protocolStats.put(s.DB); err != nil {
err := respondWithError(w, http.StatusInternalServerError, "Could not save protocol stats") err := respondWithError(w, http.StatusInternalServerError, "Could not save protocol stats")
if err != nil { if err != nil {