From fd5f3ca7649c9167290c76c3562c314f42121c98 Mon Sep 17 00:00:00 2001 From: Arceliar Date: Fri, 16 Aug 2019 23:07:40 -0500 Subject: [PATCH] fix heap pop order --- src/yggdrasil/session.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/yggdrasil/session.go b/src/yggdrasil/session.go index b675b469..57522209 100644 --- a/src/yggdrasil/session.go +++ b/src/yggdrasil/session.go @@ -20,11 +20,10 @@ import ( const nonceWindow = time.Second // A heap of nonces, used with a map[nonce]time to allow out-of-order packets a little time to arrive without rejecting them -// Less is backwards so the oldest node is the highest priority for Pop type nonceHeap []crypto.BoxNonce func (h nonceHeap) Len() int { return len(h) } -func (h nonceHeap) Less(i, j int) bool { return h[i].Minus(&h[j]) > 0 } +func (h nonceHeap) Less(i, j int) bool { return h[i].Minus(&h[j]) < 0 } func (h nonceHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] } func (h *nonceHeap) Push(x interface{}) { *h = append(*h, x.(crypto.BoxNonce)) } func (h *nonceHeap) Pop() interface{} {