Browse Source

ckdb - correct block confirm workinfoid selection code

master
kanoi 10 years ago
parent
commit
4cc9c6ac7a
  1. 18
      src/ckdb.c

18
src/ckdb.c

@ -47,7 +47,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "0.7" #define DB_VERSION "0.7"
#define CKDB_VERSION DB_VERSION"-0.45" #define CKDB_VERSION DB_VERSION"-0.46"
#define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__ #define WHERE_FFL_HERE __FILE__, __func__, __LINE__
@ -9279,9 +9279,9 @@ static void confirm_reload()
if (confirm_range && *confirm_range) { if (confirm_range && *confirm_range) {
switch(tolower(confirm_range[0])) { switch(tolower(confirm_range[0])) {
case 'b': case 'b':
// First DB record of the block after 'confirm_block-1' // First DB record of the block = or after confirm_block
blocks.height = confirm_block - 1; blocks.height = confirm_block;
STRNCPY(blocks.blockhash, "~"); blocks.blockhash[0] = '\0';
look.data = (void *)(&blocks); look.data = (void *)(&blocks);
b_end_item = find_after_in_ktree(blocks_root, &look, cmp_blocks, ctx); b_end_item = find_after_in_ktree(blocks_root, &look, cmp_blocks, ctx);
if (!b_end_item) { if (!b_end_item) {
@ -9293,22 +9293,22 @@ static void confirm_reload()
// Now find the last DB record of the previous block // Now find the last DB record of the previous block
blocks.height = DATA_BLOCKS(b_end_item)->height; blocks.height = DATA_BLOCKS(b_end_item)->height;
STRNCPY(blocks.blockhash, " "); blocks.blockhash[0] = '\0';
look.data = (void *)(&blocks); look.data = (void *)(&blocks);
b_begin_item = find_before_in_ktree(blocks_root, &look, cmp_blocks, ctx); b_begin_item = find_before_in_ktree(blocks_root, &look, cmp_blocks, ctx);
if (!b_begin_item) if (!b_begin_item)
confirm_first_workinfoid = 0; confirm_first_workinfoid = 0;
else { else {
// First DB record of the block after 'begin-1' // First DB record of the block 'begin'
blocks.height = DATA_BLOCKS(b_begin_item)->height - 1; blocks.height = DATA_BLOCKS(b_begin_item)->height;
STRNCPY(blocks.blockhash, "~"); blocks.blockhash[0] = '\0';
look.data = (void *)(&blocks); look.data = (void *)(&blocks);
b_begin_item = find_after_in_ktree(blocks_root, &look, cmp_blocks, ctx); b_begin_item = find_after_in_ktree(blocks_root, &look, cmp_blocks, ctx);
// Not possible // Not possible
if (!b_begin_item) if (!b_begin_item)
confirm_first_workinfoid = 0; confirm_first_workinfoid = 0;
else else
confirm_last_workinfoid = DATA_BLOCKS(b_begin_item)->workinfoid; confirm_first_workinfoid = DATA_BLOCKS(b_begin_item)->workinfoid;
} }
snprintf(first_buf, sizeof(first_buf), snprintf(first_buf, sizeof(first_buf),
"block %d", "block %d",

Loading…
Cancel
Save