Reincarnated GRD. Changed mesh decay to go to 1/N rather than 0.
[distributedratelimiting.git] / drl / drl_state.c
index 8583d0d..a30337b 100644 (file)
@@ -118,7 +118,7 @@ void free_comm(comm_t *comm) {
     }
 }
 
-int read_comm(comm_t *comm, double *aggregate) {
+int read_comm(comm_t *comm, double *aggregate, double decayto) {
     remote_limiter_t *remote;
 
     pthread_mutex_lock(&comm->lock);
@@ -131,9 +131,10 @@ int read_comm(comm_t *comm, double *aggregate) {
             *aggregate += remote->rate;
 
             /* If we continue to read it without having heard an update,
-             * we start to decay its value. */
+             * we start to make the peer's value approach decayto, getting
+             * half of the way there each time. */
             if (remote->awol >= REMOTE_AWOL_THRESHOLD) {
-                remote->rate = remote->rate / 2;
+                remote->rate += ((decayto - remote->rate) / 2);
             } else {
                 remote->awol++;
             }