mirror of
https://git.wownero.com/wownero/wownero-puddle.git
synced 2024-08-15 01:03:20 +00:00
fix comparators to always allow duplicates
(reported by cohcho, thanks)
This commit is contained in:
parent
c7984e0e5f
commit
05fafe0fa4
2 changed files with 22 additions and 10 deletions
27
src/pool.c
27
src/pool.c
|
@ -323,8 +323,7 @@ compare_block(const MDB_val *a, const MDB_val *b)
|
||||||
const block_t *vb = (const block_t*) b->mv_data;
|
const block_t *vb = (const block_t*) b->mv_data;
|
||||||
int sc = memcmp(va->hash, vb->hash, 64);
|
int sc = memcmp(va->hash, vb->hash, 64);
|
||||||
if (sc == 0)
|
if (sc == 0)
|
||||||
return (va->timestamp < vb->timestamp) ? -1 :
|
return (va->timestamp < vb->timestamp) ? -1 : 1;
|
||||||
va->timestamp > vb->timestamp;
|
|
||||||
else
|
else
|
||||||
return sc;
|
return sc;
|
||||||
}
|
}
|
||||||
|
@ -336,8 +335,7 @@ compare_share(const MDB_val *a, const MDB_val *b)
|
||||||
const share_t *vb = (const share_t*) b->mv_data;
|
const share_t *vb = (const share_t*) b->mv_data;
|
||||||
int sc = strcmp(va->address, vb->address);
|
int sc = strcmp(va->address, vb->address);
|
||||||
if (sc == 0)
|
if (sc == 0)
|
||||||
return (va->timestamp < vb->timestamp) ? -1 :
|
return (va->timestamp < vb->timestamp) ? -1 : 1;
|
||||||
va->timestamp > vb->timestamp;
|
|
||||||
else
|
else
|
||||||
return sc;
|
return sc;
|
||||||
}
|
}
|
||||||
|
@ -347,8 +345,7 @@ compare_payment(const MDB_val *a, const MDB_val *b)
|
||||||
{
|
{
|
||||||
const payment_t *va = (const payment_t*) a->mv_data;
|
const payment_t *va = (const payment_t*) a->mv_data;
|
||||||
const payment_t *vb = (const payment_t*) b->mv_data;
|
const payment_t *vb = (const payment_t*) b->mv_data;
|
||||||
return (va->timestamp < vb->timestamp) ? -1 :
|
return (va->timestamp < vb->timestamp) ? -1 : 1;
|
||||||
va->timestamp > vb->timestamp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -450,7 +447,14 @@ store_share(uint64_t height, share_t *share)
|
||||||
|
|
||||||
MDB_val key = { sizeof(height), (void*)&height };
|
MDB_val key = { sizeof(height), (void*)&height };
|
||||||
MDB_val val = { sizeof(share_t), (void*)share };
|
MDB_val val = { sizeof(share_t), (void*)share };
|
||||||
mdb_cursor_put(cursor, &key, &val, MDB_APPENDDUP);
|
rc = mdb_cursor_put(cursor, &key, &val, MDB_APPENDDUP);
|
||||||
|
if (rc != 0)
|
||||||
|
{
|
||||||
|
err = mdb_strerror(rc);
|
||||||
|
log_error("%s", err);
|
||||||
|
mdb_txn_abort(txn);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
rc = mdb_txn_commit(txn);
|
rc = mdb_txn_commit(txn);
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -479,7 +483,14 @@ store_block(uint64_t height, block_t *block)
|
||||||
|
|
||||||
MDB_val key = { sizeof(height), (void*)&height };
|
MDB_val key = { sizeof(height), (void*)&height };
|
||||||
MDB_val val = { sizeof(block_t), (void*)block };
|
MDB_val val = { sizeof(block_t), (void*)block };
|
||||||
mdb_cursor_put(cursor, &key, &val, MDB_APPENDDUP);
|
rc = mdb_cursor_put(cursor, &key, &val, MDB_APPENDDUP);
|
||||||
|
if (rc != 0)
|
||||||
|
{
|
||||||
|
err = mdb_strerror(rc);
|
||||||
|
log_error("%s", err);
|
||||||
|
mdb_txn_abort(txn);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
rc = mdb_txn_commit(txn);
|
rc = mdb_txn_commit(txn);
|
||||||
return rc;
|
return rc;
|
||||||
|
|
5
tools/inspect-data
vendored
5
tools/inspect-data
vendored
|
@ -126,12 +126,13 @@ def print_shares(path):
|
||||||
with env.begin(db=shares) as txn:
|
with env.begin(db=shares) as txn:
|
||||||
with txn.cursor() as curs:
|
with txn.cursor() as curs:
|
||||||
curs.last()
|
curs.last()
|
||||||
for i in range(10):
|
for i in range(25):
|
||||||
key, value = curs.item()
|
key, value = curs.item()
|
||||||
height = c_longlong.from_buffer_copy(key).value
|
height = c_longlong.from_buffer_copy(key).value
|
||||||
share = share_t.from_buffer_copy(value)
|
share = share_t.from_buffer_copy(value)
|
||||||
address = format_address(address_from_key(share.address))
|
address = format_address(address_from_key(share.address))
|
||||||
print('{}\t{}'.format(height, address))
|
dt = format_timestamp(share.timestamp)
|
||||||
|
print('{}\t{}\t{}'.format(height, address, dt))
|
||||||
if not curs.prev():
|
if not curs.prev():
|
||||||
break
|
break
|
||||||
env.close()
|
env.close()
|
||||||
|
|
Loading…
Reference in a new issue