@@ -178,10 +178,25 @@ public static String createAssetIssueForTransactionId(byte[] address, String nam
178178 public static boolean broadcastTransaction (Transaction transaction ,
179179 WalletGrpc .WalletBlockingStub blockingStubFull ) {
180180 Return response = blockingStubFull .broadcastTransaction (transaction );
181+ int i = 10 ;
182+ while (response .getResult () == false && response .getCode () == response_code .SERVER_BUSY
183+ && i > 0 ) {
184+ try {
185+ Thread .sleep (500 );
186+ } catch (Exception e ) {
187+ e .printStackTrace ();
188+ }
189+ i --;
190+ response = blockingStubFull .broadcastTransaction (transaction );
191+ logger .info ("repeat times = " + (10 - i ));
192+ }
193+
181194 if (response .getResult () == false ) {
182- logger .info (ByteArray .toStr (response .getMessage ().toByteArray ()));
183- logger .info (Integer .toString (response .getCode ().getNumber ()));
184- logger .info (Integer .toString (response .getCodeValue ()));
195+ logger .info ("Code = " + response .getCode ());
196+ logger .info ("Message = " + response .getMessage ().toStringUtf8 ());
197+ //logger.info(ByteArray.toStr(response.getMessage().toByteArray()));
198+ //logger.info(Integer.toString(response.getCode().getNumber()));
199+ //logger.info(Integer.toString(response.getCodeValue()));
185200 return false ;
186201 } else {
187202 return true ;
@@ -1311,12 +1326,13 @@ public static boolean setAccountId(byte[] accountIdBytes, byte[] ownerAddress, S
13111326 }
13121327 transaction = signTransaction (ecKey , transaction );
13131328 Return response = blockingStubFull .broadcastTransaction (transaction );
1314- if (response .getResult () == false ) {
1315- logger .info (ByteArray .toStr (response .getMessage ().toByteArray ()));
1316- return false ;
1317- } else {
1318- return true ;
1319- }
1329+ //if (response.getResult() == false) {
1330+ //logger.info(ByteArray.toStr(response.getMessage().toByteArray()));
1331+ //return false;
1332+ //} else {
1333+ //return true;
1334+ //}
1335+ return response .getResult ();
13201336 }
13211337
13221338 /**
@@ -1602,22 +1618,22 @@ public static String deployContractAndGetTransactionInfoById(String contractName
16021618 byte [] contractAddress = PublicMethed .generateContractAddress (transaction , owner );
16031619 System .out .println (
16041620 "Your smart contract address will be: " + WalletClient .encode58Check (contractAddress ));
1605- int i = 10 ;
1621+ // int i = 10;
16061622 Return response = blockingStubFull .broadcastTransaction (transaction );
1607- while (response .getResult () == false && response .getCode () == response_code .SERVER_BUSY
1608- && i > 0 ) {
1609- i --;
1610- response = blockingStubFull .broadcastTransaction (transaction );
1611- logger .info ("repeate times = " + (11 - i ));
1612- try {
1613- Thread .sleep (300 );
1614- } catch (InterruptedException e ) {
1615- e .printStackTrace ();
1616- }
1617- }
1623+ // while (response.getResult() == false && response.getCode() == response_code.SERVER_BUSY
1624+ // && i > 0) {
1625+ // i--;
1626+ // response = blockingStubFull.broadcastTransaction(transaction);
1627+ // logger.info("repeate times = " + (11 - i));
1628+ // try {
1629+ // Thread.sleep(300);
1630+ // } catch (InterruptedException e) {
1631+ // e.printStackTrace();
1632+ // }
1633+ // }
16181634 if (response .getResult () == false ) {
1619- logger .info ("Code = " + response .getCode ());
1620- logger .info ("Message = " + response .getMessage ().toStringUtf8 ());
1635+ // logger.info("Code = " + response.getCode());
1636+ // logger.info("Message = " + response.getMessage().toStringUtf8());
16211637 return null ;
16221638 } else {
16231639 //logger.info("brodacast succesfully");
@@ -2424,22 +2440,22 @@ public static String deployContractWithConstantParame(String contractName, Strin
24242440 byte [] contractAddress = PublicMethed .generateContractAddress (transaction , owner );
24252441 System .out .println (
24262442 "Your smart contract address will be: " + WalletClient .encode58Check (contractAddress ));
2427- int i = 10 ;
2443+ // int i = 10;
24282444 Return response = blockingStubFull .broadcastTransaction (transaction );
2429- while (response .getResult () == false && response .getCode () == response_code .SERVER_BUSY
2430- && i > 0 ) {
2431- i --;
2432- response = blockingStubFull .broadcastTransaction (transaction );
2433- logger .info ("repeate times = " + (11 - i ));
2434- try {
2435- Thread .sleep (300 );
2436- } catch (InterruptedException e ) {
2437- e .printStackTrace ();
2438- }
2439- }
2445+ // while (response.getResult() == false && response.getCode() == response_code.SERVER_BUSY
2446+ // && i > 0) {
2447+ // i--;
2448+ // response = blockingStubFull.broadcastTransaction(transaction);
2449+ // logger.info("repeate times = " + (11 - i));
2450+ // try {
2451+ // Thread.sleep(300);
2452+ // } catch (InterruptedException e) {
2453+ // e.printStackTrace();
2454+ // }
2455+ // }
24402456 if (response .getResult () == false ) {
2441- logger .info ("Code = " + response .getCode ());
2442- logger .info ("Message = " + response .getMessage ().toStringUtf8 ());
2457+ // logger.info("Code = " + response.getCode());
2458+ // logger.info("Message = " + response.getMessage().toStringUtf8());
24432459 return null ;
24442460 } else {
24452461 //logger.info("brodacast succesfully");
@@ -2592,23 +2608,23 @@ public static boolean accountPermissionUpdate(String permissionJson, byte[] owne
25922608 "Receive txid = " + ByteArray .toHexString (transactionExtention .getTxid ().toByteArray ()));
25932609
25942610 transaction = signTransaction (transaction , blockingStubFull , priKeys );
2595- int i = 10 ;
2611+ // int i = 10;
25962612 Return response = blockingStubFull .broadcastTransaction (transaction );
2597- while (response .getResult () == false && response .getCode () == response_code .SERVER_BUSY
2598- && i > 0 ) {
2599- i --;
2600- response = blockingStubFull .broadcastTransaction (transaction );
2601- logger .info ("repeat times = " + (11 - i ));
2602- try {
2603- Thread .sleep (300 );
2604- } catch (InterruptedException e ) {
2605- e .printStackTrace ();
2606- }
2607- }
2608- if (response .getResult () == false ) {
2609- logger .info ("Code = " + response .getCode ());
2610- logger .info ("Message = " + response .getMessage ().toStringUtf8 ());
2611- }
2613+ // while (response.getResult() == false && response.getCode() == response_code.SERVER_BUSY
2614+ // && i > 0) {
2615+ // i--;
2616+ // response = blockingStubFull.broadcastTransaction(transaction);
2617+ // logger.info("repeat times = " + (11 - i));
2618+ // try {
2619+ // Thread.sleep(300);
2620+ // } catch (InterruptedException e) {
2621+ // e.printStackTrace();
2622+ // }
2623+ // }
2624+ // if (response.getResult() == false) {
2625+ // // logger.info("Code = " + response.getCode());
2626+ // // logger.info("Message = " + response.getMessage().toStringUtf8());
2627+ // }
26122628 return response .getResult ();
26132629 }
26142630
@@ -2677,22 +2693,22 @@ public static String accountPermissionUpdateForTransactionId(String permissionJs
26772693 "Receive txid = " + ByteArray .toHexString (transactionExtention .getTxid ().toByteArray ()));
26782694
26792695 transaction = signTransaction (transaction , blockingStubFull , priKeys );
2680- int i = 10 ;
2696+ // int i = 10;
26812697 Return response = blockingStubFull .broadcastTransaction (transaction );
2682- while (response .getResult () == false && response .getCode () == response_code .SERVER_BUSY
2683- && i > 0 ) {
2684- i --;
2685- response = blockingStubFull .broadcastTransaction (transaction );
2686- logger .info ("repeat times = " + (11 - i ));
2687- try {
2688- Thread .sleep (300 );
2689- } catch (InterruptedException e ) {
2690- e .printStackTrace ();
2691- }
2692- }
2698+ // while (response.getResult() == false && response.getCode() == response_code.SERVER_BUSY
2699+ // && i > 0) {
2700+ // i--;
2701+ // response = blockingStubFull.broadcastTransaction(transaction);
2702+ // logger.info("repeat times = " + (11 - i));
2703+ // try {
2704+ // Thread.sleep(300);
2705+ // } catch (InterruptedException e) {
2706+ // e.printStackTrace();
2707+ // }
2708+ // }
26932709 if (response .getResult () == false ) {
2694- logger .info ("Code = " + response .getCode ());
2695- logger .info ("Message = " + response .getMessage ().toStringUtf8 ());
2710+ // logger.info("Code = " + response.getCode());
2711+ // logger.info("Message = " + response.getMessage().toStringUtf8());
26962712 return null ;
26972713 } else {
26982714 return ByteArray .toHexString (Sha256Hash .hash (transaction .getRawData ().toByteArray ()));
@@ -2770,22 +2786,22 @@ public static String accountPermissionUpdateForTransactionId1(String permissionJ
27702786 "Receive txid = " + ByteArray .toHexString (transactionExtention .getTxid ().toByteArray ()));
27712787
27722788 transaction = signTransaction (transaction , blockingStubFull , priKeys );
2773- int i = 10 ;
2789+ // int i = 10;
27742790 Return response = blockingStubFull .broadcastTransaction (transaction );
2775- while (response .getResult () == false && response .getCode () == response_code .SERVER_BUSY
2776- && i > 0 ) {
2777- i --;
2778- response = blockingStubFull .broadcastTransaction (transaction );
2779- logger .info ("repeat times = " + (11 - i ));
2780- try {
2781- Thread .sleep (300 );
2782- } catch (InterruptedException e ) {
2783- e .printStackTrace ();
2784- }
2785- }
2791+ // while (response.getResult() == false && response.getCode() == response_code.SERVER_BUSY
2792+ // && i > 0) {
2793+ // i--;
2794+ // response = blockingStubFull.broadcastTransaction(transaction);
2795+ // logger.info("repeat times = " + (11 - i));
2796+ // try {
2797+ // Thread.sleep(300);
2798+ // } catch (InterruptedException e) {
2799+ // e.printStackTrace();
2800+ // }
2801+ // }
27862802 if (response .getResult () == false ) {
2787- logger .info ("Code = " + response .getCode ());
2788- logger .info ("Message = " + response .getMessage ().toStringUtf8 ());
2803+ // logger.info("Code = " + response.getCode());
2804+ // logger.info("Message = " + response.getMessage().toStringUtf8());
27892805 return null ;
27902806 } else {
27912807 return ByteArray .toHexString (Sha256Hash .hash (transaction .getRawData ().toByteArray ()));
@@ -3015,6 +3031,10 @@ public static Return broadcastTransaction1(Transaction transaction,
30153031 e .printStackTrace ();
30163032 }
30173033 }
3034+ if (response .getResult () == false ) {
3035+ logger .info ("Code = " + response .getCode ());
3036+ logger .info ("Message = " + response .getMessage ().toStringUtf8 ());
3037+ }
30183038 return response ;
30193039 }
30203040
@@ -3092,23 +3112,23 @@ public static boolean accountPermissionUpdateWithPermissionId(String permissionJ
30923112 "Receive txid = " + ByteArray .toHexString (transactionExtention .getTxid ().toByteArray ()));
30933113
30943114 transaction = signTransaction (transaction , blockingStubFull , priKeys );
3095- int i = 10 ;
3096- Return response = blockingStubFull . broadcastTransaction (transaction );
3097- while (response .getResult () == false && response .getCode () == response_code .SERVER_BUSY
3098- && i > 0 ) {
3099- i --;
3100- response = blockingStubFull .broadcastTransaction (transaction );
3101- logger .info ("repeat times = " + (11 - i ));
3102- try {
3103- Thread .sleep (300 );
3104- } catch (InterruptedException e ) {
3105- e .printStackTrace ();
3106- }
3107- }
3108- if (response .getResult () == false ) {
3109- logger .info ("Code = " + response .getCode ());
3110- logger .info ("Message = " + response .getMessage ().toStringUtf8 ());
3111- }
3115+ // int i = 10;
3116+ Return response = broadcastTransaction1 (transaction , blockingStubFull );
3117+ // while (response.getResult() == false && response.getCode() == response_code.SERVER_BUSY
3118+ // && i > 0) {
3119+ // i--;
3120+ // response = blockingStubFull.broadcastTransaction(transaction);
3121+ // logger.info("repeat times = " + (11 - i));
3122+ // try {
3123+ // Thread.sleep(300);
3124+ // } catch (InterruptedException e) {
3125+ // e.printStackTrace();
3126+ // }
3127+ // }
3128+ // if (response.getResult() == false) {
3129+ // logger.info("Code = " + response.getCode());
3130+ // logger.info("Message = " + response.getMessage().toStringUtf8());
3131+ // }
31123132 return response .getResult ();
31133133 }
31143134
@@ -3411,23 +3431,23 @@ public static GrpcAPI.Return accountPermissionUpdateForResponse(String permissio
34113431 "Receive txid = " + ByteArray .toHexString (transactionExtention .getTxid ().toByteArray ()));
34123432
34133433 transaction = signTransaction (transaction , blockingStubFull , priKeys );
3414- int i = 10 ;
3415- Return response = blockingStubFull . broadcastTransaction (transaction );
3416- while (response .getResult () == false && response .getCode () == response_code .SERVER_BUSY
3417- && i > 0 ) {
3418- i --;
3419- response = blockingStubFull .broadcastTransaction (transaction );
3420- logger .info ("repeat times = " + (11 - i ));
3421- try {
3422- Thread .sleep (300 );
3423- } catch (InterruptedException e ) {
3424- e .printStackTrace ();
3425- }
3426- }
3427- if (response .getResult () == false ) {
3428- logger .info ("Code = " + response .getCode ());
3429- logger .info ("Message = " + response .getMessage ().toStringUtf8 ());
3430- }
3434+ // int i = 10;
3435+ Return response = broadcastTransaction1 (transaction , blockingStubFull );
3436+ // while (response.getResult() == false && response.getCode() == response_code.SERVER_BUSY
3437+ // && i > 0) {
3438+ // i--;
3439+ // response = blockingStubFull.broadcastTransaction(transaction);
3440+ // logger.info("repeat times = " + (11 - i));
3441+ // try {
3442+ // Thread.sleep(300);
3443+ // } catch (InterruptedException e) {
3444+ // e.printStackTrace();
3445+ // }
3446+ // }
3447+ // if (response.getResult() == false) {
3448+ // logger.info("Code = " + response.getCode());
3449+ // logger.info("Message = " + response.getMessage().toStringUtf8());
3450+ // }
34313451 return response ;
34323452 }
34333453
@@ -3804,23 +3824,8 @@ public static byte[] deployContractWithPermissionId(String contractName, String
38043824 System .out .println (
38053825 "Your smart contract address will be: " + WalletClient .encode58Check (contractAddress ));
38063826
3807- int i = 10 ;
3808- GrpcAPI .Return response = blockingStubFull .broadcastTransaction (transaction );
3809-
3810- while (response .getResult () == false && response .getCode () == response_code .SERVER_BUSY
3811- && i > 0 ) {
3812- i --;
3813- response = blockingStubFull .broadcastTransaction (transaction );
3814- logger .info ("repeate times = " + (11 - i ));
3815- try {
3816- Thread .sleep (300 );
3817- } catch (InterruptedException e ) {
3818- e .printStackTrace ();
3819- }
3820- }
3827+ GrpcAPI .Return response = broadcastTransaction1 (transaction , blockingStubFull );
38213828 if (response .getResult () == false ) {
3822- logger .info ("Code = " + response .getCode ());
3823- logger .info ("Message = " + response .getMessage ().toStringUtf8 ());
38243829 return null ;
38253830 } else {
38263831 //logger.info("brodacast succesfully");
@@ -4309,13 +4314,15 @@ public static boolean setAccountId1(byte[] accountIdBytes, byte[] ownerAddress,
43094314 e .printStackTrace ();
43104315 }
43114316 transaction = signTransaction (transaction , blockingStubFull , permissionKeyString );
4312- Return response = blockingStubFull .broadcastTransaction (transaction );
4313- if (response .getResult () == false ) {
4314- logger .info (ByteArray .toStr (response .getMessage ().toByteArray ()));
4315- return false ;
4316- } else {
4317- return true ;
4318- }
4317+ return broadcastTransaction (transaction , blockingStubFull );
4318+ //Return response = broadcastTransaction1(transaction, blockingStubFull);
4319+ //if (response.getResult() == false) {
4320+ // logger.info(ByteArray.toStr(response.getMessage().toByteArray()));
4321+ // return false;
4322+ //} else {
4323+ // return true;
4324+ //}
4325+ //return response.getResult();
43194326 }
43204327
43214328
0 commit comments