fix balance updates

This commit is contained in:
Jethro Grassie 2019-08-21 18:32:57 -04:00
parent 4d69befdd1
commit 2c636d00e9
No known key found for this signature in database
GPG key ID: DE8ED755616565BB

View file

@ -572,7 +572,12 @@ balance_add(const char *address, uint64_t amount, MDB_txn *parent)
{ {
log_trace("Adding new balance entry"); log_trace("Adding new balance entry");
MDB_val new_val = { sizeof(amount), (void*)&amount }; MDB_val new_val = { sizeof(amount), (void*)&amount };
mdb_cursor_put(cursor, &key, &new_val, MDB_APPEND); rc = mdb_cursor_put(cursor, &key, &new_val, 0);
if (rc != 0)
{
err = mdb_strerror(rc);
log_error("%s", err);
}
} }
else if (rc == 0) else if (rc == 0)
{ {
@ -663,6 +668,8 @@ payout_block(block_t *block, MDB_txn *parent)
rc = balance_add(share->address, amount, txn); rc = balance_add(share->address, amount, txn);
if (rc != 0) if (rc != 0)
{ {
err = mdb_strerror(rc);
log_error("%s", err);
mdb_cursor_close(cursor); mdb_cursor_close(cursor);
mdb_txn_abort(txn); mdb_txn_abort(txn);
return rc; return rc;