Add JoinSplit verification benchmarks

This commit is contained in:
Taylor Hornby
2016-04-11 09:17:02 -06:00
parent bf8def9749
commit d44feea44c
4 changed files with 39 additions and 2 deletions

View File

@@ -2396,7 +2396,20 @@ Value zc_benchmark(const json_spirit::Array& params, bool fHelp)
} else if (benchmarktype == "createjoinsplit") {
sample_times.push_back(benchmark_create_joinsplit());
} else if (benchmarktype == "verifyjoinsplit") {
throw JSONRPCError(RPC_TYPE_ERROR, "Unimplemented");
if (params.size() != 3) {
throw JSONRPCError(RPC_TYPE_ERROR, "Please provide a transaction with a JoinSplit.");
}
CTransaction tx;
if (!DecodeHexTx(tx, params[2].get_str())) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
}
if (tx.vpour.size() != 1) {
throw JSONRPCError(RPC_TYPE_ERROR, "The transaction must have exactly one JoinSplit.");
}
sample_times.push_back(benchmark_verify_joinsplit(tx.vpour[0]));
} else if (benchmarktype == "solveequihash") {
sample_times.push_back(benchmark_solve_equihash());
} else if (benchmarktype == "verifyequihash") {

View File

@@ -102,3 +102,10 @@ double benchmark_solve_equihash()
eh.BasicSolve(eh_state);
return timer_stop();
}
double benchmark_verify_joinsplit(const CPourTx &joinsplit)
{
timer_start();
joinsplit.Verify(*pzerocashParams);
return timer_stop();
}

View File

@@ -8,5 +8,6 @@ extern double benchmark_sleep();
extern double benchmark_parameter_loading();
extern double benchmark_create_joinsplit();
extern double benchmark_solve_equihash();
extern double benchmark_verify_joinsplit(const CPourTx &joinsplit);
#endif