Add benchmark for incrementing note witnesses
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "script/sign.h"
|
||||
#include "sodium.h"
|
||||
#include "streams.h"
|
||||
#include "utiltest.h"
|
||||
#include "wallet/wallet.h"
|
||||
|
||||
#include "zcbenchmarks.h"
|
||||
@@ -243,3 +244,45 @@ double benchmark_try_decrypt_notes(const JSDescription &joinsplit)
|
||||
return timer_stop(tv_start);
|
||||
}
|
||||
|
||||
double benchmark_increment_note_witnesses(size_t nTxs)
|
||||
{
|
||||
CWallet wallet;
|
||||
ZCIncrementalMerkleTree tree;
|
||||
|
||||
auto sk = libzcash::SpendingKey::random();
|
||||
wallet.AddSpendingKey(sk);
|
||||
|
||||
// First block
|
||||
CBlock block1;
|
||||
for (int i = 0; i < nTxs; i++) {
|
||||
auto wtx = GetValidReceive(*pzcashParams, sk, 10, true);
|
||||
auto note = GetNote(*pzcashParams, sk, wtx, 0, 1);
|
||||
auto nullifier = note.nullifier(sk);
|
||||
|
||||
mapNoteData_t noteData;
|
||||
JSOutPoint jsoutpt {wtx.GetHash(), 0, 1};
|
||||
CNoteData nd {sk.address(), nullifier};
|
||||
noteData[jsoutpt] = nd;
|
||||
|
||||
wtx.SetNoteData(noteData);
|
||||
wallet.AddToWallet(wtx, true, NULL);
|
||||
block1.vtx.push_back(wtx);
|
||||
}
|
||||
CBlockIndex index1(block1);
|
||||
index1.nHeight = 1;
|
||||
|
||||
// Increment to get transactions witnessed
|
||||
wallet.ChainTip(&index1, &block1, tree, true);
|
||||
|
||||
// Second block
|
||||
CBlock block2;
|
||||
block2.hashPrevBlock = block1.GetHash();
|
||||
CBlockIndex index2(block2);
|
||||
index2.nHeight = 2;
|
||||
|
||||
struct timeval tv_start;
|
||||
timer_start(tv_start);
|
||||
wallet.ChainTip(&index2, &block2, tree, true);
|
||||
return timer_stop(tv_start);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user