@@ -103,7 +103,7 @@ public class TransactionBatchProcessor implements TransactionBatchProcess { | |||
return resp; | |||
} | |||
LOGGER.debug("Start handling transaction... --[BlockHeight=%s][RequestHash=%s][TxHash=%s]", | |||
LOGGER.debug("Start handling transaction... --[BlockHeight={}][RequestHash={}][TxHash={}]", | |||
newBlockEditor.getBlockHeight(), request.getHash(), request.getTransactionContent().getHash()); | |||
// 创建交易上下文; | |||
// 此调用将会验证交易签名,验签失败将会抛出异常,同时,不记录签名错误的交易到链上; | |||
@@ -112,7 +112,7 @@ public class TransactionBatchProcessor implements TransactionBatchProcess { | |||
// 处理交易; | |||
resp = handleTx(request, txCtx); | |||
LOGGER.debug("Complete handling transaction. --[BlockHeight=%s][RequestHash=%s][TxHash=%s]", | |||
LOGGER.debug("Complete handling transaction. --[BlockHeight={}][RequestHash={}][TxHash={}]", | |||
newBlockEditor.getBlockHeight(), request.getHash(), request.getTransactionContent().getHash()); | |||
responseList.add(resp); | |||
@@ -246,7 +246,7 @@ public class TransactionBatchProcessor implements TransactionBatchProcess { | |||
TxResponseMessage resp = new TxResponseMessage(request.getTransactionContent().getHash()); | |||
resp.setExecutionState(txState); | |||
LOGGER.error("Discard transaction request! --[BlockHeight=%s][RequestHash=%s][TxHash=%s][ResponseState=%s]", | |||
LOGGER.error("Discard transaction request! --[BlockHeight={}][RequestHash={}][TxHash={}][ResponseState={}]", | |||
newBlockEditor.getBlockHeight(), request.getHash(), request.getTransactionContent().getHash(), | |||
resp.getExecutionState()); | |||
return resp; | |||
@@ -84,14 +84,14 @@ public class LedgerTestUtils { | |||
// public static TransactionRequest createTxRequest_UserReg(BlockchainKeypair userKeypair, HashDigest ledgerHash, BlockchainKeypair... partiKeys) { | |||
// return createTxRequest_UserReg(userKeypair, ledgerHash, null, null); | |||
// } | |||
public static TransactionRequest createLedgerInitTxRequest(BlockchainKeypair... participants) { | |||
TxBuilder txBuilder = new TxBuilder(null); | |||
for (BlockchainKeypair parti : participants) { | |||
txBuilder.users().register(parti.getIdentity()); | |||
} | |||
TransactionRequestBuilder txReqBuilder = txBuilder.prepareRequest(); | |||
for (BlockchainKeypair parti : participants) { | |||
txReqBuilder.signAsNode(parti); | |||
@@ -100,11 +100,11 @@ public class LedgerTestUtils { | |||
return txReqBuilder.buildRequest(); | |||
} | |||
public static TransactionRequest createTxRequest_UserReg(HashDigest ledgerHash, | |||
BlockchainKeypair nodeKeypair, BlockchainKeypair... signers) { | |||
return createTxRequest_UserReg(BlockchainKeyGenerator.getInstance().generate(), ledgerHash, nodeKeypair, | |||
signers); | |||
} | |||
// public static TransactionRequest createTxRequest_UserReg(HashDigest ledgerHash, BlockchainKeypair nodeKeypair, | |||
// BlockchainKeypair... signers) { | |||
// return createTxRequest_UserReg(BlockchainKeyGenerator.getInstance().generate(), ledgerHash, nodeKeypair, | |||
// signers); | |||
// } | |||
public static TransactionRequest createTxRequest_UserReg(BlockchainKeypair userKeypair, HashDigest ledgerHash, | |||
BlockchainKeypair nodeKeypair, BlockchainKeypair... signers) { | |||
@@ -113,7 +113,11 @@ public class LedgerTestUtils { | |||
txBuilder.users().register(userKeypair.getIdentity()); | |||
TransactionRequestBuilder txReqBuilder = txBuilder.prepareRequest(); | |||
txReqBuilder.signAsEndpoint(nodeKeypair); | |||
if (signers != null) { | |||
for (BlockchainKeypair signer : signers) { | |||
txReqBuilder.signAsEndpoint(signer); | |||
} | |||
} | |||
if (nodeKeypair != null) { | |||
txReqBuilder.signAsNode(nodeKeypair); | |||
} | |||
@@ -121,8 +125,8 @@ public class LedgerTestUtils { | |||
return txReqBuilder.buildRequest(); | |||
} | |||
public static TransactionRequest createTxRequest_MultiOPs_WithError(HashDigest ledgerHash, | |||
BlockchainKeypair userKeypair, BlockchainKeypair nodeKeypair) { | |||
public static TransactionRequest createTxRequest_MultiOPs_WithError(BlockchainKeypair userKeypair, HashDigest ledgerHash, | |||
BlockchainKeypair nodeKeypair, BlockchainKeypair... signers) { | |||
TxBuilder txBuilder = new TxBuilder(ledgerHash); | |||
txBuilder.users().register(userKeypair.getIdentity()); | |||
@@ -88,7 +88,7 @@ public class TransactionBatchProcessorTest { | |||
// 注册新用户; | |||
BlockchainKeypair userKeypair = BlockchainKeyGenerator.getInstance().generate(); | |||
transactionRequest = LedgerTestUtils.createTxRequest_UserReg(ledgerHash, userKeypair, parti0); | |||
transactionRequest = LedgerTestUtils.createTxRequest_UserReg(userKeypair, ledgerHash, parti0, parti0); | |||
TransactionResponse txResp = txbatchProcessor.schedule(transactionRequest); | |||
LedgerBlock newBlock = newBlockEditor.prepare(); | |||
@@ -132,7 +132,7 @@ public class TransactionBatchProcessorTest { | |||
// 注册新用户; | |||
BlockchainKeypair userKeypair1 = BlockchainKeyGenerator.getInstance().generate(); | |||
transactionRequest = LedgerTestUtils.createTxRequest_UserReg(ledgerHash, userKeypair1, parti0); | |||
transactionRequest = LedgerTestUtils.createTxRequest_UserReg(userKeypair1, ledgerHash, parti0, parti0); | |||
TransactionResponse txResp1 = txbatchProcessor.schedule(transactionRequest); | |||
// BlockchainKeypair userKeypair2 = BlockchainKeyGenerator.getInstance().generate(); | |||
@@ -187,15 +187,15 @@ public class TransactionBatchProcessorTest { | |||
// 注册新用户; | |||
BlockchainKeypair userKeypair1 = BlockchainKeyGenerator.getInstance().generate(); | |||
transactionRequest = LedgerTestUtils.createTxRequest_UserReg(ledgerHash, userKeypair1, parti0); | |||
transactionRequest = LedgerTestUtils.createTxRequest_UserReg(userKeypair1, ledgerHash, parti0, parti0); | |||
TransactionResponse txResp1 = txbatchProcessor.schedule(transactionRequest); | |||
BlockchainKeypair userKeypair2 = BlockchainKeyGenerator.getInstance().generate(); | |||
transactionRequest = LedgerTestUtils.createTxRequest_MultiOPs_WithError(ledgerHash, userKeypair2, parti0); | |||
transactionRequest = LedgerTestUtils.createTxRequest_MultiOPs_WithError(userKeypair2, ledgerHash, parti0, parti0); | |||
TransactionResponse txResp2 = txbatchProcessor.schedule(transactionRequest); | |||
BlockchainKeypair userKeypair3 = BlockchainKeyGenerator.getInstance().generate(); | |||
transactionRequest = LedgerTestUtils.createTxRequest_UserReg(ledgerHash, userKeypair3, parti0); | |||
transactionRequest = LedgerTestUtils.createTxRequest_UserReg(userKeypair3, ledgerHash, parti0, parti0); | |||
TransactionResponse txResp3 = txbatchProcessor.schedule(transactionRequest); | |||
LedgerBlock newBlock = newBlockEditor.prepare(); | |||