@@ -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