add robustness against trust #f
1 files changed, 5 insertions(+), 3 deletions(-)

M wispwot/wispwot.w
M wispwot/wispwot.w +5 -3
@@ 588,7 588,7 @@ define* : calculate-ranks wotstate root-
 
 
 define : score-increment/truncated capacity trust
-    truncate/ (* trust capacity) 100
+    truncate/ (* (or trust 0) capacity) 100
 
 
 define : update-score! wotstate truster-index old-rank new-rank trustee-index old-trust new-trust

          
@@ 596,7 596,7 @@ define : update-score! wotstate truster-
     define new-capacity : rank->capacity new-rank
     define scores : wotstate-scores wotstate
     define ranks : wotstate-ranks wotstate
-    define old-score-increment : score-increment/truncated old-capacity : or old-trust 0
+    define old-score-increment : score-increment/truncated old-capacity old-trust
     define new-score-increment : score-increment/truncated new-capacity new-trust
     define trustee-rank : ranks-ref ranks trustee-index
     ;; CHANGE to WoT: defend against distrusting your ancestors by strict hierarchical scoring

          
@@ 1011,6 1011,8 @@ define* : update-ranks-and-scores-from-t
             set! ranks
                 vector-append! ranks ranks--inf make-ranks ranks-length ranks-ref ranks-set!
             set-wotstate-ranks! wotstate ranks
+       when : not scores
+            set! scores : make-vector 0
        while : or {truster-index >= (vector-length scores)} {trustee-index >= (vector-length scores)}
             set! scores : vector-append! scores #f
             set-wotstate-scores! wotstate scores

          
@@ 1023,7 1025,7 @@ define* : update-ranks-and-scores-from-t
              let*
                : t : vector-ref (wotstate-trustlists wotstate) truster-index
                  idx : find-trustee-index-in-trustlist (car t) trustee-index
-               trusts-ref (cdr t) idx
+               and idx : trusts-ref (cdr t) idx
            trustee-score-change
              update-score! wotstate truster-index truster-rank truster-rank trustee-index old-trust trust
            changed-subtree