Browse Source

ckdb - fix block db save

master
kanoi 10 years ago
parent
commit
2af4207306
  1. 24
      src/ckdb.c

24
src/ckdb.c

@ -4033,11 +4033,11 @@ static K_ITEM *find_blocks(int32_t height, char *blockhash)
*/ */
static bool blocks_add(PGconn *conn, char *height, char *blockhash, static bool blocks_add(PGconn *conn, char *height, char *blockhash,
char *workinfoid, char *username, char *workername, char *confirmed, char *workinfoid, char *username,
char *clientid, char *enonce1, char *nonce2, char *workername, char *clientid, char *enonce1,
char *nonce, char *reward, char *confirmed, char *nonce2, char *nonce, char *reward,
char *by, char *code, char *inet, tv_t *cd, char *by, char *code, char *inet, tv_t *cd,
bool igndup) bool igndup, char *id)
{ {
ExecStatusType rescode; ExecStatusType rescode;
PGresult *res = NULL; PGresult *res = NULL;
@ -4171,6 +4171,10 @@ static bool blocks_add(PGconn *conn, char *height, char *blockhash,
res = PQexec(conn, "Commit"); res = PQexec(conn, "Commit");
break; break;
default:
LOGERR("%s(): %s.failed.invalid confirm='%s'",
__func__, id, confirmed);
goto flail;
} }
ok = true; ok = true;
@ -4178,7 +4182,7 @@ unparam:
PQclear(res); PQclear(res);
for (n = 0; n < par; n++) for (n = 0; n < par; n++)
free(params[n]); free(params[n]);
flail:
K_WLOCK(blocks_free); K_WLOCK(blocks_free);
if (!ok) if (!ok)
k_add_head(blocks_free, item); k_add_head(blocks_free, item);
@ -6609,7 +6613,7 @@ static char *cmd_blocks_do(char *cmd, char *id, char *by, char *code, char *inet
DATA_TRANSFER(i_nonce2)->data, DATA_TRANSFER(i_nonce2)->data,
DATA_TRANSFER(i_nonce)->data, DATA_TRANSFER(i_nonce)->data,
DATA_TRANSFER(i_reward)->data, DATA_TRANSFER(i_reward)->data,
by, code, inet, cd, igndup); by, code, inet, cd, igndup, id);
break; break;
case BLOCKS_CONFIRM: case BLOCKS_CONFIRM:
msg = "confirmed"; msg = "confirmed";
@ -6619,11 +6623,11 @@ static char *cmd_blocks_do(char *cmd, char *id, char *by, char *code, char *inet
DATA_TRANSFER(i_confirmed)->data, DATA_TRANSFER(i_confirmed)->data,
EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY,
EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY,
by, code, inet, cd, igndup); by, code, inet, cd, igndup, id);
break; break;
default: default:
LOGERR("%s.failed.invalid conf='%s'", LOGERR("%s(): %s.failed.invalid confirm='%s'",
id, DATA_TRANSFER(i_confirmed)->data); __func__, id, DATA_TRANSFER(i_confirmed)->data);
return strdup("failed.DATA"); return strdup("failed.DATA");
} }

Loading…
Cancel
Save