|
52 | 52 | #include "validationinterface.h" |
53 | 53 | #include "zpivchain.h" |
54 | 54 |
|
| 55 | +// Sapling |
| 56 | +#include "sapling/util.h" |
| 57 | +#include <librustzcash.h> |
| 58 | + |
55 | 59 | #ifdef ENABLE_WALLET |
56 | 60 | #include "wallet/db.h" |
57 | 61 | #include "wallet/wallet.h" |
@@ -752,6 +756,30 @@ bool InitSanityCheck(void) |
752 | 756 | return true; |
753 | 757 | } |
754 | 758 |
|
| 759 | +static void LoadSaplingParams() |
| 760 | +{ |
| 761 | + struct timeval tv_start, tv_end; |
| 762 | + float elapsed; |
| 763 | + gettimeofday(&tv_start, 0); |
| 764 | + |
| 765 | + try { |
| 766 | + initZKSNARKS(); |
| 767 | + } catch (std::runtime_error &e) { |
| 768 | + uiInterface.ThreadSafeMessageBox(strprintf( |
| 769 | + _("Cannot find the Sapling parameters in the following directory:\n" |
| 770 | + "%s\n" |
| 771 | + "Please run 'sapling-fetch-params' or './util/fetch-params.sh' and then restart."), |
| 772 | + ZC_GetParamsDir()), |
| 773 | + "", CClientUIInterface::MSG_ERROR); |
| 774 | + StartShutdown(); |
| 775 | + return; |
| 776 | + } |
| 777 | + |
| 778 | + gettimeofday(&tv_end, 0); |
| 779 | + elapsed = float(tv_end.tv_sec-tv_start.tv_sec) + (tv_end.tv_usec-tv_start.tv_usec)/float(1000000); |
| 780 | + LogPrintf("Loaded Sapling parameters in %fs seconds.\n", elapsed); |
| 781 | +} |
| 782 | + |
755 | 783 | bool AppInitServers() |
756 | 784 | { |
757 | 785 | RPCServer::OnStarted(&OnRPCStarted); |
@@ -1177,6 +1205,9 @@ bool AppInit2() |
1177 | 1205 | CScheduler::Function serviceLoop = boost::bind(&CScheduler::serviceQueue, &scheduler); |
1178 | 1206 | threadGroup.create_thread(boost::bind(&TraceThread<CScheduler::Function>, "scheduler", serviceLoop)); |
1179 | 1207 |
|
| 1208 | + // Initialize Sapling circuit parameters |
| 1209 | + LoadSaplingParams(); |
| 1210 | + |
1180 | 1211 | /* Start the RPC server already. It will be started in "warmup" mode |
1181 | 1212 | * and not really process calls already (but it will signify connections |
1182 | 1213 | * that the server is there and will be ready later). Warmup mode will |
|
0 commit comments