From 58d9a8434407643678997c0c93f4443ea328c9d4 Mon Sep 17 00:00:00 2001
From: Martin Stiemerling <martin.stiemerling@h-da.de>
Date: Thu, 22 Jun 2023 11:12:19 +0200
Subject: [PATCH] wait time in GlobalKeyHandler now configurable

---
 kms/kms.go | 5 +++--
 main.go    | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/kms/kms.go b/kms/kms.go
index 818ee58..68a85dd 100644
--- a/kms/kms.go
+++ b/kms/kms.go
@@ -17,6 +17,7 @@ import (
 
 type Qkdnkms interface {
 	AddQuantumElement() *QuantumElement
+	GlobalKeyHandler(time.Duration) error
 }
 
 type qlElementId uint64
@@ -81,7 +82,7 @@ func (kms *eKMS) AddQuantumElement(kmsUDPAddrr string) *QuantumElement {
 	return &qle
 }
 
-func (kms *eKMS) GlobalKeyHandler() error {
+func (kms *eKMS) GlobalKeyHandler(waitTime time.Duration) error {
 
 	// periodically walk through QuantumElements and retrieve their
 	// - local key bulk buffer
@@ -110,7 +111,7 @@ func (kms *eKMS) GlobalKeyHandler() error {
 				kms.QuantumElements[currentQE].keyStoreRemote.KeyChopper256Bit(&bulkKeysLocal)
 			}
 		}
-		time.Sleep(10 * time.Second)
+		time.Sleep(waitTime)
 	}
 }
 
diff --git a/main.go b/main.go
index 402f31d..eaee39d 100644
--- a/main.go
+++ b/main.go
@@ -4,6 +4,7 @@ import (
 	"flag"
 	"log"
 	"net"
+	"time"
 
 	"code.fbi.h-da.de/m.stiemerling/proto-kms/kms"
 	"github.com/google/uuid"
@@ -70,5 +71,5 @@ func emulatedKMS(myName string, myUDPAddr string, peerUDPAddr string) {
 	myQL.QuantumElementLink.AddPeer(*udpQL2Addr)
 
 	// TODO/XXX catch errors!
-	emuKMS.GlobalKeyHandler()
+	emuKMS.GlobalKeyHandler(7 * time.Second)
 }
-- 
GitLab