From 2cbfd270b02b427bab0c881a874fccecefdc5306 Mon Sep 17 00:00:00 2001
From: Lukas Braun <lukas.braun@fau.de>
Date: Wed, 1 Feb 2017 01:07:31 +0100
Subject: [PATCH] fix off-by-one in lookahead code

The Lookahead var should indicate how often the counter is incremented
before an offer is finally declared invalid, *not* the total number of
checks (aka window size).
I.e. for Lookahead=0, check only against the current counter instead of
not at all.
---
 goatherd.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/goatherd.go b/goatherd.go
index f831845..033ab19 100644
--- a/goatherd.go
+++ b/goatherd.go
@@ -190,7 +190,7 @@ func check_offer(db *sql.DB, remote string, name string, offer string) (bool, er
             return false, err
         } else { err_panic(err) }
 
-        for i := uint64(0); i < cfg.Lookahead; i++ {
+        for i := uint64(0); i <= cfg.Lookahead; i++ {
             debugf("[%v] checking for match (offset %v)", remote, i)
             // .Check increments .Counter if successfull
             // otherwise do it explicitly
-- 
GitLab