@@ -30,24 +30,30 @@ public static void librustzcashInitZksnarkParams() {
3030 return ;
3131 }
3232
33- logger .info ("init zk param begin" );
33+ synchronized (ZksnarkInitService .class ) {
34+ if (initialized .get ()) {
35+ logger .info ("zk param already initialized" );
36+ return ;
37+ }
38+ logger .info ("init zk param begin" );
3439
35- String spendPath = getParamsFile ("sapling-spend.params" );
36- String spendHash = "25fd9a0d1c1be0526c14662947ae95b758fe9f3d7fb7f55e9b4437830dcc6215a7ce3ea465 "
37- + "914b157715b7a4d681389ea4aa84438190e185d5e4c93574d3a19a " ;
40+ String spendPath = getParamsFile ("sapling-spend.params" );
41+ String spendHash = "25fd9a0d1c1be0526c14662947ae95b758fe9f3d7fb7f55e9b4437830dcc6215a7ce3ea "
42+ + "465914b157715b7a4d681389ea4aa84438190e185d5e4c93574d3a19a " ;
3843
39- String outputPath = getParamsFile ("sapling-output.params" );
40- String outputHash = "a1cb23b93256adce5bce2cb09cefbc96a1d16572675ceb691e9a3626ec15b5b546926ff1c "
41- + "536cfe3a9df07d796b32fdfc3e5d99d65567257bf286cd2858d71a6 " ;
44+ String outputPath = getParamsFile ("sapling-output.params" );
45+ String outputHash = "a1cb23b93256adce5bce2cb09cefbc96a1d16572675ceb691e9a3626ec15b5b546926f "
46+ + "f1c536cfe3a9df07d796b32fdfc3e5d99d65567257bf286cd2858d71a6 " ;
4247
43- try {
44- JLibrustzcash .librustzcashInitZksnarkParams (
45- new LibrustzcashParam .InitZksnarkParams (spendPath , spendHash , outputPath , outputHash ));
48+ try {
49+ JLibrustzcash .librustzcashInitZksnarkParams (
50+ new LibrustzcashParam .InitZksnarkParams (spendPath , spendHash , outputPath , outputHash ));
51+ } catch (ZksnarkException e ) {
52+ throw new TronError (e , TronError .ErrCode .ZCASH_INIT );
53+ }
4654 initialized .set (true );
47- } catch (ZksnarkException e ) {
48- throw new TronError (e , TronError .ErrCode .ZCASH_INIT );
55+ logger .info ("init zk param done" );
4956 }
50- logger .info ("init zk param done" );
5157 }
5258
5359 private static String getParamsFile (String fileName ) {
0 commit comments