From f836bf28f2c2a4e49d9dadf7422e1d4bea5d3359 Mon Sep 17 00:00:00 2001 From: kanoi Date: Fri, 8 Aug 2014 11:58:29 +1000 Subject: [PATCH] ckdb - store blocks even if they have incorrect usernames --- src/ckdb.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ckdb.c b/src/ckdb.c index 217b67e2..c6f4a86a 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -1006,6 +1006,8 @@ typedef struct blocks { #define BLOCKS_NEW 'n' #define BLOCKS_CONFIRM '1' +#define KANO -27972 + static K_TREE *blocks_root; static K_LIST *blocks_free; static K_STORE *blocks_store; @@ -3998,7 +4000,7 @@ void sharesummary_reload() PQfinish(conn); } -// order by height asc,blockhash asc,expirydate desc +// order by height asc,blockhash asc,expirydate asc static double cmp_blocks(K_ITEM *a, K_ITEM *b) { double c = DATA_BLOCKS(a)->height - DATA_BLOCKS(b)->height; @@ -4066,7 +4068,9 @@ static bool blocks_add(PGconn *conn, char *height, char *blockhash, case BLOCKS_NEW: u_item = find_users(username); if (!u_item) - goto early; + row->userid = KANO; + else + row->userid = DATA_USERS(u_item)->userid; TXT_TO_BIGINT("workinfoid", workinfoid, row->workinfoid); STRNCPY(row->workername, workername); @@ -4174,7 +4178,7 @@ unparam: PQclear(res); for (n = 0; n < par; n++) free(params[n]); -early: + K_WLOCK(blocks_free); if (!ok) k_add_head(blocks_free, item);