@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>jdchain-root</artifactId> | <artifactId>jdchain-root</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>base</artifactId> | <artifactId>base</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>jdchain-root</artifactId> | <artifactId>jdchain-root</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>binary-proto</artifactId> | <artifactId>binary-proto</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>consensus</artifactId> | <artifactId>consensus</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>consensus-bftsmart</artifactId> | <artifactId>consensus-bftsmart</artifactId> | ||||
@@ -359,33 +359,107 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer | |||||
* Used by consensus write phase, pre compute new block hash | * Used by consensus write phase, pre compute new block hash | ||||
* | * | ||||
*/ | */ | ||||
// public BatchAppResultImpl preComputeAppHash(byte[][] commands) { | |||||
// String batchId = messageHandle.beginBatch(realmName); | |||||
// List<AsyncFuture<byte[]>> asyncFutureLinkedList = new ArrayList<>(commands.length); | |||||
// List<byte[]> responseLinkedList = new ArrayList<>(); | |||||
// try { | |||||
// int msgId = 0; | |||||
// for (byte[] txContent : commands) { | |||||
// AsyncFuture<byte[]> asyncFuture = messageHandle.processOrdered(msgId++, txContent, realmName, batchId); | |||||
// asyncFutureLinkedList.add(asyncFuture); | |||||
// } | |||||
// StateSnapshot stateSnapshot = messageHandle.completeBatch(realmName, batchId); | |||||
// byte[] blockHashBytes = stateSnapshot.getSnapshot(); | |||||
// | |||||
// for (int i = 0; i< asyncFutureLinkedList.size(); i++) { | |||||
// responseLinkedList.add(asyncFutureLinkedList.get(i).get()); | |||||
// } | |||||
// | |||||
// | |||||
// return new BatchAppResultImpl(responseLinkedList, blockHashBytes, batchId); | |||||
// | |||||
// } catch (Exception e) { | |||||
// // todo 需要处理应答码 404 | |||||
// LOGGER.error("Error occurred while processing ordered messages! --" + e.getMessage(), e); | |||||
// messageHandle.rollbackBatch(realmName, batchId, TransactionState.IGNORED_BY_CONSENSUS_PHASE_PRECOMPUTE_ROLLBACK.CODE); | |||||
// } | |||||
// | |||||
// return null; | |||||
// } | |||||
/** | |||||
* Used by consensus write phase, pre compute new block hash | |||||
*/ | |||||
public BatchAppResultImpl preComputeAppHash(byte[][] commands) { | public BatchAppResultImpl preComputeAppHash(byte[][] commands) { | ||||
String batchId = messageHandle.beginBatch(realmName); | String batchId = messageHandle.beginBatch(realmName); | ||||
List<AsyncFuture<byte[]>> asyncFutureLinkedList = new ArrayList<>(commands.length); | List<AsyncFuture<byte[]>> asyncFutureLinkedList = new ArrayList<>(commands.length); | ||||
List<byte[]> responseLinkedList = new ArrayList<>(); | List<byte[]> responseLinkedList = new ArrayList<>(); | ||||
BatchAppResultImpl result; | |||||
try { | try { | ||||
int msgId = 0; | int msgId = 0; | ||||
for (byte[] txContent : commands) { | |||||
AsyncFuture<byte[]> asyncFuture = messageHandle.processOrdered(msgId++, txContent, realmName, batchId); | |||||
asyncFutureLinkedList.add(asyncFuture); | |||||
} | |||||
StateSnapshot stateSnapshot = messageHandle.completeBatch(realmName, batchId); | |||||
byte[] blockHashBytes = stateSnapshot.getSnapshot(); | |||||
for (int i = 0; i< asyncFutureLinkedList.size(); i++) { | |||||
responseLinkedList.add(asyncFutureLinkedList.get(i).get()); | |||||
boolean isOK = true; | |||||
TransactionState transactionState = TransactionState.IGNORED_BY_BLOCK_FULL_ROLLBACK; | |||||
for (int i = 0; i < commands.length; i++) { | |||||
byte[] txContent = commands[i]; | |||||
try { | |||||
AsyncFuture<byte[]> asyncFuture = messageHandle.processOrdered(msgId++, txContent, realmName, batchId); | |||||
asyncFutureLinkedList.add(asyncFuture); | |||||
} catch (BlockRollbackException e) { | |||||
LOGGER.error("Error occurred while processing ordered messages! --" + e.getMessage(), e); | |||||
isOK = false; | |||||
// TODO: handle the BlockRollbackException in detail; | |||||
if (e instanceof DataVersionConflictException) { | |||||
transactionState = TransactionState.DATA_VERSION_CONFLICT; | |||||
} | |||||
break; | |||||
} | |||||
} | } | ||||
if (isOK) { | |||||
StateSnapshot stateSnapshot = messageHandle.completeBatch(realmName, batchId); | |||||
byte[] blockHashBytes = stateSnapshot.getSnapshot(); | |||||
for (int i = 0; i < asyncFutureLinkedList.size(); i++) { | |||||
responseLinkedList.add(asyncFutureLinkedList.get(i).get()); | |||||
} | |||||
result = new BatchAppResultImpl(responseLinkedList, blockHashBytes, batchId); | |||||
result.setErrorCode((byte) 0); | |||||
return result; | |||||
} else { | |||||
for (int i = 0; i < commands.length; i++) { | |||||
responseLinkedList.add(createAppResponse(commands[i],transactionState)); | |||||
} | |||||
Random random = new Random(); | |||||
byte[] rand = new byte[4]; | |||||
random.nextBytes(rand); | |||||
return new BatchAppResultImpl(responseLinkedList, blockHashBytes, batchId); | |||||
result = new BatchAppResultImpl(responseLinkedList, rand, batchId); | |||||
result.setErrorCode((byte) 1); | |||||
return result; | |||||
} | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
// todo 需要处理应答码 404 | |||||
LOGGER.error("Error occurred while processing ordered messages! --" + e.getMessage(), e); | |||||
messageHandle.rollbackBatch(realmName, batchId, TransactionState.IGNORED_BY_CONSENSUS_PHASE_PRECOMPUTE_ROLLBACK.CODE); | |||||
LOGGER.error("Error occurred while genearte batch app result! --" + e.getMessage(), e); | |||||
throw e; | |||||
} | } | ||||
} | |||||
return null; | |||||
public byte[] createAppResponse(byte[] command, TransactionState transactionState) { | |||||
TransactionRequest txRequest = BinaryProtocol.decode(command); | |||||
TxResponseMessage resp = new TxResponseMessage(txRequest.getTransactionContent().getHash()); | |||||
// resp.setExecutionState(TransactionState.IGNORED_BY_BLOCK_FULL_ROLLBACK); | |||||
resp.setExecutionState(transactionState); | |||||
return BinaryProtocol.encode(resp, TransactionResponse.class); | |||||
} | } | ||||
/** | /** | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>consensus</artifactId> | <artifactId>consensus</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>consensus-framework</artifactId> | <artifactId>consensus-framework</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>consensus</artifactId> | <artifactId>consensus</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>consensus-mq</artifactId> | <artifactId>consensus-mq</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>jdchain-root</artifactId> | <artifactId>jdchain-root</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>consensus</artifactId> | <artifactId>consensus</artifactId> | ||||
<packaging>pom</packaging> | <packaging>pom</packaging> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>contract</artifactId> | <artifactId>contract</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>contract-framework</artifactId> | <artifactId>contract-framework</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>contract</artifactId> | <artifactId>contract</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>contract-jvm</artifactId> | <artifactId>contract-jvm</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>contract</artifactId> | <artifactId>contract</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>contract-maven-plugin</artifactId> | <artifactId>contract-maven-plugin</artifactId> | ||||
<packaging>maven-plugin</packaging> | <packaging>maven-plugin</packaging> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<artifactId>contract</artifactId> | <artifactId>contract</artifactId> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<modelVersion>4.0.0</modelVersion> | <modelVersion>4.0.0</modelVersion> | ||||
@@ -4,7 +4,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>jdchain-root</artifactId> | <artifactId>jdchain-root</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>contract</artifactId> | <artifactId>contract</artifactId> | ||||
<packaging>pom</packaging> | <packaging>pom</packaging> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>crypto</artifactId> | <artifactId>crypto</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>crypto-adv</artifactId> | <artifactId>crypto-adv</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>crypto</artifactId> | <artifactId>crypto</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>crypto-classic</artifactId> | <artifactId>crypto-classic</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>crypto</artifactId> | <artifactId>crypto</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>crypto-framework</artifactId> | <artifactId>crypto-framework</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<artifactId>crypto</artifactId> | <artifactId>crypto</artifactId> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<modelVersion>4.0.0</modelVersion> | <modelVersion>4.0.0</modelVersion> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>crypto</artifactId> | <artifactId>crypto</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>crypto-sm</artifactId> | <artifactId>crypto-sm</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>jdchain-root</artifactId> | <artifactId>jdchain-root</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>crypto</artifactId> | <artifactId>crypto</artifactId> | ||||
<packaging>pom</packaging> | <packaging>pom</packaging> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>deployment</artifactId> | <artifactId>deployment</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>deployment-gateway</artifactId> | <artifactId>deployment-gateway</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>deployment</artifactId> | <artifactId>deployment</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>deployment-peer</artifactId> | <artifactId>deployment-peer</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>jdchain-root</artifactId> | <artifactId>jdchain-root</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>deployment</artifactId> | <artifactId>deployment</artifactId> | ||||
<packaging>pom</packaging> | <packaging>pom</packaging> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>jdchain-root</artifactId> | <artifactId>jdchain-root</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>gateway</artifactId> | <artifactId>gateway</artifactId> | ||||
@@ -5,15 +5,26 @@ import com.jd.blockchain.gateway.PeerService; | |||||
import com.jd.blockchain.ledger.ContractCodeDeployOperation; | import com.jd.blockchain.ledger.ContractCodeDeployOperation; | ||||
import com.jd.blockchain.ledger.Operation; | import com.jd.blockchain.ledger.Operation; | ||||
import com.jd.blockchain.ledger.TransactionRequest; | import com.jd.blockchain.ledger.TransactionRequest; | ||||
import org.apache.commons.io.FileUtils; | |||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import org.springframework.util.ResourceUtils; | |||||
import java.io.File; | |||||
import java.net.URL; | |||||
@Service | @Service | ||||
public class GatewayInterceptServiceHandler implements GatewayInterceptService { | public class GatewayInterceptServiceHandler implements GatewayInterceptService { | ||||
private static String contractsPath; | |||||
@Autowired | @Autowired | ||||
private PeerService peerService; | private PeerService peerService; | ||||
static { | |||||
contractsPath = jarRootDir(); | |||||
} | |||||
@Override | @Override | ||||
public void intercept(TransactionRequest txRequest) { | public void intercept(TransactionRequest txRequest) { | ||||
// 当前仅处理合约发布的请求 | // 当前仅处理合约发布的请求 | ||||
@@ -29,7 +40,34 @@ public class GatewayInterceptServiceHandler implements GatewayInterceptService { | |||||
} | } | ||||
private void contractCheck(final ContractCodeDeployOperation contractOP) { | private void contractCheck(final ContractCodeDeployOperation contractOP) { | ||||
// 校验chainCode | // 校验chainCode | ||||
ContractJarUtils.verify(contractOP.getChainCode()); | |||||
ContractJarUtils.verify(contractsPath, contractOP.getChainCode()); | |||||
} | |||||
private static String jarRootDir() { | |||||
try { | |||||
URL url = GatewayInterceptServiceHandler.class.getProtectionDomain().getCodeSource().getLocation(); | |||||
String currPath = java.net.URLDecoder.decode(url.getPath(), "UTF-8"); | |||||
if (currPath.contains("!/")) { | |||||
currPath = currPath.substring(5, currPath.indexOf("!/")); | |||||
} | |||||
if (currPath.endsWith(".jar")) { | |||||
currPath = currPath.substring(0, currPath.lastIndexOf("/") + 1); | |||||
} | |||||
File file = new File(currPath); | |||||
String homeDir = file.getParent(); | |||||
String jarRootPath = homeDir + File.separator + "contracts"; | |||||
FileUtils.forceMkdir(new File(jarRootPath)); | |||||
return jarRootPath; | |||||
} catch (Exception e) { | |||||
throw new IllegalStateException(e); | |||||
} | |||||
} | } | ||||
} | } |
@@ -597,7 +597,7 @@ public class BlockBrowserController implements BlockchainExtendQueryService { | |||||
public AccountHeader[] getUsers(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, | public AccountHeader[] getUsers(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, | ||||
@RequestParam(name = "fromIndex", required = false, defaultValue = "0") int fromIndex, | @RequestParam(name = "fromIndex", required = false, defaultValue = "0") int fromIndex, | ||||
@RequestParam(name = "count", required = false, defaultValue = "-1") int count) { | @RequestParam(name = "count", required = false, defaultValue = "-1") int count) { | ||||
return peerService.getQueryService().getUsers(ledgerHash, fromIndex, count); | |||||
return revertAccountHeader(peerService.getQueryService().getUsers(ledgerHash, fromIndex, count)); | |||||
} | } | ||||
@RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/accounts") | @RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/accounts") | ||||
@@ -605,7 +605,7 @@ public class BlockBrowserController implements BlockchainExtendQueryService { | |||||
public AccountHeader[] getDataAccounts(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, | public AccountHeader[] getDataAccounts(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, | ||||
@RequestParam(name = "fromIndex", required = false, defaultValue = "0") int fromIndex, | @RequestParam(name = "fromIndex", required = false, defaultValue = "0") int fromIndex, | ||||
@RequestParam(name = "count", required = false, defaultValue = "-1") int count) { | @RequestParam(name = "count", required = false, defaultValue = "-1") int count) { | ||||
return peerService.getQueryService().getDataAccounts(ledgerHash, fromIndex, count); | |||||
return revertAccountHeader(peerService.getQueryService().getDataAccounts(ledgerHash, fromIndex, count)); | |||||
} | } | ||||
@RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/contracts") | @RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/contracts") | ||||
@@ -613,6 +613,20 @@ public class BlockBrowserController implements BlockchainExtendQueryService { | |||||
public AccountHeader[] getContractAccounts(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, | public AccountHeader[] getContractAccounts(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, | ||||
@RequestParam(name = "fromIndex", required = false, defaultValue = "0") int fromIndex, | @RequestParam(name = "fromIndex", required = false, defaultValue = "0") int fromIndex, | ||||
@RequestParam(name = "count", required = false, defaultValue = "-1") int count) { | @RequestParam(name = "count", required = false, defaultValue = "-1") int count) { | ||||
return peerService.getQueryService().getContractAccounts(ledgerHash, fromIndex, count); | |||||
return revertAccountHeader(peerService.getQueryService().getContractAccounts(ledgerHash, fromIndex, count)); | |||||
} | |||||
/** | |||||
* reverse the AccountHeader[] content; the latest record show first; | |||||
* @return | |||||
*/ | |||||
private AccountHeader[] revertAccountHeader(AccountHeader[] accountHeaders){ | |||||
AccountHeader[] accounts = new AccountHeader[accountHeaders.length]; | |||||
if(accountHeaders!=null && accountHeaders.length>0){ | |||||
for (int i = 0; i < accountHeaders.length; i++) { | |||||
accounts[accountHeaders.length-1-i] = accountHeaders[i]; | |||||
} | |||||
} | |||||
return accounts; | |||||
} | } | ||||
} | } |
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>ledger</artifactId> | <artifactId>ledger</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>ledger-core</artifactId> | <artifactId>ledger-core</artifactId> | ||||
@@ -392,7 +392,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||||
checkLedgerHash(ledgerHash); | checkLedgerHash(ledgerHash); | ||||
LedgerBlock block = ledger.getLatestBlock(); | LedgerBlock block = ledger.getLatestBlock(); | ||||
UserAccountQuery userAccountSet = ledger.getUserAccountSet(block); | UserAccountQuery userAccountSet = ledger.getUserAccountSet(block); | ||||
int pages[] = QueryUtil.calFromIndexAndCount(fromIndex, count, (int) userAccountSet.getTotal()); | |||||
int pages[] = QueryUtil.calFromIndexAndCountDescend(fromIndex, count, (int) userAccountSet.getTotal()); | |||||
return userAccountSet.getHeaders(pages[0], pages[1]); | return userAccountSet.getHeaders(pages[0], pages[1]); | ||||
} | } | ||||
@@ -401,7 +401,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||||
checkLedgerHash(ledgerHash); | checkLedgerHash(ledgerHash); | ||||
LedgerBlock block = ledger.getLatestBlock(); | LedgerBlock block = ledger.getLatestBlock(); | ||||
DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | ||||
int pages[] = QueryUtil.calFromIndexAndCount(fromIndex, count, (int) dataAccountSet.getTotal()); | |||||
int pages[] = QueryUtil.calFromIndexAndCountDescend(fromIndex, count, (int) dataAccountSet.getTotal()); | |||||
return dataAccountSet.getHeaders(pages[0], pages[1]); | return dataAccountSet.getHeaders(pages[0], pages[1]); | ||||
} | } | ||||
@@ -410,7 +410,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||||
checkLedgerHash(ledgerHash); | checkLedgerHash(ledgerHash); | ||||
LedgerBlock block = ledger.getLatestBlock(); | LedgerBlock block = ledger.getLatestBlock(); | ||||
ContractAccountQuery contractAccountSet = ledger.getContractAccountSet(block); | ContractAccountQuery contractAccountSet = ledger.getContractAccountSet(block); | ||||
int pages[] = QueryUtil.calFromIndexAndCount(fromIndex, count, (int) contractAccountSet.getTotal()); | |||||
int pages[] = QueryUtil.calFromIndexAndCountDescend(fromIndex, count, (int) contractAccountSet.getTotal()); | |||||
return contractAccountSet.getHeaders(pages[0], pages[1]); | return contractAccountSet.getHeaders(pages[0], pages[1]); | ||||
} | } | ||||
@@ -5,29 +5,11 @@ import java.util.Collection; | |||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import java.util.List; | import java.util.List; | ||||
import com.jd.blockchain.ledger.*; | |||||
import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
import com.jd.blockchain.crypto.HashDigest; | import com.jd.blockchain.crypto.HashDigest; | ||||
import com.jd.blockchain.ledger.BlockRollbackException; | |||||
import com.jd.blockchain.ledger.BytesValue; | |||||
import com.jd.blockchain.ledger.ContractDoesNotExistException; | |||||
import com.jd.blockchain.ledger.DataAccountDoesNotExistException; | |||||
import com.jd.blockchain.ledger.IllegalTransactionException; | |||||
import com.jd.blockchain.ledger.LedgerBlock; | |||||
import com.jd.blockchain.ledger.LedgerException; | |||||
import com.jd.blockchain.ledger.LedgerPermission; | |||||
import com.jd.blockchain.ledger.LedgerSecurityException; | |||||
import com.jd.blockchain.ledger.Operation; | |||||
import com.jd.blockchain.ledger.OperationResult; | |||||
import com.jd.blockchain.ledger.OperationResultData; | |||||
import com.jd.blockchain.ledger.ParticipantDoesNotExistException; | |||||
import com.jd.blockchain.ledger.TransactionContent; | |||||
import com.jd.blockchain.ledger.TransactionRequest; | |||||
import com.jd.blockchain.ledger.TransactionResponse; | |||||
import com.jd.blockchain.ledger.TransactionRollbackException; | |||||
import com.jd.blockchain.ledger.TransactionState; | |||||
import com.jd.blockchain.ledger.UserDoesNotExistException; | |||||
import com.jd.blockchain.ledger.core.TransactionRequestExtension.Credential; | import com.jd.blockchain.ledger.core.TransactionRequestExtension.Credential; | ||||
import com.jd.blockchain.service.TransactionBatchProcess; | import com.jd.blockchain.service.TransactionBatchProcess; | ||||
import com.jd.blockchain.service.TransactionBatchResult; | import com.jd.blockchain.service.TransactionBatchResult; | ||||
@@ -63,7 +45,7 @@ public class TransactionBatchProcessor implements TransactionBatchProcess { | |||||
/** | /** | ||||
* @param newBlockEditor 新区块的数据编辑器; | * @param newBlockEditor 新区块的数据编辑器; | ||||
* @param ledgerQueryer 账本查询器,只包含新区块的前一个区块的数据集;即未提交新区块之前的经过共识的账本最新数据集; | |||||
* @param newBlockEditor 账本查询器,只包含新区块的前一个区块的数据集;即未提交新区块之前的经过共识的账本最新数据集; | |||||
* @param opHandles 操作处理对象注册表; | * @param opHandles 操作处理对象注册表; | ||||
*/ | */ | ||||
public TransactionBatchProcessor(LedgerSecurityManager securityManager, LedgerEditor newBlockEditor, | public TransactionBatchProcessor(LedgerSecurityManager securityManager, LedgerEditor newBlockEditor, | ||||
@@ -153,6 +135,7 @@ public class TransactionBatchProcessor implements TransactionBatchProcess { | |||||
} catch (BlockRollbackException e) { | } catch (BlockRollbackException e) { | ||||
// 发生区块级别的处理异常,向上重新抛出异常进行处理,整个区块可能被丢弃; | // 发生区块级别的处理异常,向上重新抛出异常进行处理,整个区块可能被丢弃; | ||||
resp = discard(request, e.getState()); | |||||
LOGGER.error(String.format( | LOGGER.error(String.format( | ||||
"Ignore transaction caused by BlockRollbackException! --[BlockHeight=%s][RequestHash=%s][TxHash=%s] --%s", | "Ignore transaction caused by BlockRollbackException! --[BlockHeight=%s][RequestHash=%s][TxHash=%s] --%s", | ||||
newBlockEditor.getBlockHeight(), request.getHash(), request.getTransactionContent().getHash(), | newBlockEditor.getBlockHeight(), request.getHash(), request.getTransactionContent().getHash(), | ||||
@@ -287,8 +270,12 @@ public class TransactionBatchProcessor implements TransactionBatchProcess { | |||||
newBlockEditor.getBlockHeight(), request.getHash(), request.getTransactionContent().getHash(), | newBlockEditor.getBlockHeight(), request.getHash(), request.getTransactionContent().getHash(), | ||||
e.getMessage()), e); | e.getMessage()), e); | ||||
} catch (BlockRollbackException e) { | } catch (BlockRollbackException e) { | ||||
// 回滚整个区块; | |||||
// rollback all the block; | |||||
// TODO: handle the BlockRollbackException in detail; | |||||
result = TransactionState.IGNORED_BY_BLOCK_FULL_ROLLBACK; | result = TransactionState.IGNORED_BY_BLOCK_FULL_ROLLBACK; | ||||
if (e instanceof DataVersionConflictException) { | |||||
result = TransactionState.DATA_VERSION_CONFLICT; | |||||
} | |||||
txCtx.rollback(); | txCtx.rollback(); | ||||
LOGGER.error( | LOGGER.error( | ||||
String.format("Transaction was rolled back! --[BlockHeight=%s][RequestHash=%s][TxHash=%s] --%s", | String.format("Transaction was rolled back! --[BlockHeight=%s][RequestHash=%s][TxHash=%s] --%s", | ||||
@@ -6,7 +6,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>ledger</artifactId> | <artifactId>ledger</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>ledger-model</artifactId> | <artifactId>ledger-model</artifactId> | ||||
@@ -110,36 +110,46 @@ public class ContractJarUtils { | |||||
return dotClassName; | return dotClassName; | ||||
} | } | ||||
public static void verify(byte[] chainCode) { | |||||
public static void verify(String contractPath, byte[] chainCode) { | |||||
if (chainCode == null || chainCode.length == 0) { | if (chainCode == null || chainCode.length == 0) { | ||||
throw new IllegalStateException("Contract's chaincode is empty !!!"); | throw new IllegalStateException("Contract's chaincode is empty !!!"); | ||||
} | } | ||||
// 首先生成合约文件 | // 首先生成合约文件 | ||||
File jarFile = newJarFile(); | |||||
File jarFile = newJarTempFile(); | |||||
try { | try { | ||||
FileUtils.writeByteArrayToFile(jarFile, chainCode); | FileUtils.writeByteArrayToFile(jarFile, chainCode); | ||||
// 校验合约文件 | // 校验合约文件 | ||||
verify(jarFile); | |||||
verify(contractPath, jarFile); | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
throw new IllegalStateException(e); | throw new IllegalStateException(e); | ||||
} finally { | } finally { | ||||
// 删除文件 | // 删除文件 | ||||
try { | try { | ||||
FileUtils.forceDelete(jarFile); | |||||
jarFile.deleteOnExit(); | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
throw new IllegalStateException(e); | |||||
// DO NOTHING | |||||
} | } | ||||
} | } | ||||
} | } | ||||
private static void verify(File jarFile) throws Exception { | |||||
public static void verify(byte[] chainCode) { | |||||
verify(null, chainCode); | |||||
} | |||||
private static void verify(String contractPath, File jarFile) throws Exception { | |||||
// 首先判断jarFile中是否含有META-INF/JDCHAIN.TXT,并将其读出 | // 首先判断jarFile中是否含有META-INF/JDCHAIN.TXT,并将其读出 | ||||
URL jarUrl = new URL("jar:file:" + jarFile.getPath() + "!/" + CONTRACT_MF); | URL jarUrl = new URL("jar:file:" + jarFile.getPath() + "!/" + CONTRACT_MF); | ||||
InputStream inputStream = jarUrl.openStream(); | InputStream inputStream = jarUrl.openStream(); | ||||
if (inputStream == null) { | if (inputStream == null) { | ||||
throw new IllegalStateException(CONTRACT_MF + " IS NULL !!!"); | throw new IllegalStateException(CONTRACT_MF + " IS NULL !!!"); | ||||
} | } | ||||
byte[] bytes = IOUtils.toByteArray(inputStream); | |||||
byte[] bytes; | |||||
try { | |||||
bytes = IOUtils.toByteArray(inputStream); | |||||
} finally { | |||||
inputStream.close(); | |||||
} | |||||
if (bytes == null || bytes.length == 0) { | if (bytes == null || bytes.length == 0) { | ||||
throw new IllegalStateException(CONTRACT_MF + " IS Illegal !!!"); | throw new IllegalStateException(CONTRACT_MF + " IS Illegal !!!"); | ||||
} | } | ||||
@@ -147,20 +157,25 @@ public class ContractJarUtils { | |||||
String txt = new String(bytes, StandardCharsets.UTF_8); | String txt = new String(bytes, StandardCharsets.UTF_8); | ||||
// 生成新的Jar包文件,该文件路径与JarFile基本一致 | // 生成新的Jar包文件,该文件路径与JarFile基本一致 | ||||
File tempJar = newJarFile(); | |||||
// 复制除JDCHAIN.TXT之外的部分 | |||||
copy(jarFile, tempJar, null, null, CONTRACT_MF); | |||||
// 生成新Jar包对应的Hash内容 | |||||
String verifyTxt = contractMF(FileUtils.readFileToByteArray(tempJar)); | |||||
File tempJar = newJarTempFile(); | |||||
try { | |||||
// 复制除JDCHAIN.TXT之外的部分 | |||||
copy(jarFile, tempJar, null, null, CONTRACT_MF); | |||||
// 删除临时文件 | |||||
FileUtils.forceDelete(tempJar); | |||||
// 生成新Jar包对应的Hash内容 | |||||
String verifyTxt = contractMF(FileUtils.readFileToByteArray(tempJar)); | |||||
// 校验Jar包内容 | |||||
if (!txt.equals(verifyTxt)) { | |||||
throw new IllegalStateException(String.format("Jar [%s] verify Illegal !!!", jarFile.getName())); | |||||
// 校验Jar包内容 | |||||
if (!txt.equals(verifyTxt)) { | |||||
throw new IllegalStateException(String.format("Jar [%s] verify Illegal !!!", jarFile.getName())); | |||||
} | |||||
} finally { | |||||
try { | |||||
// 删除临时文件 | |||||
tempJar.deleteOnExit(); | |||||
} catch (Exception e) { | |||||
// DO NOTHING | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -218,11 +233,30 @@ public class ContractJarUtils { | |||||
} | } | ||||
} | } | ||||
private static File newJarFile() { | |||||
return new File("contract-" + | |||||
System.currentTimeMillis() + "-" + | |||||
System.nanoTime() + "-" + | |||||
FILE_RANDOM.nextInt(1024) + | |||||
".jar"); | |||||
private static File newJarTempFile() { | |||||
try { | |||||
return File.createTempFile("contract-" + | |||||
System.currentTimeMillis() + "-" + | |||||
System.nanoTime() + "-" + | |||||
FILE_RANDOM.nextInt(1024), ".jar"); | |||||
} catch (Exception e) { | |||||
throw new IllegalStateException(e); | |||||
} | |||||
// | |||||
// if (contractPath != null && contractPath.length() > 0) { | |||||
// return new File(contractPath + File.separator + | |||||
// "contract-" + | |||||
// System.currentTimeMillis() + "-" + | |||||
// System.nanoTime() + "-" + | |||||
// FILE_RANDOM.nextInt(1024) + | |||||
// ".jar"); | |||||
// } | |||||
// | |||||
// return new File("contract-" + | |||||
// System.currentTimeMillis() + "-" + | |||||
// System.nanoTime() + "-" + | |||||
// FILE_RANDOM.nextInt(1024) + | |||||
// ".jar"); | |||||
} | } | ||||
} | } |
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>ledger</artifactId> | <artifactId>ledger</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>ledger-rpc</artifactId> | <artifactId>ledger-rpc</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>jdchain-root</artifactId> | <artifactId>jdchain-root</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>ledger</artifactId> | <artifactId>ledger</artifactId> | ||||
<packaging>pom</packaging> | <packaging>pom</packaging> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<artifactId>manager</artifactId> | <artifactId>manager</artifactId> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<modelVersion>4.0.0</modelVersion> | <modelVersion>4.0.0</modelVersion> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<artifactId>manager</artifactId> | <artifactId>manager</artifactId> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<modelVersion>4.0.0</modelVersion> | <modelVersion>4.0.0</modelVersion> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<artifactId>manager</artifactId> | <artifactId>manager</artifactId> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<modelVersion>4.0.0</modelVersion> | <modelVersion>4.0.0</modelVersion> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<artifactId>manager</artifactId> | <artifactId>manager</artifactId> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<modelVersion>4.0.0</modelVersion> | <modelVersion>4.0.0</modelVersion> | ||||
@@ -11,8 +11,21 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>jdchain-root</artifactId> | <artifactId>jdchain-root</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>manager</artifactId> | <artifactId>manager</artifactId> | ||||
<packaging>pom</packaging> | <packaging>pom</packaging> | ||||
<build> | |||||
<plugins> | |||||
<plugin> | |||||
<groupId>org.apache.maven.plugins</groupId> | |||||
<artifactId>maven-deploy-plugin</artifactId> | |||||
<version>2.8.2</version> | |||||
<configuration> | |||||
<skip>true</skip> | |||||
</configuration> | |||||
</plugin> | |||||
</plugins> | |||||
</build> | |||||
</project> | </project> |
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>jdchain-root</artifactId> | <artifactId>jdchain-root</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>peer</artifactId> | <artifactId>peer</artifactId> | ||||
@@ -474,7 +474,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||||
LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | ||||
LedgerBlock block = ledger.getLatestBlock(); | LedgerBlock block = ledger.getLatestBlock(); | ||||
UserAccountQuery userAccountSet = ledger.getUserAccountSet(block); | UserAccountQuery userAccountSet = ledger.getUserAccountSet(block); | ||||
int pages[] = QueryUtil.calFromIndexAndCount(fromIndex, count, (int) userAccountSet.getTotal()); | |||||
int pages[] = QueryUtil.calFromIndexAndCountDescend(fromIndex, count, (int) userAccountSet.getTotal()); | |||||
return userAccountSet.getHeaders(pages[0], pages[1]); | return userAccountSet.getHeaders(pages[0], pages[1]); | ||||
} | } | ||||
@@ -494,7 +494,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||||
LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | ||||
LedgerBlock block = ledger.getLatestBlock(); | LedgerBlock block = ledger.getLatestBlock(); | ||||
DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | ||||
int pages[] = QueryUtil.calFromIndexAndCount(fromIndex, count, (int) dataAccountSet.getTotal()); | |||||
int pages[] = QueryUtil.calFromIndexAndCountDescend(fromIndex, count, (int) dataAccountSet.getTotal()); | |||||
return dataAccountSet.getHeaders(pages[0], pages[1]); | return dataAccountSet.getHeaders(pages[0], pages[1]); | ||||
} | } | ||||
@@ -506,7 +506,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||||
LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | ||||
LedgerBlock block = ledger.getLatestBlock(); | LedgerBlock block = ledger.getLatestBlock(); | ||||
ContractAccountQuery contractAccountSet = ledger.getContractAccountSet(block); | ContractAccountQuery contractAccountSet = ledger.getContractAccountSet(block); | ||||
int pages[] = QueryUtil.calFromIndexAndCount(fromIndex, count, (int) contractAccountSet.getTotal()); | |||||
int pages[] = QueryUtil.calFromIndexAndCountDescend(fromIndex, count, (int) contractAccountSet.getTotal()); | |||||
return contractAccountSet.getHeaders(pages[0], pages[1]); | return contractAccountSet.getHeaders(pages[0], pages[1]); | ||||
} | } | ||||
@@ -11,7 +11,7 @@ | |||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>jdchain-root</artifactId> | <artifactId>jdchain-root</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
<packaging>pom</packaging> | <packaging>pom</packaging> | ||||
<description>jdchain</description> | <description>jdchain</description> | ||||
@@ -35,7 +35,7 @@ | |||||
</modules> | </modules> | ||||
<properties> | <properties> | ||||
<bft-smart.version>0.2.0.RELEASE</bft-smart.version> | |||||
<bft-smart.version>0.3.0.RELEASE</bft-smart.version> | |||||
<data-explorer.version>1.1.0.RELEASE</data-explorer.version> | <data-explorer.version>1.1.0.RELEASE</data-explorer.version> | ||||
<manager-explorer.version>1.1.0.RELEASE</manager-explorer.version> | <manager-explorer.version>1.1.0.RELEASE</manager-explorer.version> | ||||
<commons-io.version>2.4</commons-io.version> | <commons-io.version>2.4</commons-io.version> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>jdchain-root</artifactId> | <artifactId>jdchain-root</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>runtime</artifactId> | <artifactId>runtime</artifactId> | ||||
<packaging>pom</packaging> | <packaging>pom</packaging> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>runtime</artifactId> | <artifactId>runtime</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>runtime-context</artifactId> | <artifactId>runtime-context</artifactId> | ||||
@@ -240,7 +240,7 @@ public abstract class RuntimeContext { | |||||
private static void initBlacks() { | private static void initBlacks() { | ||||
try { | try { | ||||
InputStream inputStream = ContractURLClassLoader.class.getResourceAsStream(File.separator + BLACK_CONFIG); | |||||
InputStream inputStream = ContractURLClassLoader.class.getResourceAsStream("/"+ BLACK_CONFIG); | |||||
String text = FileUtils.readText(inputStream); | String text = FileUtils.readText(inputStream); | ||||
String[] textArray = text.split("\n"); | String[] textArray = text.split("\n"); | ||||
for (String setting : textArray) { | for (String setting : textArray) { | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>runtime</artifactId> | <artifactId>runtime</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>runtime-modular-booter</artifactId> | <artifactId>runtime-modular-booter</artifactId> | ||||
</project> | </project> |
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>runtime</artifactId> | <artifactId>runtime</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>runtime-modular</artifactId> | <artifactId>runtime-modular</artifactId> | ||||
@@ -4,7 +4,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>jdchain-root</artifactId> | <artifactId>jdchain-root</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>sdk</artifactId> | <artifactId>sdk</artifactId> | ||||
<packaging>pom</packaging> | <packaging>pom</packaging> | ||||
@@ -4,7 +4,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>sdk</artifactId> | <artifactId>sdk</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>sdk-base</artifactId> | <artifactId>sdk-base</artifactId> | ||||
@@ -4,7 +4,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>sdk</artifactId> | <artifactId>sdk</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>sdk-client</artifactId> | <artifactId>sdk-client</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>sdk</artifactId> | <artifactId>sdk</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>sdk-samples</artifactId> | <artifactId>sdk-samples</artifactId> | ||||
@@ -3,7 +3,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>jdchain-root</artifactId> | <artifactId>jdchain-root</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>storage</artifactId> | <artifactId>storage</artifactId> | ||||
<packaging>pom</packaging> | <packaging>pom</packaging> | ||||
@@ -4,7 +4,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>storage</artifactId> | <artifactId>storage</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>storage-composite</artifactId> | <artifactId>storage-composite</artifactId> | ||||
@@ -4,7 +4,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>storage</artifactId> | <artifactId>storage</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>storage-redis</artifactId> | <artifactId>storage-redis</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>storage</artifactId> | <artifactId>storage</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>storage-rocksdb</artifactId> | <artifactId>storage-rocksdb</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>storage</artifactId> | <artifactId>storage</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>storage-service</artifactId> | <artifactId>storage-service</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>jdchain-root</artifactId> | <artifactId>jdchain-root</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>test</artifactId> | <artifactId>test</artifactId> | ||||
<packaging>pom</packaging> | <packaging>pom</packaging> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>test</artifactId> | <artifactId>test</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>test-consensus-client</artifactId> | <artifactId>test-consensus-client</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>test</artifactId> | <artifactId>test</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>test-consensus-node</artifactId> | <artifactId>test-consensus-node</artifactId> | ||||
<dependencies> | <dependencies> | ||||
@@ -38,7 +38,7 @@ | |||||
<dependency> | <dependency> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>consensus-bftsmart</artifactId> | <artifactId>consensus-bftsmart</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</dependency> | </dependency> | ||||
<dependency> | <dependency> | ||||
<groupId>org.springframework.boot</groupId> | <groupId>org.springframework.boot</groupId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>test</artifactId> | <artifactId>test</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>test-integration</artifactId> | <artifactId>test-integration</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>test</artifactId> | <artifactId>test</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>test-ledger</artifactId> | <artifactId>test-ledger</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>jdchain-root</artifactId> | <artifactId>jdchain-root</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>tools</artifactId> | <artifactId>tools</artifactId> | ||||
<packaging>pom</packaging> | <packaging>pom</packaging> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>tools</artifactId> | <artifactId>tools</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>tools-initializer-booter</artifactId> | <artifactId>tools-initializer-booter</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>tools</artifactId> | <artifactId>tools</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>tools-initializer</artifactId> | <artifactId>tools-initializer</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>tools</artifactId> | <artifactId>tools</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>tools-keygen-booter</artifactId> | <artifactId>tools-keygen-booter</artifactId> | ||||
@@ -5,7 +5,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>tools</artifactId> | <artifactId>tools</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>tools-keygen</artifactId> | <artifactId>tools-keygen</artifactId> | ||||
@@ -4,7 +4,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>jdchain-root</artifactId> | <artifactId>jdchain-root</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>utils</artifactId> | <artifactId>utils</artifactId> | ||||
<packaging>pom</packaging> | <packaging>pom</packaging> | ||||
@@ -4,7 +4,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>utils</artifactId> | <artifactId>utils</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>utils-common</artifactId> | <artifactId>utils-common</artifactId> | ||||
@@ -47,4 +47,21 @@ public class QueryUtil { | |||||
rtn[1] = count; | rtn[1] = count; | ||||
return rtn; | return rtn; | ||||
} | } | ||||
/** | |||||
* cal the data by descend; | |||||
* @param fromIndex | |||||
* @param count | |||||
* @param maxNum | |||||
* @return | |||||
*/ | |||||
public static int[] calFromIndexAndCountDescend(int fromIndex, int count, int maxNum){ | |||||
int rtn[] = new int[2]; | |||||
int results[] = calFromIndexAndCount(fromIndex,count,maxNum); | |||||
//now use descend; first show the latest record; | |||||
rtn[0] = maxNum - results[0] - results[1]; | |||||
rtn[1] = results[1]; | |||||
return rtn; | |||||
} | |||||
} | } |
@@ -4,7 +4,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>utils</artifactId> | <artifactId>utils</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<properties> | <properties> | ||||
@@ -4,7 +4,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>utils</artifactId> | <artifactId>utils</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>utils-serialize</artifactId> | <artifactId>utils-serialize</artifactId> | ||||
@@ -4,7 +4,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>utils</artifactId> | <artifactId>utils</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>utils-test</artifactId> | <artifactId>utils-test</artifactId> | ||||
@@ -4,7 +4,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>utils</artifactId> | <artifactId>utils</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>utils-web-server</artifactId> | <artifactId>utils-web-server</artifactId> | ||||
@@ -4,7 +4,7 @@ | |||||
<parent> | <parent> | ||||
<groupId>com.jd.blockchain</groupId> | <groupId>com.jd.blockchain</groupId> | ||||
<artifactId>utils</artifactId> | <artifactId>utils</artifactId> | ||||
<version>1.1.0.RELEASE</version> | |||||
<version>1.1.1.RELEASE</version> | |||||
</parent> | </parent> | ||||
<artifactId>utils-web</artifactId> | <artifactId>utils-web</artifactId> | ||||
<dependencies> | <dependencies> | ||||