move the rct commitments to the output_amounts database

Since these are needed at the same time as the output pubkeys,
this is a whole lot faster, and takes less space. Only outputs
of 0 amount store the commitment. When reading other outputs,
a fake commitment is regenerated on the fly. This avoids having
to rewrite the database to add space for fake commitments for
existing outputs.

This code relies on two things:

- LMDB must support fixed size records per key, rather than
per database (ie, all records on key 0 are the same size, all
records for non 0 keys are same size, but records from key 0
and non 0 keys do have different sizes).

- the commitment must be directly after the rest of the data
in outkey and output_data_t.
This commit is contained in:
moneromooo-monero 2016-06-29 19:55:49 +01:00
parent 6d0e47148b
commit 59a66e209a
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
8 changed files with 63 additions and 195 deletions

View file

@ -90,9 +90,8 @@ void BlockchainDB::add_transaction(const crypto::hash& blk_hash, const transacti
// we need the index
for (uint64_t i = 0; i < tx.vout.size(); ++i)
{
amount_output_indices.push_back(add_output(tx_hash, tx.vout[i], i, tx.unlock_time));
if (tx.version > 1 && tx.vout[i].amount == 0)
add_rct_commitment(tx.rct_signatures.outPk[i].mask);
amount_output_indices.push_back(add_output(tx_hash, tx.vout[i], i, tx.unlock_time,
tx.version > 1 ? &tx.rct_signatures.outPk[i].mask : NULL));
}
add_tx_amount_output_indices(tx_id, amount_output_indices);
}