Browse Source

delete the ledger-model in runtime-context;

use ACCOUNT_REGISTER_CONFLICT STATE;
throw UndeclaredThrowableException in the JavaContractCode.java;
tags/1.1.5
zhaoguangwei 5 years ago
parent
commit
b65f9111d2
6 changed files with 30 additions and 21 deletions
  1. +8
    -2
      source/contract/contract-jvm/src/main/java/com/jd/blockchain/contract/jvm/JavaContractCode.java
  2. +1
    -1
      source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/MerkleAccountSet.java
  3. +5
    -5
      source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/TransactionState.java
  4. +0
    -6
      source/runtime/runtime-context/pom.xml
  5. +14
    -5
      source/runtime/runtime-context/src/main/java/com/jd/blockchain/runtime/AbstractModule.java
  6. +2
    -2
      source/tools/tools-initializer/src/main/java/com/jd/blockchain/tools/initializer/web/LedgerInitializeWebController.java

+ 8
- 2
source/contract/contract-jvm/src/main/java/com/jd/blockchain/contract/jvm/JavaContractCode.java View File

@@ -1,7 +1,9 @@
package com.jd.blockchain.contract.jvm;

import java.lang.reflect.UndeclaredThrowableException;
import java.util.concurrent.Callable;

import com.jd.blockchain.ledger.ContractExecuteException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@@ -100,8 +102,12 @@ public class JavaContractCode extends AbstractContractCode {
}

@Override
public BytesValue call() throws Exception {
return JavaContractCode.super.processEvent(eventContext);
public BytesValue call() {
try {
return JavaContractCode.super.processEvent(eventContext);
} catch (Exception e) {
throw new UndeclaredThrowableException(new ContractExecuteException());
}
}
}



+ 1
- 1
source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/MerkleAccountSet.java View File

@@ -250,7 +250,7 @@ public class MerkleAccountSet implements Transactional, MerkleProvable, AccountQ
}
long version = merkleDataset.getVersion(address);
if (version >= 0) {
throw new LedgerException("The registering account already exist!", TransactionState.DATA_ACCOUNT_EXIST);
throw new LedgerException("The registering account already exist!", TransactionState.ACCOUNT_REGISTER_CONFLICT);
}

if (!accessPolicy.checkRegistering(address, pubKey)) {


+ 5
- 5
source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/TransactionState.java View File

@@ -29,11 +29,6 @@ public enum TransactionState {
*/
DATA_ACCOUNT_DOES_NOT_EXIST((byte) 0x02),

/**
* 数据账户存在;
*/
DATA_ACCOUNT_EXIST((byte) 0x12),

/**
* 用户不存在;
*/
@@ -64,6 +59,11 @@ public enum TransactionState {
*/
REJECTED_BY_SECURITY_POLICY((byte) 0x10),

/**
* 账户注册冲突;
*/
ACCOUNT_REGISTER_CONFLICT((byte) 0x12),

/**
* 由于在错误的账本上执行交易而被丢弃;
*/


+ 0
- 6
source/runtime/runtime-context/pom.xml View File

@@ -15,11 +15,5 @@
<artifactId>utils-common</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.jd.blockchain</groupId>
<artifactId>ledger-model</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

+ 14
- 5
source/runtime/runtime-context/src/main/java/com/jd/blockchain/runtime/AbstractModule.java View File

@@ -1,12 +1,12 @@
package com.jd.blockchain.runtime;

import java.io.InputStream;
import java.util.concurrent.Callable;

import com.jd.blockchain.ledger.ContractExecuteException;
import com.jd.blockchain.utils.concurrent.AsyncFuture;
import com.jd.blockchain.utils.concurrent.CompletableAsyncFuture;

import java.io.InputStream;
import java.lang.reflect.UndeclaredThrowableException;
import java.util.concurrent.Callable;

public abstract class AbstractModule implements Module {
@@ -93,8 +93,17 @@ public abstract class AbstractModule implements Module {
}
try {
return callable.call();
} catch (UndeclaredThrowableException e) {
if(e.getCause() == null){
throw e;
}
if(e.getCause() instanceof RuntimeException){
throw (RuntimeException)e.getCause();
}

throw new IllegalStateException(e.getCause().getMessage(), e.getCause());
} catch (Exception e) {
throw new ContractExecuteException(e.getMessage(), e);
throw new IllegalStateException(e.getMessage(), e);
} finally {
if (origClassLoader != Thread.currentThread().getContextClassLoader()) {
Thread.currentThread().setContextClassLoader(origClassLoader);


+ 2
- 2
source/tools/tools-initializer/src/main/java/com/jd/blockchain/tools/initializer/web/LedgerInitializeWebController.java View File

@@ -272,9 +272,9 @@ public class LedgerInitializeWebController implements LedgerInitProcess, LedgerI
do {
allPermitted = startRequestPermissions(currentId, privKey);
if (!allPermitted) {
if (retry < 181) {
if (retry < 601) {
try {
Thread.sleep(10000);
Thread.sleep(3000);
} catch (InterruptedException e) {
// ignore interrupted exception;
}


Loading…
Cancel
Save