Skip to content

Commit

Permalink
<fix>(console): fix load account failed not exit bug. (#813)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyonRay authored Jan 3, 2024
1 parent dff0b76 commit 4d1b13d
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/main/java/console/ConsoleInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,25 +171,31 @@ private void loadAccountInfo(AccountInfo accountInfo, String groupID) {
.getConfig()
.getAccountConfig()
.isAccountConfigured()) {
accountInfo = loadAccountRandomly(bcosSDK, client);
if (accountInfo != null) {
// load key from account dir
AccountInfo newAccountInfo = loadAccountRandomly(bcosSDK, client);
if (newAccountInfo != null) {
this.client
.getCryptoSuite()
.loadAccount(
accountInfo.accountFileFormat,
accountInfo.accountFile,
accountInfo.password);
newAccountInfo.accountFileFormat,
newAccountInfo.accountFile,
newAccountInfo.password);
}
if (accountInfo == null) {
if (newAccountInfo == null) {
// still not found key, use client crypto key pair
// save the keyPair
client.getCryptoSuite().getCryptoKeyPair().storeKeyPairWithPemFormat();
}
}
} catch (LoadKeyStoreException e) {
logger.warn(
logger.error(
"loadAccountRandomly failed, try to generate and load the random account, error info: {}",
e.getMessage(),
e);
System.out.println(
"Failed to load the account from the keyStoreDir, error info: "
+ e.getMessage());
System.exit(0);
} catch (Exception e) {
System.out.println(
"Failed to create BcosSDK failed! Please check the node status and the console configuration, error info: "
Expand Down

0 comments on commit 4d1b13d

Please sign in to comment.