Skip to content

Commit 5d30c2e

Browse files
committed
2025.08.08
1 parent 6416829 commit 5d30c2e

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

messaging/proofs.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,31 @@ func HandleProofOfAccess(req Request, ws *websocket.Conn) {
6565
// Create the proof hash
6666
var validationHash string
6767
fmt.Println("Request Hash", req.Hash)
68-
if req.Hash != "NA" || req.Hash != "" {
68+
if req.Hash != "NA" && req.Hash != "" {
6969
fmt.Println("Creating proof of access hash")
7070
validationHash = validation.CreatProofHash(seed, CID)
7171
fmt.Println("Validation Hash", validationHash)
72-
// Check if the proof of access is valid
73-
if validationHash == req.Hash && elapsed < 25000000*time.Millisecond {
74-
fmt.Println("Proof of access is valid")
75-
//fmt.Println(req.Seed)
76-
localdata.SetStatus(req.Seed, CID, "Valid", req.User)
77-
} else {
72+
73+
// Check if we could create a validation hash
74+
if validationHash == "" {
75+
fmt.Println("Could not create validation hash - CID refs not found")
76+
localdata.SetStatus(req.Seed, CID, "Invalid", req.User)
77+
} else if validationHash != req.Hash {
7878
fmt.Println("Request Hash", req.Hash)
7979
fmt.Println("Validation Hash", validationHash)
80+
fmt.Println("Hash mismatch - proof is invalid")
81+
localdata.SetStatus(req.Seed, CID, "Invalid", req.User)
82+
} else if elapsed >= 25000*time.Millisecond {
83+
// 25 seconds timeout
8084
fmt.Println("Elapsed time:", elapsed)
81-
fmt.Println("Proof of access is invalid took too long")
85+
fmt.Println("Proof of access took too long (>25s)")
8286
localdata.SetStatus(req.Seed, CID, "Invalid", req.User)
87+
} else {
88+
fmt.Println("Proof of access is valid")
89+
localdata.SetStatus(req.Seed, CID, "Valid", req.User)
8390
}
8491
} else {
85-
fmt.Println("Proof is invalid")
92+
fmt.Println("Proof is invalid - no hash provided")
8693
localdata.SetStatus(req.Seed, CID, "Invalid", req.User)
8794
}
8895
localdata.Lock.Lock()

0 commit comments

Comments
 (0)