fix orphaning

This commit is contained in:
Jethro Grassie 2019-08-23 16:24:03 -04:00
parent af3bf72f08
commit af9b9c8953
No known key found for this signature in database
GPG Key ID: DE8ED755616565BB
1 changed files with 12 additions and 4 deletions

View File

@ -743,7 +743,7 @@ process_blocks(block_t *blocks, size_t count)
}
block_t nb;
memcpy(&nb, sb, sizeof(block_t));
if (ib->status & BLOCK_ORPHANED)
if (memcmp(ib->hash, sb->hash, 64) != 0)
{
log_debug("Orphaned block at height %"PRIu64, ib->height);
nb.status |= BLOCK_ORPHANED;
@ -751,16 +751,24 @@ process_blocks(block_t *blocks, size_t count)
mdb_cursor_put(cursor, &key, &new_val, MDB_CURRENT);
continue;
}
if (memcmp(ib->hash, sb->hash, 64) == 0
&& memcmp(ib->prev_hash, sb->prev_hash, 64) != 0)
if (memcmp(ib->prev_hash, sb->prev_hash, 64) != 0)
{
log_warn("Block with matching heights but differing parents! "
log_warn("Block with matching height and hash "
"but differing parent! "
"Setting orphaned.\n");
nb.status |= BLOCK_ORPHANED;
MDB_val new_val = {sizeof(block_t), (void*)&nb};
mdb_cursor_put(cursor, &key, &new_val, MDB_CURRENT);
continue;
}
if (ib->status & BLOCK_ORPHANED)
{
log_debug("Orphaned block at height %"PRIu64, ib->height);
nb.status |= BLOCK_ORPHANED;
MDB_val new_val = {sizeof(block_t), (void*)&nb};
mdb_cursor_put(cursor, &key, &new_val, MDB_CURRENT);
continue;
}
nb.status |= BLOCK_UNLOCKED;
nb.reward = ib->reward;
rc = payout_block(&nb, txn);