From ea1a2c6edfbb7d75c4a836411350ef8920ed2da5 Mon Sep 17 00:00:00 2001 From: kanoi Date: Tue, 15 Sep 2015 22:28:00 +1000 Subject: [PATCH] ckdb - shifts created after a payout they are in, need rewarded set --- src/ckdb.h | 2 +- src/ckdb_data.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ckdb.h b/src/ckdb.h index c34666c5..a0963ae9 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -55,7 +55,7 @@ #define DB_VLOCK "1" #define DB_VERSION "1.0.2" -#define CKDB_VERSION DB_VERSION"-1.302" +#define CKDB_VERSION DB_VERSION"-1.303" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ diff --git a/src/ckdb_data.c b/src/ckdb_data.c index 720f3a8e..34f29848 100644 --- a/src/ckdb_data.c +++ b/src/ckdb_data.c @@ -4861,7 +4861,9 @@ bool reward_shifts(PAYOUTS *payouts, bool lock, int delta) * and thus if the shift is expired the counter is ignored * We only need to (re)calculate it when the workmarker is created * Payouts code processing will increment/decrement all current rewards as - * needed with reward_shifts() when payouts are added/changed/removed */ + * needed with reward_shifts() when payouts are added/changed/removed, + * however, the last shift in a payout can be created after the payout + * is generated so we need to update all from the payouts */ bool shift_rewards(K_ITEM *wm_item) { PAYOUTS *payouts = NULL; @@ -4869,6 +4871,7 @@ bool shift_rewards(K_ITEM *wm_item) WORKMARKERS *wm; K_ITEM *p_item; int rewards = 0; + double pps = 0.0; DATA_WORKMARKERS(wm, wm_item); @@ -4879,14 +4882,19 @@ bool shift_rewards(K_ITEM *wm_item) // a workmarker should not cross a payout boundary while (p_item && payouts->workinfoidstart <= wm->workinfoidstart && wm->workinfoidend <= payouts->workinfoidend) { - if (CURRENT(&(payouts->expirydate))) + if (CURRENT(&(payouts->expirydate))) { rewards++; + pps += (double)(payouts->minerreward) / + payouts->diffused; + } p_item = prev_in_ktree(ctx); DATA_PAYOUTS_NULL(payouts, p_item); } K_RUNLOCK(payouts_free); wm->rewards = rewards; + wm->rewarded = pps; + return (rewards > 0); }