Browse Source

Merge commit '173e4ba768cf66291320aabcf07d5f2fee9cce7a' into feature/crypto-spi

# Conflicts:
#	source/pom.xml
tags/1.0.0
zhanglin33 5 years ago
parent
commit
d44f97a646
96 changed files with 1422 additions and 1165 deletions
  1. +1
    -3
      source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/client/BftsmartConsensusClient.java
  2. +10
    -10
      source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/client/BftsmartMessageService.java
  3. +8
    -1
      source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartConsensusManageService.java
  4. +3
    -373
      source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartNodeServer.java
  5. +26
    -15
      source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/utils/classic/RSAUtils.java
  6. +5
    -5
      source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/service/classic/AESEncryptionFunctionTest.java
  7. +7
    -7
      source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/service/classic/ECDSASignatureFunctionTest.java
  8. +7
    -7
      source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/service/classic/ED25519SignatureFunctionTest.java
  9. +4
    -4
      source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/service/classic/RIPEMD160HashFunctionTest.java
  10. +9
    -9
      source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/service/classic/RSACryptoFunctionTest.java
  11. +4
    -4
      source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/service/classic/SHA256HashFunctionTest.java
  12. +1
    -1
      source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/utils/classic/ECDSAUtilsTest.java
  13. +1
    -1
      source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/utils/classic/ED25519UtilsTest.java
  14. +3
    -3
      source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/utils/classic/RSAUtilsTest.java
  15. +3
    -3
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/BaseCryptoKey.java
  16. +8
    -8
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/CryptoAlgorithm.java
  17. +1
    -1
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/CryptoBytesEncoding.java
  18. +1
    -0
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/PrivKey.java
  19. +5
    -1
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/PubKey.java
  20. +0
    -78
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/serialize/ByteArrayObjectDeserializer.java
  21. +0
    -63
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/serialize/ByteArrayObjectSerializer.java
  22. +9
    -9
      source/crypto/crypto-sm/src/test/java/test/com/jd/blockchain/crypto/service/sm/SM2CyptoFunctionTest.java
  23. +3
    -3
      source/crypto/crypto-sm/src/test/java/test/com/jd/blockchain/crypto/service/sm/SM3HashFunctionTest.java
  24. +5
    -5
      source/crypto/crypto-sm/src/test/java/test/com/jd/blockchain/crypto/service/sm/SM4EncryptionFunctionTest.java
  25. +43
    -43
      source/crypto/crypto-sm/src/test/java/test/com/jd/blockchain/crypto/utils/SM2UtilsTest.java
  26. +22
    -0
      source/deployment/deployment-peer/pom.xml
  27. +0
    -9
      source/deployment/deployment-peer/src/main/resources/assembly.xml
  28. +23
    -1
      source/gateway/pom.xml
  29. +10
    -0
      source/gateway/src/main/java/com/jd/blockchain/gateway/service/GatewayQueryService.java
  30. +144
    -0
      source/gateway/src/main/java/com/jd/blockchain/gateway/service/GatewayQueryServiceHandler.java
  31. +37
    -37
      source/gateway/src/main/java/com/jd/blockchain/gateway/service/GatewayQueryServiceImpl.java
  32. +12
    -0
      source/gateway/src/main/java/com/jd/blockchain/gateway/web/BlockBrowserController.java
  33. +5
    -22
      source/gateway/src/main/java/com/jd/blockchain/gateway/web/GatewayWebServerConfigurer.java
  34. +10
    -8
      source/gateway/src/main/resources/gateway.conf
  35. +2
    -0
      source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/LedgerAdminAccount.java
  36. +1
    -0
      source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/LedgerAdministration.java
  37. +1
    -0
      source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/LedgerConfiguration.java
  38. +36
    -36
      source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/LedgerMetadata.java
  39. +24
    -24
      source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/LedgerSetting.java
  40. +14
    -14
      source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/impl/LedgerQueryService.java
  41. +2
    -8
      source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/impl/LedgerRepositoryImpl.java
  42. +2
    -10
      source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/impl/LedgerTransactionalEditor.java
  43. +6
    -16
      source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/impl/handles/ContractLedgerContext.java
  44. +1
    -1
      source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerAdminAccountTest.java
  45. +2
    -2
      source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerMetaDataTest.java
  46. +12
    -0
      source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/CryptoProviderInfo.java
  47. +36
    -0
      source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/LedgerMetadata.java
  48. +24
    -0
      source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/LedgerSetting.java
  49. +8
    -0
      source/ledger/ledger-model/src/main/java/com/jd/blockchain/transaction/BlockchainQueryService.java
  50. +1
    -1
      source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/ED25519SignatureTest.java
  51. +101
    -0
      source/ledger/ledger-rpc/src/main/java/com/jd/blockchain/web/serializes/ByteArrayObjectJsonDeserializer.java
  52. +120
    -0
      source/ledger/ledger-rpc/src/main/java/com/jd/blockchain/web/serializes/ByteArrayObjectJsonSerializer.java
  53. +41
    -0
      source/ledger/ledger-rpc/src/main/java/com/jd/blockchain/web/serializes/ByteArrayObjectUtil.java
  54. +11
    -19
      source/peer/src/main/java/com/jd/blockchain/peer/web/LedgerQueryController.java
  55. +2
    -19
      source/peer/src/main/java/com/jd/blockchain/peer/web/PeerWebServerConfigurer.java
  56. +13
    -8
      source/pom.xml
  57. +113
    -0
      source/sdk/sdk-base/src/main/java/com/jd/blockchain/sdk/LedgerInitSettings.java
  58. +6
    -1
      source/sdk/sdk-base/src/main/java/com/jd/blockchain/sdk/proxy/BlockchainServiceProxy.java
  59. +11
    -0
      source/sdk/sdk-base/src/main/java/com/jd/blockchain/sdk/proxy/HttpBlockchainQueryService.java
  60. +1
    -1
      source/sdk/sdk-base/src/main/java/com/jd/blockchain/sdk/service/NodeSigningAppender.java
  61. +6
    -0
      source/sdk/sdk-client/pom.xml
  62. +32
    -5
      source/sdk/sdk-client/src/main/java/com/jd/blockchain/sdk/client/GatewayServiceFactory.java
  63. +0
    -13
      source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_Query_Test_.java
  64. +30
    -1
      source/storage/storage-composite/pom.xml
  65. +88
    -64
      source/storage/storage-composite/src/main/java/com/jd/blockchain/storage/service/impl/composite/CompositeConnectionFactory.java
  66. +1
    -0
      source/storage/storage-composite/src/main/java/com/jd/blockchain/storage/service/impl/composite/CompositeStorageConfiguration.java
  67. +110
    -112
      source/storage/storage-composite/src/test/java/test/com/jd/blockchain/storage/service/impl/composite/CompositeConnectionFactoryTest.java
  68. +28
    -2
      source/storage/storage-redis/src/main/java/com/jd/blockchain/storage/service/impl/redis/RedisConnectionFactory.java
  69. +6
    -1
      source/storage/storage-rocksdb/src/main/java/com/jd/blockchain/storage/service/impl/rocksdb/RocksDBConnectionFactory.java
  70. +7
    -1
      source/storage/storage-service/src/main/java/com/jd/blockchain/storage/service/DbConnectionFactory.java
  71. +5
    -0
      source/storage/storage-service/src/main/java/com/jd/blockchain/storage/service/utils/MemoryDBConnFactory.java
  72. +1
    -1
      source/test/test-integration/src/main/resources/ledger_init_test_integration.init
  73. +0
    -1
      source/test/test-integration/src/main/resources/ledger_init_test_web2.init
  74. +8
    -8
      source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBase.java
  75. +3
    -3
      source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest4Bftsmart.java
  76. +8
    -8
      source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTestAll4Redis.java
  77. +18
    -2
      source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/initializer/LedgerInitSettingTest.java
  78. +2
    -1
      source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/initializer/LedgerInitWebTestConfiguration.java
  79. +5
    -5
      source/test/test-integration/src/test/resources/bftsmart.config
  80. +2
    -2
      source/test/test-integration/src/test/resources/ledger-binding-mem-0.conf
  81. +2
    -2
      source/test/test-integration/src/test/resources/ledger-binding-mem-1.conf
  82. +2
    -2
      source/test/test-integration/src/test/resources/ledger-binding-mem-2.conf
  83. +2
    -2
      source/test/test-integration/src/test/resources/ledger-binding-mem-3.conf
  84. +2
    -2
      source/test/test-integration/src/test/resources/ledger-binding-redis-0.conf
  85. +2
    -2
      source/test/test-integration/src/test/resources/ledger-binding-redis-1.conf
  86. +2
    -2
      source/test/test-integration/src/test/resources/ledger-binding-redis-2.conf
  87. +2
    -2
      source/test/test-integration/src/test/resources/ledger-binding-redis-3.conf
  88. +2
    -2
      source/test/test-integration/src/test/resources/ledger-binding-rocksdb-0.conf
  89. +2
    -2
      source/test/test-integration/src/test/resources/ledger-binding-rocksdb-1.conf
  90. +2
    -2
      source/test/test-integration/src/test/resources/ledger-binding-rocksdb-2.conf
  91. +2
    -2
      source/test/test-integration/src/test/resources/ledger-binding-rocksdb-3.conf
  92. +3
    -3
      source/test/test-integration/src/test/resources/ledger.init
  93. +4
    -4
      source/test/test-integration/src/test/resources/ledger_init_test.init
  94. +4
    -4
      source/test/test-integration/src/test/resources/ledger_init_test_integration.init
  95. +4
    -4
      source/test/test-integration/src/test/resources/ledger_init_test_web1.init
  96. +4
    -4
      source/test/test-integration/src/test/resources/ledger_init_test_web2.init

+ 1
- 3
source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/client/BftsmartConsensusClient.java View File

@@ -20,8 +20,6 @@ public class BftsmartConsensusClient implements ConsensusClient {


this.clientSettings = clientSettings; this.clientSettings = clientSettings;
this.gatewayId = clientSettings.getClientId(); this.gatewayId = clientSettings.getClientId();

connect();
} }




@@ -45,7 +43,7 @@ public class BftsmartConsensusClient implements ConsensusClient {
} }


@Override @Override
public void connect() {
public synchronized void connect() {


//consensus client pool //consensus client pool
BftsmartPeerProxyFactory peerProxyFactory = new BftsmartPeerProxyFactory((BftsmartClientSettings)clientSettings, gatewayId); BftsmartPeerProxyFactory peerProxyFactory = new BftsmartPeerProxyFactory((BftsmartClientSettings)clientSettings, gatewayId);


+ 10
- 10
source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/client/BftsmartMessageService.java View File

@@ -27,16 +27,16 @@ public class BftsmartMessageService implements MessageService {
AsynchServiceProxy asynchServiceProxy = null; AsynchServiceProxy asynchServiceProxy = null;
try { try {
asynchServiceProxy = asyncPeerProxyPool.borrowObject(); asynchServiceProxy = asyncPeerProxyPool.borrowObject();
//0: Transaction msg, 1: Commitblock msg
byte[] msgType = BytesUtils.toBytes(0);
byte[] wrapMsg = new byte[message.length + 4];
System.arraycopy(message, 0, wrapMsg, 4, message.length);
System.arraycopy(msgType, 0, wrapMsg, 0, 4);
System.out.printf("BftsmartMessageService invokeOrdered time = %s, id = %s threadId = %s \r\n",
System.currentTimeMillis(), asynchServiceProxy.getProcessId(), Thread.currentThread().getId());
byte[] result = asynchServiceProxy.invokeOrdered(wrapMsg);
// //0: Transaction msg, 1: Commitblock msg
// byte[] msgType = BytesUtils.toBytes(0);
// byte[] wrapMsg = new byte[message.length + 4];
// System.arraycopy(message, 0, wrapMsg, 4, message.length);
// System.arraycopy(msgType, 0, wrapMsg, 0, 4);
//
// System.out.printf("BftsmartMessageService invokeOrdered time = %s, id = %s threadId = %s \r\n",
// System.currentTimeMillis(), asynchServiceProxy.getProcessId(), Thread.currentThread().getId());
byte[] result = asynchServiceProxy.invokeOrdered(message);
asyncFuture.complete(result); asyncFuture.complete(result);


} catch (Exception e) { } catch (Exception e) {


+ 8
- 1
source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartConsensusManageService.java View File

@@ -13,10 +13,16 @@ import com.jd.blockchain.utils.serialize.binary.BinarySerializeUtils;


public class BftsmartConsensusManageService implements ConsensusManageService { public class BftsmartConsensusManageService implements ConsensusManageService {


public static final int CLIENT_RANGE = 100 * 1000;
public static final int GATEWAY_SIZE = 100;

public static final int CLIENT_SIZE_PER_GATEWAY = 1000;

public static final int CLIENT_RANGE = GATEWAY_SIZE * CLIENT_SIZE_PER_GATEWAY;


private BftsmartNodeServer nodeServer; private BftsmartNodeServer nodeServer;

private int clientId; private int clientId;

private static final Lock authLock = new ReentrantLock(); private static final Lock authLock = new ReentrantLock();


public BftsmartConsensusManageService(BftsmartNodeServer nodeServer) { public BftsmartConsensusManageService(BftsmartNodeServer nodeServer) {
@@ -41,6 +47,7 @@ public class BftsmartConsensusManageService implements ConsensusManageService {
try { try {
authLock.lock(); authLock.lock();
((BftsmartClientIncomingConfig) clientIncomingSettings).setClientId(clientId++); ((BftsmartClientIncomingConfig) clientIncomingSettings).setClientId(clientId++);
clientId += CLIENT_SIZE_PER_GATEWAY;
} finally { } finally {
authLock.unlock(); authLock.unlock();
} }


+ 3
- 373
source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/service/BftsmartNodeServer.java View File

@@ -1,16 +1,13 @@
package com.jd.blockchain.consensus.bftsmart.service; package com.jd.blockchain.consensus.bftsmart.service;


import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import bftsmart.tom.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

import com.jd.blockchain.consensus.ConsensusManageService; import com.jd.blockchain.consensus.ConsensusManageService;
import com.jd.blockchain.consensus.NodeSettings; import com.jd.blockchain.consensus.NodeSettings;
import com.jd.blockchain.consensus.bftsmart.BftsmartConsensusProvider; import com.jd.blockchain.consensus.bftsmart.BftsmartConsensusProvider;
@@ -26,13 +23,8 @@ import com.jd.blockchain.ledger.TransactionState;
import com.jd.blockchain.utils.PropertiesUtils; import com.jd.blockchain.utils.PropertiesUtils;
import com.jd.blockchain.utils.concurrent.AsyncFuture; import com.jd.blockchain.utils.concurrent.AsyncFuture;
import com.jd.blockchain.utils.io.BytesUtils; import com.jd.blockchain.utils.io.BytesUtils;

import bftsmart.reconfiguration.util.HostsConfig; import bftsmart.reconfiguration.util.HostsConfig;
import bftsmart.reconfiguration.util.TOMConfiguration; import bftsmart.reconfiguration.util.TOMConfiguration;
import bftsmart.tom.MessageContext;
import bftsmart.tom.ReplyContext;
import bftsmart.tom.ReplyContextMessage;
import bftsmart.tom.ServiceReplica;
import bftsmart.tom.core.messages.TOMMessage; import bftsmart.tom.core.messages.TOMMessage;
import bftsmart.tom.server.defaultservices.DefaultRecoverable; import bftsmart.tom.server.defaultservices.DefaultRecoverable;


@@ -42,15 +34,9 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer


private List<StateHandle> stateHandles = new CopyOnWriteArrayList<>(); private List<StateHandle> stateHandles = new CopyOnWriteArrayList<>();


// private List<BatchConsensusListener> batchConsensusListeners = new LinkedList<>();

// private Map<ReplyContextMessage, AsyncFuture<byte[]>> replyContextMessages = new ConcurrentHashMap<>();

// TODO 暂不处理队列溢出问题 // TODO 暂不处理队列溢出问题
private ExecutorService notifyReplyExecutors = Executors.newSingleThreadExecutor(); private ExecutorService notifyReplyExecutors = Executors.newSingleThreadExecutor();


// private ExecutorService sendCommitExecutors = Executors.newFixedThreadPool(2);

private volatile Status status = Status.STOPPED; private volatile Status status = Status.STOPPED;


private final Object mutex = new Object(); private final Object mutex = new Object();
@@ -81,28 +67,6 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer


private int serverId; private int serverId;


// private volatile String batchId = null;
//
//// private List<AsyncFuture<byte[]>> replyMessages ;
//
// private boolean leader_has_makedicision = false;
//
// private boolean commit_block_condition = false;
//
// private final AtomicLong txIndex = new AtomicLong();
//
// private final AtomicLong blockIndex = new AtomicLong();
//
// private static final AtomicInteger incrementNum = new AtomicInteger();
//
//// private final BlockingQueue<ActionRequest> txRequestQueue = new LinkedBlockingQueue();
//
// private final ExecutorService queueExecutor = Executors.newSingleThreadExecutor();
//
// private final ScheduledExecutorService timerEexecutorService = new ScheduledThreadPoolExecutor(10);
// private ServiceProxy peerProxy;


public BftsmartNodeServer() { public BftsmartNodeServer() {


} }
@@ -113,28 +77,12 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer
//used later //used later
this.stateMachineReplicate = stateMachineReplicate; this.stateMachineReplicate = stateMachineReplicate;
this.messageHandle = messageHandler; this.messageHandle = messageHandler;
this.manageService = new BftsmartConsensusManageService(this);
createConfig(); createConfig();
serverId = findServerId(); serverId = findServerId();
initConfig(serverId, systemConfig, hostsConfig); initConfig(serverId, systemConfig, hostsConfig);
this.manageService = new BftsmartConsensusManageService(this);
} }


//aim to send commit block message
// protected void createProxyClient() {
// BftsmartTopology topologyCopy = (BftsmartTopology) topology.copyOf();
//
// MemoryBasedViewStorage viewStorage = new MemoryBasedViewStorage(topologyCopy.getView());
//
// byte[] bytes = BinarySerializeUtils.serialize(tomConfig);
//
// TOMConfiguration decodeTomConfig = BinarySerializeUtils.deserialize(bytes);
//
// decodeTomConfig.setProcessId(0);
//
// peerProxy = new ServiceProxy(decodeTomConfig, viewStorage, null, null);
//
// }

protected int findServerId() { protected int findServerId() {
int serverId = 0; int serverId = 0;


@@ -242,214 +190,12 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer
return appExecuteBatch(commands, msgCtxs, fromConsensus, null); return appExecuteBatch(commands, msgCtxs, fromConsensus, null);
} }


// private boolean checkLeaderId(MessageContext[] msgCtxs) {
// boolean result = false;
//
// for (int i = 0; i < msgCtxs.length - 1; i++) {
// if (msgCtxs[i].getLeader() != msgCtxs[i+1].getLeader())
// return result;
// }
//
// result = true;
//
// return result;
// }
//
// //普通消息处理
// private void normalMsgProcess(ReplyContextMessage replyContextMsg, byte[] msg, String realmName, String batchId) {
// AsyncFuture<byte[]> replyMsg = messageHandle.processOrdered(replyContextMsg.getMessageContext().getOperationId(), msg, realmName, batchId);
// replyContextMessages.put(replyContextMsg, replyMsg);
// }
//
// //结块消息处理
// private void commitMsgProcess(ReplyContextMessage replyContextMsg, String realmName, String batchId) {
// try{
// //receive messages before commitblock message, then execute commit
// if (replyContextMessages.size() != 0) {
// messageHandle.completeBatch(realmName, batchId);
// messageHandle.commitBatch(realmName, batchId);
// }
//
// // commit block msg need response too
// CompletableAsyncFuture<byte[]> asyncFuture = new CompletableAsyncFuture<>();
// TransactionResponse transactionRespHandle = new TransactionRespHandle(newBlockCommitRequest(),
// TransactionState.SUCCESS, TransactionState.SUCCESS);
//
// asyncFuture.complete(BinaryEncodingUtils.encode(transactionRespHandle, TransactionResponse.class));
// replyContextMessages.put(replyContextMsg, asyncFuture);
// }catch (Exception e){
// LOGGER.error("Error occurred on commit batch transactions, so the new block is canceled! --" + e.getMessage(), e);
// messageHandle.rollbackBatch(realmName, batchId, -1);
// }finally{
// this.batchId = null;
// }
// }

// private void sendCommitMessage() {
//
// HashDigest ledgerHash = new HashDigest(Base58Utils.decode(realmName));
//
// BlockchainKeyPair userKeyPeer = BlockchainKeyGenerator.getInstance().generate();
//
// TxContentBlob txContentBlob = new TxContentBlob(ledgerHash);
//
// byte[] reqBytes = BinaryEncodingUtils.encode(txContentBlob, TransactionContent.class);
//
// HashDigest reqHash = CryptoUtils.hash(CryptoAlgorithm.SHA256).hash(reqBytes);
//
// txContentBlob.setHash(reqHash);
//
// TxRequestMessage transactionRequest = new TxRequestMessage(txContentBlob);
//
// byte[] msg = BinaryEncodingUtils.encode(transactionRequest, TransactionRequest.class);
//
// byte[] type = BytesUtils.toBytes(1);
//
// byte[] wrapMsg = new byte[msg.length + 4];
//
// System.arraycopy(type, 0, wrapMsg, 0, 4);
// System.arraycopy(msg, 0, wrapMsg, 4, msg.length);
//
// peerProxy.invokeOrdered(wrapMsg);
//
// LOGGER.info("Send commit block msg success!");
// }

// private TransactionRequest newBlockCommitRequest() {
//
// HashDigest ledgerHash = new HashDigest(Base58Utils.decode(realmName));
//
// TxContentBlob txContentBlob = new TxContentBlob(ledgerHash);
//
// byte[] reqBytes = BinaryEncodingUtils.encode(txContentBlob, TransactionContent.class);
//
// HashDigest reqHash = CryptoUtils.hash(CryptoAlgorithm.SHA256).hash(reqBytes);
//
// txContentBlob.setHash(reqHash);
//
// TxRequestMessage transactionRequest = new TxRequestMessage(txContentBlob);
//
// return transactionRequest;
// }

// private void checkConsensusFinish() {
// BftsmartCommitBlockSettings commitBlockSettings = ((BftsmartServerSettings)serverSettings).getConsensusSettings().getCommitBlockSettings();
// int txSize = commitBlockSettings.getTxSizePerBlock();
// long maxDelay = commitBlockSettings.getMaxDelayMilliSecondsPerBlock();
//
// long currIndex = txIndex.incrementAndGet();
// if (currIndex == txSize) {
// txIndex.set(0);
// this.blockIndex.getAndIncrement();
// sendCommitExecutors.execute(()-> {
// sendCommitMessage();
// });
// } else if (currIndex == 1) {
//// System.out.printf("checkConsensusFinish schedule blockIndex = %s \r\n", this.blockIndex.get());
// timerEexecutorService.schedule(timeTask(this.blockIndex.get()), maxDelay, TimeUnit.MILLISECONDS);
// }
//
// return;
// }

// @Override
// public byte[][] appExecuteBatch(byte[][] commands, MessageContext[] msgCtxs, boolean fromConsensus, List<ReplyContextMessage> replyList) {
//
// if (!checkLeaderId(msgCtxs)) {
// throw new IllegalArgumentException();
// }
//
// boolean isLeader = (msgCtxs[0].getLeader() == getId());
//
// if (isLeader) {
// for (int i = 0; i < commands.length; i++) {
// byte[] wrapMsg = commands[i];
// byte[] type = new byte[4];
// byte[] msg= new byte[wrapMsg.length - 4];
//
// System.arraycopy(wrapMsg, 0, type, 0, 4);
// System.arraycopy(wrapMsg, 4, msg, 0, wrapMsg.length - 4);
//
// MessageContext messageContext = msgCtxs[i];
// ReplyContextMessage replyContextMessage = replyList.get(i);
// replyContextMessage.setMessageContext(messageContext);
//
// if (batchId == null) {
// batchId = messageHandle.beginBatch(realmName);
// }
//
// int msgType = BytesUtils.readInt(new ByteArrayInputStream(type));
//
// if (msgType == 0) {
//
// //only leader do it
// checkConsensusFinish();
// //normal message process
// normalMsgProcess(replyContextMessage, msg, realmName, batchId);
// }
// if (!leader_has_makedicision) {
// if (msgType == 1) {
// LOGGER.error("Error occurred on appExecuteBatch msg process, leader confilicting error!");
// }
//
// if (commit_block_condition) {
// leader_has_makedicision = true;
//
//// sendCommitExecutors.execute(() -> {
// commit_block_condition = false;
// LOGGER.info("Txcount execute commit block!");
// sendCommitMessage();
//// });
//
// }
// } else if (msgType == 1) {
// //commit block message
// commitMsgProcess(replyContextMessage, realmName, batchId);
// leader_has_makedicision = false;
// sendReplyMessage();
// }
// }
// } else {
// for (int i = 0; i < commands.length; i++) {
// byte[] wrapMsg = commands[i];
// byte[] type = new byte[4];
// byte[] msg= new byte[wrapMsg.length - 4];
//
// System.arraycopy(wrapMsg, 0, type, 0, 4);
// System.arraycopy(wrapMsg, 4, msg, 0, wrapMsg.length - 4);
//
// MessageContext messageContext = msgCtxs[i];
// ReplyContextMessage replyContextMessage = replyList.get(i);
// replyContextMessage.setMessageContext(messageContext);
//
// if (batchId == null) {
// batchId = messageHandle.beginBatch(realmName);
// }
//
// int msgType = BytesUtils.readInt(new ByteArrayInputStream(type));
//
// if (msgType == 0) {
// //normal message
// normalMsgProcess(replyContextMessage, msg, realmName, batchId);
// } else if (msgType == 1) {
// // commit block message
// commitMsgProcess(replyContextMessage, realmName, batchId);
// sendReplyMessage();
// }
// }
// }
//
// return null;
// }

@Override @Override
public byte[][] appExecuteBatch(byte[][] commands, MessageContext[] msgCtxs, boolean fromConsensus, List<ReplyContextMessage> replyList) { public byte[][] appExecuteBatch(byte[][] commands, MessageContext[] msgCtxs, boolean fromConsensus, List<ReplyContextMessage> replyList) {


if (replyList == null || replyList.size() == 0) { if (replyList == null || replyList.size() == 0) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }


// todo 此部分需要重新改造 // todo 此部分需要重新改造
/** /**
* 默认BFTSmart接口提供的commands是一个或多个共识结果的顺序集合 * 默认BFTSmart接口提供的commands是一个或多个共识结果的顺序集合
@@ -481,52 +227,6 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer
if (!manageConsensusCmds.isEmpty()) { if (!manageConsensusCmds.isEmpty()) {
blockAndReply(manageConsensusCmds, manageReplyMsgs); blockAndReply(manageConsensusCmds, manageReplyMsgs);
} }


//// if (!checkLeaderId(msgCtxs)) {
//// throw new IllegalArgumentException();
//// }
//
// if (replyList == null || replyList.size() == 0) {
// throw new IllegalArgumentException();
// }
//
// for (int i = 0; i < commands.length; i++) {
// byte[] wrapMsg = commands[i];
// byte[] type = new byte[4];
// byte[] msg= new byte[wrapMsg.length - 4];
// // batch messages, maybe in different consensus instance, leader also maybe different
// boolean isLeader = (msgCtxs[i].getLeader() == getId());
//
// System.arraycopy(wrapMsg, 0, type, 0, 4);
// System.arraycopy(wrapMsg, 4, msg, 0, wrapMsg.length - 4);
//
// MessageContext messageContext = msgCtxs[i];
// ReplyContextMessage replyContextMessage = replyList.get(i);
// replyContextMessage.setMessageContext(messageContext);
//
// if (batchId == null) {
// batchId = messageHandle.beginBatch(realmName);
// }
//
// int msgType = BytesUtils.readInt(new ByteArrayInputStream(type));
//
// if (msgType == 0) {
//
// //only leader do it
// if (isLeader) {
// checkConsensusFinish();
// }
// //normal message process
// normalMsgProcess(replyContextMessage, msg, realmName, batchId);
// }
// else if (msgType == 1) {
// //commit block message
// commitMsgProcess(replyContextMessage, realmName, batchId);
// sendReplyMessage();
// }
// }

return null; return null;
} }


@@ -574,46 +274,6 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer
}); });
} }


// private void sendReplyMessage() {
// for (ReplyContextMessage msg: replyContextMessages.keySet()) {
// byte[] reply = replyContextMessages.get(msg).get();
// msg.setReply(reply);
// TOMMessage request = msg.getTomMessage();
// ReplyContext replyContext = msg.getReplyContext();
// request.reply = new TOMMessage(replyContext.getId(), request.getSession(), request.getSequence(),
// request.getOperationId(), msg.getReply(), replyContext.getCurrentViewId(),
// request.getReqType());
//
// if (replyContext.getNumRepliers() > 0) {
// bftsmart.tom.util.Logger.println("(ServiceReplica.receiveMessages) sending reply to "
// + request.getSender() + " with sequence number " + request.getSequence()
// + " and operation ID " + request.getOperationId() + " via ReplyManager");
// replyContext.getRepMan().send(request);
// } else {
// bftsmart.tom.util.Logger.println("(ServiceReplica.receiveMessages) sending reply to "
// + request.getSender() + " with sequence number " + request.getSequence()
// + " and operation ID " + request.getOperationId());
// replyContext.getReplier().manageReply(request, msg.getMessageContext());
// // cs.send(new int[]{request.getSender()}, request.reply);
// }
// }
// replyContextMessages.clear();
// }

// private Runnable timeTask(final long currBlockIndex) {
// Runnable task = () -> {
// boolean isAdd = this.blockIndex.compareAndSet(currBlockIndex, currBlockIndex + 1);
// if (isAdd) {
// LOGGER.info("TimerTask execute commit block! ");
// this.txIndex.set(0);
// timerEexecutorService.execute(()-> {
// sendCommitMessage();
// });
// }
// };
// return task;
// }

//notice //notice
public byte[] getSnapshot() { public byte[] getSnapshot() {
LOGGER.debug("------- GetSnapshot...[replica.id=" + this.getId() + "]"); LOGGER.debug("------- GetSnapshot...[replica.id=" + this.getId() + "]");
@@ -623,9 +283,6 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer
for (StateHandle stateHandle : stateHandles) { for (StateHandle stateHandle : stateHandles) {
// TODO: 测试代码; // TODO: 测试代码;
return stateHandle.takeSnapshot(); return stateHandle.takeSnapshot();

// byte[] state = stateHandle.takeSnapshot();
// BytesEncoding.writeInNormal(state, out);
} }
return out.toByteArray(); return out.toByteArray();
} }
@@ -693,33 +350,6 @@ public class BftsmartNodeServer extends DefaultRecoverable implements NodeServer
} }
} }


// private static class ActionRequestExtend {
//
//
// ReplyContextMessage replyContextMessage;
//
// private byte[] message;
//
// private ActionRequest actionRequest;
//
// public ActionRequestExtend(byte[] message) {
// this.message = message;
// actionRequest = BinaryEncodingUtils.decode(message);
// }
//
// public byte[] getMessage() {
// return message;
// }
//
// public ReplyContextMessage getReplyContextMessage() {
// return replyContextMessage;
// }
//
// public ActionRequest getActionRequest() {
// return actionRequest;
// }
// }

enum Status { enum Status {


STARTING, STARTING,


+ 26
- 15
source/crypto/crypto-classic/src/main/java/com/jd/blockchain/crypto/utils/classic/RSAUtils.java View File

@@ -1,11 +1,31 @@
package com.jd.blockchain.crypto.utils.classic; package com.jd.blockchain.crypto.utils.classic;


import com.jd.blockchain.utils.io.BytesUtils;
import org.bouncycastle.asn1.*;
import java.io.IOException;
import java.math.BigInteger;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.interfaces.RSAPrivateCrtKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;

import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Encoding;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERNull;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers; import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.RSAPrivateKey; import org.bouncycastle.asn1.pkcs.RSAPrivateKey;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier; import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.crypto.*;
import org.bouncycastle.crypto.AsymmetricBlockCipher;
import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
import org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator;
import org.bouncycastle.crypto.CipherParameters;
import org.bouncycastle.crypto.CryptoException;
import org.bouncycastle.crypto.InvalidCipherTextException;
import org.bouncycastle.crypto.digests.SHA256Digest; import org.bouncycastle.crypto.digests.SHA256Digest;
import org.bouncycastle.crypto.encodings.PKCS1Encoding; import org.bouncycastle.crypto.encodings.PKCS1Encoding;
import org.bouncycastle.crypto.engines.RSAEngine; import org.bouncycastle.crypto.engines.RSAEngine;
@@ -16,17 +36,8 @@ import org.bouncycastle.crypto.params.RSAKeyParameters;
import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters; import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters;
import org.bouncycastle.crypto.signers.RSADigestSigner; import org.bouncycastle.crypto.signers.RSADigestSigner;
import org.bouncycastle.jcajce.provider.asymmetric.util.KeyUtil; import org.bouncycastle.jcajce.provider.asymmetric.util.KeyUtil;
import sun.security.rsa.RSAPrivateCrtKeyImpl;


import java.io.IOException;
import java.math.BigInteger;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import com.jd.blockchain.utils.io.BytesUtils;


/** /**
* @author zhanglin33 * @author zhanglin33
@@ -458,9 +469,9 @@ public class RSAUtils {
throw new com.jd.blockchain.crypto.CryptoException(e.getMessage(), e); throw new com.jd.blockchain.crypto.CryptoException(e.getMessage(), e);
} }


RSAPrivateCrtKeyImpl privateKey;
RSAPrivateCrtKey privateKey;
try { try {
privateKey = (RSAPrivateCrtKeyImpl) keyFactory.generatePrivate(keySpec);
privateKey = (RSAPrivateCrtKey) keyFactory.generatePrivate(keySpec);
} catch (InvalidKeySpecException e) { } catch (InvalidKeySpecException e) {
throw new com.jd.blockchain.crypto.CryptoException(e.getMessage(), e); throw new com.jd.blockchain.crypto.CryptoException(e.getMessage(), e);
} }


+ 5
- 5
source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/service/classic/AESEncryptionFunctionTest.java View File

@@ -69,7 +69,7 @@ public class AESEncryptionFunctionTest {
assertEquals(algorithm.code(), symmetricKey.getAlgorithm()); assertEquals(algorithm.code(), symmetricKey.getAlgorithm());


assertEquals(2 + 1 + 128 / 8, symmetricKey.toBytes().length); assertEquals(2 + 1 + 128 / 8, symmetricKey.toBytes().length);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] keyTypeBytes = new byte[] { SYMMETRIC.CODE }; byte[] keyTypeBytes = new byte[] { SYMMETRIC.CODE };
byte[] rawKeyBytes = symmetricKey.getRawKeyBytes(); byte[] rawKeyBytes = symmetricKey.getRawKeyBytes();
assertArrayEquals(BytesUtils.concat(algoBytes, keyTypeBytes, rawKeyBytes), symmetricKey.toBytes()); assertArrayEquals(BytesUtils.concat(algoBytes, keyTypeBytes, rawKeyBytes), symmetricKey.toBytes());
@@ -167,7 +167,7 @@ public class AESEncryptionFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE }; byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE };
byte[] rawKeyBytes = symmetricKey.getRawKeyBytes(); byte[] rawKeyBytes = symmetricKey.getRawKeyBytes();
byte[] ripemd160KeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes); byte[] ripemd160KeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes);
@@ -197,7 +197,7 @@ public class AESEncryptionFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE }; byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE };
byte[] rawKeyBytes = symmetricKey.getRawKeyBytes(); byte[] rawKeyBytes = symmetricKey.getRawKeyBytes();
byte[] ripemd160KeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes); byte[] ripemd160KeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes);
@@ -235,7 +235,7 @@ public class AESEncryptionFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] rawCiphertextBytes = ciphertext.toBytes(); byte[] rawCiphertextBytes = ciphertext.toBytes();
byte[] ripemd160CiphertextBytes = BytesUtils.concat(algoBytes, rawCiphertextBytes); byte[] ripemd160CiphertextBytes = BytesUtils.concat(algoBytes, rawCiphertextBytes);


@@ -275,7 +275,7 @@ public class AESEncryptionFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] rawCiphertextBytes = ciphertext.getRawCiphertext(); byte[] rawCiphertextBytes = ciphertext.getRawCiphertext();
byte[] ripemd160CiphertextBytes = BytesUtils.concat(algoBytes, rawCiphertextBytes); byte[] ripemd160CiphertextBytes = BytesUtils.concat(algoBytes, rawCiphertextBytes);




+ 7
- 7
source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/service/classic/ECDSASignatureFunctionTest.java View File

@@ -66,7 +66,7 @@ public class ECDSASignatureFunctionTest {
assertEquals(2 + 1 + 65, pubKey.toBytes().length); assertEquals(2 + 1 + 65, pubKey.toBytes().length);
assertEquals(2 + 1 + 32, privKey.toBytes().length); assertEquals(2 + 1 + 32, privKey.toBytes().length);


byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE }; byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE };
byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE }; byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE };
byte[] rawPubKeyBytes = pubKey.getRawKeyBytes(); byte[] rawPubKeyBytes = pubKey.getRawKeyBytes();
@@ -162,7 +162,7 @@ public class ECDSASignatureFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE }; byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE };
byte[] rawKeyBytes = privKey.getRawKeyBytes(); byte[] rawKeyBytes = privKey.getRawKeyBytes();
byte[] ripemd160PubKeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes); byte[] ripemd160PubKeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes);
@@ -194,7 +194,7 @@ public class ECDSASignatureFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE }; byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE };
byte[] rawKeyBytes = privKey.getRawKeyBytes(); byte[] rawKeyBytes = privKey.getRawKeyBytes();
byte[] ripemd160PubKeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes); byte[] ripemd160PubKeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes);
@@ -227,7 +227,7 @@ public class ECDSASignatureFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE }; byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE };
byte[] rawKeyBytes = pubKey.getRawKeyBytes(); byte[] rawKeyBytes = pubKey.getRawKeyBytes();
byte[] ripemd160PrivKeyBytes = BytesUtils.concat(algoBytes, privKeyTypeBytes, rawKeyBytes); byte[] ripemd160PrivKeyBytes = BytesUtils.concat(algoBytes, privKeyTypeBytes, rawKeyBytes);
@@ -259,7 +259,7 @@ public class ECDSASignatureFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE }; byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE };
byte[] rawKeyBytes = pubKey.getRawKeyBytes(); byte[] rawKeyBytes = pubKey.getRawKeyBytes();
byte[] ripemd160PrivKeyBytes = BytesUtils.concat(algoBytes, privKeyTypeBytes, rawKeyBytes); byte[] ripemd160PrivKeyBytes = BytesUtils.concat(algoBytes, privKeyTypeBytes, rawKeyBytes);
@@ -298,7 +298,7 @@ public class ECDSASignatureFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] rawDigestBytes = signatureDigest.toBytes(); byte[] rawDigestBytes = signatureDigest.toBytes();
byte[] ripemd160SignatureBytes = BytesUtils.concat(algoBytes, rawDigestBytes); byte[] ripemd160SignatureBytes = BytesUtils.concat(algoBytes, rawDigestBytes);


@@ -335,7 +335,7 @@ public class ECDSASignatureFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] rawDigestBytes = signatureDigest.getRawDigest(); byte[] rawDigestBytes = signatureDigest.getRawDigest();
byte[] ripemd160SignatureDigestBytes = BytesUtils.concat(algoBytes, rawDigestBytes); byte[] ripemd160SignatureDigestBytes = BytesUtils.concat(algoBytes, rawDigestBytes);




+ 7
- 7
source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/service/classic/ED25519SignatureFunctionTest.java View File

@@ -93,7 +93,7 @@ public class ED25519SignatureFunctionTest {
assertEquals(2 + 1 + 32, pubKey.toBytes().length); assertEquals(2 + 1 + 32, pubKey.toBytes().length);
assertEquals(2 + 1 + 32, privKey.toBytes().length); assertEquals(2 + 1 + 32, privKey.toBytes().length);


byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE }; byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE };
byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE }; byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE };
byte[] rawPubKeyBytes = pubKey.getRawKeyBytes(); byte[] rawPubKeyBytes = pubKey.getRawKeyBytes();
@@ -189,7 +189,7 @@ public class ED25519SignatureFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE }; byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE };
byte[] rawKeyBytes = privKey.getRawKeyBytes(); byte[] rawKeyBytes = privKey.getRawKeyBytes();
byte[] ripemd160PubKeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes); byte[] ripemd160PubKeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes);
@@ -221,7 +221,7 @@ public class ED25519SignatureFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE }; byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE };
byte[] rawKeyBytes = privKey.getRawKeyBytes(); byte[] rawKeyBytes = privKey.getRawKeyBytes();
byte[] ripemd160PubKeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes); byte[] ripemd160PubKeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes);
@@ -254,7 +254,7 @@ public class ED25519SignatureFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE }; byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE };
byte[] rawKeyBytes = pubKey.getRawKeyBytes(); byte[] rawKeyBytes = pubKey.getRawKeyBytes();
byte[] ripemd160PrivKeyBytes = BytesUtils.concat(algoBytes, privKeyTypeBytes, rawKeyBytes); byte[] ripemd160PrivKeyBytes = BytesUtils.concat(algoBytes, privKeyTypeBytes, rawKeyBytes);
@@ -286,7 +286,7 @@ public class ED25519SignatureFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE }; byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE };
byte[] rawKeyBytes = pubKey.getRawKeyBytes(); byte[] rawKeyBytes = pubKey.getRawKeyBytes();
byte[] ripemd160PrivKeyBytes = BytesUtils.concat(algoBytes, privKeyTypeBytes, rawKeyBytes); byte[] ripemd160PrivKeyBytes = BytesUtils.concat(algoBytes, privKeyTypeBytes, rawKeyBytes);
@@ -325,7 +325,7 @@ public class ED25519SignatureFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] rawDigestBytes = signatureDigest.toBytes(); byte[] rawDigestBytes = signatureDigest.toBytes();
byte[] ripemd160SignatureBytes = BytesUtils.concat(algoBytes, rawDigestBytes); byte[] ripemd160SignatureBytes = BytesUtils.concat(algoBytes, rawDigestBytes);


@@ -362,7 +362,7 @@ public class ED25519SignatureFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] rawDigestBytes = signatureDigest.getRawDigest(); byte[] rawDigestBytes = signatureDigest.getRawDigest();
byte[] ripemd160SignatureDigestBytes = BytesUtils.concat(algoBytes, rawDigestBytes); byte[] ripemd160SignatureDigestBytes = BytesUtils.concat(algoBytes, rawDigestBytes);




+ 4
- 4
source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/service/classic/RIPEMD160HashFunctionTest.java View File

@@ -57,7 +57,7 @@ public class RIPEMD160HashFunctionTest {


HashDigest digest = hashFunction.hash(data); HashDigest digest = hashFunction.hash(data);
byte[] rawDigestBytes = digest.getRawDigest(); byte[] rawDigestBytes = digest.getRawDigest();
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);


byte[] digestBytes = digest.toBytes(); byte[] digestBytes = digest.toBytes();
assertEquals(160 / 8 + 2, digestBytes.length); assertEquals(160 / 8 + 2, digestBytes.length);
@@ -111,7 +111,7 @@ public class RIPEMD160HashFunctionTest {


algorithm = Crypto.getAlgorithm("aes"); algorithm = Crypto.getAlgorithm("aes");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
System.arraycopy(algoBytes, 0, digestBytes, 0, algoBytes.length); System.arraycopy(algoBytes, 0, digestBytes, 0, algoBytes.length);
assertFalse(hashFunction.supportHashDigest(digestBytes)); assertFalse(hashFunction.supportHashDigest(digestBytes));
} }
@@ -140,7 +140,7 @@ public class RIPEMD160HashFunctionTest {


algorithm = Crypto.getAlgorithm("aes"); algorithm = Crypto.getAlgorithm("aes");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] rawDigestBytes = digest.getRawDigest(); byte[] rawDigestBytes = digest.getRawDigest();
byte[] aesDigestBytes = BytesUtils.concat(algoBytes, rawDigestBytes); byte[] aesDigestBytes = BytesUtils.concat(algoBytes, rawDigestBytes);


@@ -156,7 +156,7 @@ public class RIPEMD160HashFunctionTest {


algorithm = Crypto.getAlgorithm("sha256"); algorithm = Crypto.getAlgorithm("sha256");
assertNotNull(algorithm); assertNotNull(algorithm);
algoBytes = CryptoAlgorithm.toBytes(algorithm);
algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
rawDigestBytes = digest.getRawDigest(); rawDigestBytes = digest.getRawDigest();
byte[] ripemd160DigestBytes = BytesUtils.concat(algoBytes, rawDigestBytes); byte[] ripemd160DigestBytes = BytesUtils.concat(algoBytes, rawDigestBytes);




+ 9
- 9
source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/service/classic/RSACryptoFunctionTest.java View File

@@ -65,7 +65,7 @@ public class RSACryptoFunctionTest {
assertEquals(2 + 1 + 259, pubKey.toBytes().length); assertEquals(2 + 1 + 259, pubKey.toBytes().length);
assertEquals(2 + 1 + 1155, privKey.toBytes().length); assertEquals(2 + 1 + 1155, privKey.toBytes().length);


byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE }; byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE };
byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE }; byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE };
byte[] rawPubKeyBytes = pubKey.getRawKeyBytes(); byte[] rawPubKeyBytes = pubKey.getRawKeyBytes();
@@ -219,7 +219,7 @@ public class RSACryptoFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE }; byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE };
byte[] rawKeyBytes = privKey.getRawKeyBytes(); byte[] rawKeyBytes = privKey.getRawKeyBytes();
byte[] ripemd160PubKeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes); byte[] ripemd160PubKeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes);
@@ -251,7 +251,7 @@ public class RSACryptoFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE }; byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE };
byte[] rawKeyBytes = privKey.getRawKeyBytes(); byte[] rawKeyBytes = privKey.getRawKeyBytes();
byte[] ripemd160PubKeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes); byte[] ripemd160PubKeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes);
@@ -284,7 +284,7 @@ public class RSACryptoFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE }; byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE };
byte[] rawKeyBytes = pubKey.getRawKeyBytes(); byte[] rawKeyBytes = pubKey.getRawKeyBytes();
byte[] ripemd160PrivKeyBytes = BytesUtils.concat(algoBytes, privKeyTypeBytes, rawKeyBytes); byte[] ripemd160PrivKeyBytes = BytesUtils.concat(algoBytes, privKeyTypeBytes, rawKeyBytes);
@@ -316,7 +316,7 @@ public class RSACryptoFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE }; byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE };
byte[] rawKeyBytes = pubKey.getRawKeyBytes(); byte[] rawKeyBytes = pubKey.getRawKeyBytes();
byte[] ripemd160PrivKeyBytes = BytesUtils.concat(algoBytes, privKeyTypeBytes, rawKeyBytes); byte[] ripemd160PrivKeyBytes = BytesUtils.concat(algoBytes, privKeyTypeBytes, rawKeyBytes);
@@ -355,7 +355,7 @@ public class RSACryptoFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] rawDigestBytes = signatureDigest.toBytes(); byte[] rawDigestBytes = signatureDigest.toBytes();
byte[] ripemd160SignatureBytes = BytesUtils.concat(algoBytes, rawDigestBytes); byte[] ripemd160SignatureBytes = BytesUtils.concat(algoBytes, rawDigestBytes);


@@ -392,7 +392,7 @@ public class RSACryptoFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] rawDigestBytes = signatureDigest.getRawDigest(); byte[] rawDigestBytes = signatureDigest.getRawDigest();
byte[] ripemd160SignatureDigestBytes = BytesUtils.concat(algoBytes, rawDigestBytes); byte[] ripemd160SignatureDigestBytes = BytesUtils.concat(algoBytes, rawDigestBytes);


@@ -432,7 +432,7 @@ public class RSACryptoFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] rawCiphertextBytes = ciphertext.toBytes(); byte[] rawCiphertextBytes = ciphertext.toBytes();
byte[] ripemd160CiphertextBytes = BytesUtils.concat(algoBytes, rawCiphertextBytes); byte[] ripemd160CiphertextBytes = BytesUtils.concat(algoBytes, rawCiphertextBytes);


@@ -470,7 +470,7 @@ public class RSACryptoFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] rawCiphertextBytes = ciphertext.getRawCiphertext(); byte[] rawCiphertextBytes = ciphertext.getRawCiphertext();
byte[] ripemd160CiphertextBytes = BytesUtils.concat(algoBytes, rawCiphertextBytes); byte[] ripemd160CiphertextBytes = BytesUtils.concat(algoBytes, rawCiphertextBytes);




+ 4
- 4
source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/service/classic/SHA256HashFunctionTest.java View File

@@ -57,7 +57,7 @@ public class SHA256HashFunctionTest {


HashDigest digest = hashFunction.hash(data); HashDigest digest = hashFunction.hash(data);
byte[] rawDigestBytes = digest.getRawDigest(); byte[] rawDigestBytes = digest.getRawDigest();
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);


byte[] digestBytes = digest.toBytes(); byte[] digestBytes = digest.toBytes();
assertEquals(256 / 8 + 2, digestBytes.length); assertEquals(256 / 8 + 2, digestBytes.length);
@@ -111,7 +111,7 @@ public class SHA256HashFunctionTest {


algorithm = Crypto.getAlgorithm("aes"); algorithm = Crypto.getAlgorithm("aes");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
System.arraycopy(algoBytes, 0, digestBytes, 0, algoBytes.length); System.arraycopy(algoBytes, 0, digestBytes, 0, algoBytes.length);
assertFalse(hashFunction.supportHashDigest(digestBytes)); assertFalse(hashFunction.supportHashDigest(digestBytes));
} }
@@ -140,7 +140,7 @@ public class SHA256HashFunctionTest {


algorithm = Crypto.getAlgorithm("aes"); algorithm = Crypto.getAlgorithm("aes");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] rawDigestBytes = digest.getRawDigest(); byte[] rawDigestBytes = digest.getRawDigest();
byte[] aesDigestBytes = BytesUtils.concat(algoBytes, rawDigestBytes); byte[] aesDigestBytes = BytesUtils.concat(algoBytes, rawDigestBytes);


@@ -156,7 +156,7 @@ public class SHA256HashFunctionTest {


algorithm = Crypto.getAlgorithm("ripemd160"); algorithm = Crypto.getAlgorithm("ripemd160");
assertNotNull(algorithm); assertNotNull(algorithm);
algoBytes = CryptoAlgorithm.toBytes(algorithm);
algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
rawDigestBytes = digest.getRawDigest(); rawDigestBytes = digest.getRawDigest();
byte[] ripemd160DigestBytes = BytesUtils.concat(algoBytes, rawDigestBytes); byte[] ripemd160DigestBytes = BytesUtils.concat(algoBytes, rawDigestBytes);




+ 1
- 1
source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/utils/classic/ECDSAUtilsTest.java View File

@@ -146,7 +146,7 @@ public class ECDSAUtilsTest {
assertTrue(ECDSAUtils.verify(pubKey,signature,hashedMsg)); assertTrue(ECDSAUtils.verify(pubKey,signature,hashedMsg));
} }


@Test
// @Test
public void performanceTest(){ public void performanceTest(){


int count = 10000; int count = 10000;


+ 1
- 1
source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/utils/classic/ED25519UtilsTest.java View File

@@ -109,7 +109,7 @@ public class ED25519UtilsTest {


} }


@Test
// @Test
public void performanceTest(){ public void performanceTest(){


int count = 10000; int count = 10000;


+ 3
- 3
source/crypto/crypto-classic/src/test/java/test/com/jd/blockchain/crypto/utils/classic/RSAUtilsTest.java View File

@@ -175,7 +175,7 @@ public class RSAUtilsTest {
} }




@Test
// @Test
public void performanceTest(){ public void performanceTest(){


int count = 10000; int count = 10000;
@@ -241,7 +241,7 @@ public class RSAUtilsTest {
} }
} }


@Test
// @Test
public void encryptionConsistencyTest(){ public void encryptionConsistencyTest(){


int count = 10000; int count = 10000;
@@ -339,7 +339,7 @@ public class RSAUtilsTest {
assertArrayEquals(data,plaintext); assertArrayEquals(data,plaintext);
} }


@Test
// @Test
public void signatureConsistencyTest() { public void signatureConsistencyTest() {


int count = 10000; int count = 10000;


+ 3
- 3
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/BaseCryptoKey.java View File

@@ -7,9 +7,9 @@ public abstract class BaseCryptoKey extends BaseCryptoBytes implements CryptoKey
public static final int KEY_TYPE_BYTES = 1; public static final int KEY_TYPE_BYTES = 1;
private static final long serialVersionUID = 4543074827807908363L; private static final long serialVersionUID = 4543074827807908363L;


// public BaseCryptoKey() {
// super();
// }
public BaseCryptoKey() {
super();
}


protected BaseCryptoKey(short algorithm, byte[] rawKeyBytes, CryptoKeyType keyType) { protected BaseCryptoKey(short algorithm, byte[] rawKeyBytes, CryptoKeyType keyType) {
super(algorithm, CryptoBytesEncoding.encodeKeyBytes(rawKeyBytes, keyType)); super(algorithm, CryptoBytesEncoding.encodeKeyBytes(rawKeyBytes, keyType));


+ 8
- 8
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/CryptoAlgorithm.java View File

@@ -9,7 +9,7 @@ import com.jd.blockchain.binaryproto.PrimitiveType;
import com.jd.blockchain.consts.DataCodes; import com.jd.blockchain.consts.DataCodes;
import com.jd.blockchain.utils.io.BytesUtils; import com.jd.blockchain.utils.io.BytesUtils;


@DataContract(code = DataCodes.CRYPTO_ALGORITHM)
//@DataContract(code = DataCodes.CRYPTO_ALGORITHM)
public interface CryptoAlgorithm { public interface CryptoAlgorithm {


/** /**
@@ -51,7 +51,7 @@ public interface CryptoAlgorithm {
static final int SYMMETRIC_KEY = 0x0200; static final int SYMMETRIC_KEY = 0x0200;


/** /**
* 算法编码的字节长度;等同于 {@link #toBytes(CryptoAlgorithm)} 返回的字节数组的长度;
* 算法编码的字节长度;等同于 {@link #getCodeBytes(CryptoAlgorithm)} 返回的字节数组的长度;
*/ */
static final int CODE_SIZE = 2; static final int CODE_SIZE = 2;


@@ -63,7 +63,7 @@ public interface CryptoAlgorithm {
* {@link #EXT_ALGORITHM}) 5 种); 接下来4位标识密钥类型(包括:{@link #SYMMETRIC_KEY}, * {@link #EXT_ALGORITHM}) 5 种); 接下来4位标识密钥类型(包括:{@link #SYMMETRIC_KEY},
* {@link #ASYMMETRIC_KEY}); 最后8位是算法唯一ID; * {@link #ASYMMETRIC_KEY}); 最后8位是算法唯一ID;
*/ */
@DataField(primitiveType = PrimitiveType.INT16, order = 0)
// @DataField(primitiveType = PrimitiveType.INT16, order = 0)
short code(); short code();


/** /**
@@ -81,16 +81,16 @@ public interface CryptoAlgorithm {
* *
* @return * @return
*/ */
static byte[] toBytes(CryptoAlgorithm algorithm) {
static byte[] getCodeBytes(CryptoAlgorithm algorithm) {
return BytesUtils.toBytes(algorithm.code()); return BytesUtils.toBytes(algorithm.code());
} }


static short resolveCode(byte[] algorithmBytes) {
return BytesUtils.toShort(algorithmBytes, 0);
static short resolveCode(byte[] codeBytes) {
return BytesUtils.toShort(codeBytes, 0);
} }


static short resolveCode(byte[] algorithmBytes, int offset) {
return BytesUtils.toShort(algorithmBytes, offset);
static short resolveCode(byte[] codeBytes, int offset) {
return BytesUtils.toShort(codeBytes, offset);
} }


static short resolveCode(InputStream in) { static short resolveCode(InputStream in) {


+ 1
- 1
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/CryptoBytesEncoding.java View File

@@ -10,7 +10,7 @@ public final class CryptoBytesEncoding {
} }


static byte[] encodeBytes(CryptoAlgorithm algorithm, byte[] rawCryptoBytes) { static byte[] encodeBytes(CryptoAlgorithm algorithm, byte[] rawCryptoBytes) {
return BytesUtils.concat(CryptoAlgorithm.toBytes(algorithm), rawCryptoBytes);
return BytesUtils.concat(CryptoAlgorithm.getCodeBytes(algorithm), rawCryptoBytes);
} }


public static short decodeAlgorithm(byte[] cryptoBytes) { public static short decodeAlgorithm(byte[] cryptoBytes) {


+ 1
- 0
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/PrivKey.java View File

@@ -7,6 +7,7 @@ package com.jd.blockchain.crypto;
* *
*/ */
public class PrivKey extends BaseCryptoKey { public class PrivKey extends BaseCryptoKey {
private static final long serialVersionUID = 6265440395252295646L; private static final long serialVersionUID = 6265440395252295646L;
public PrivKey(short algorithm, byte[] rawCryptoBytes) { public PrivKey(short algorithm, byte[] rawCryptoBytes) {


+ 5
- 1
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/PubKey.java View File

@@ -9,7 +9,11 @@ package com.jd.blockchain.crypto;
public class PubKey extends BaseCryptoKey { public class PubKey extends BaseCryptoKey {


private static final long serialVersionUID = -2055071197736385328L; private static final long serialVersionUID = -2055071197736385328L;

public PubKey() {
super();
}

public PubKey(short algorithm, byte[] rawCryptoBytes) { public PubKey(short algorithm, byte[] rawCryptoBytes) {
super(algorithm, rawCryptoBytes, CryptoKeyType.PUBLIC); super(algorithm, rawCryptoBytes, CryptoKeyType.PUBLIC);
} }


+ 0
- 78
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/serialize/ByteArrayObjectDeserializer.java View File

@@ -1,78 +0,0 @@
package com.jd.blockchain.crypto.serialize;

import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.JSONToken;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer;
import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.PubKey;
import com.jd.blockchain.crypto.SignatureDigest;
import com.jd.blockchain.utils.Bytes;
import com.jd.blockchain.utils.codec.Base58Utils;
import com.jd.blockchain.utils.io.BytesSlice;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Type;
import java.util.Map;

public class ByteArrayObjectDeserializer extends JavaBeanDeserializer {

private ByteArrayObjectDeserializer(Class<?> clazz) {
super(ParserConfig.global, clazz);
}

public static ByteArrayObjectDeserializer getInstance(Class<?> clazz) {
return new ByteArrayObjectDeserializer(clazz);
}

@SuppressWarnings("unchecked")
@Override
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
if (type instanceof Class && clazz.isAssignableFrom((Class<?>) type)) {
String base58Str = parser.parseObject(String.class);
byte[] hashBytes = Base58Utils.decode(base58Str);
if (clazz == HashDigest.class) {
return (T) new HashDigest(hashBytes);
} else if (clazz == PubKey.class) {
return (T) new HashDigest(hashBytes);
} else if (clazz == SignatureDigest.class) {
return (T) new SignatureDigest(hashBytes);
} else if (clazz == Bytes.class) {
return (T) new Bytes(hashBytes);
} else if (clazz == BytesSlice.class) {
return (T) new BytesSlice(hashBytes);
}
}
return (T) parser.parse(fieldName);
}

@Override
public Object createInstance(Map<String, Object> map, ParserConfig config) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
if (map == null || map.isEmpty()) {
return null;
}
for (Map.Entry<String, Object> entry : map.entrySet()) {
Object value = entry.getValue();
if (value instanceof String) {
byte[] hashBytes = Base58Utils.decode((String)value);
if (clazz == HashDigest.class) {
return new HashDigest(hashBytes);
} else if (clazz == PubKey.class) {
return new PubKey(hashBytes);
} else if (clazz == SignatureDigest.class) {
return new SignatureDigest(hashBytes);
} else if (clazz == Bytes.class) {
return new Bytes(hashBytes);
} else if (clazz == BytesSlice.class) {
return new BytesSlice(hashBytes);
}
}
}
return null;
}

@Override
public int getFastMatchToken() {
return JSONToken.LBRACE;
}
}

+ 0
- 63
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/serialize/ByteArrayObjectSerializer.java View File

@@ -1,63 +0,0 @@
package com.jd.blockchain.crypto.serialize;

import java.lang.reflect.Type;

import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;
import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.PubKey;
import com.jd.blockchain.crypto.SignatureDigest;
import com.jd.blockchain.utils.Bytes;
import com.jd.blockchain.utils.io.BytesSlice;

public class ByteArrayObjectSerializer implements ObjectSerializer {

private Class<?> clazz;

private ByteArrayObjectSerializer(Class<?> clazz) {
this.clazz = clazz;
}

public static ByteArrayObjectSerializer getInstance(Class<?> clazz) {
return new ByteArrayObjectSerializer(clazz);
}

@Override
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) {
if (object.getClass() != clazz) {
serializer.writeNull();
return;
}
if (object instanceof HashDigest) {
serializer.write(new HashDigestJson(((HashDigest) object).toBase58()));
} else if (object instanceof PubKey) {
serializer.write(new HashDigestJson(((PubKey) object).toBase58()));
} else if (object instanceof SignatureDigest) {
serializer.write(new HashDigestJson(((SignatureDigest) object).toBase58()));
} else if (object instanceof Bytes) {
serializer.write(new HashDigestJson(((Bytes) object).toBase58()));
} else if (object instanceof BytesSlice) {
byte[] bytes = ((BytesSlice) object).toBytes();
serializer.write(new HashDigestJson(new String(bytes)));
}
}

private static class HashDigestJson {

String value;

public HashDigestJson(String value) {
this.value = value;
}

@SuppressWarnings("unused")
public String getValue() {
return value;
}

@SuppressWarnings("unused")
public void setValue(String value) {
this.value = value;
}
}
}

+ 9
- 9
source/crypto/crypto-sm/src/test/java/test/com/jd/blockchain/crypto/service/sm/SM2CyptoFunctionTest.java View File

@@ -65,7 +65,7 @@ public class SM2CyptoFunctionTest {
assertEquals(2 + 1 + 65, pubKey.toBytes().length); assertEquals(2 + 1 + 65, pubKey.toBytes().length);
assertEquals(2 + 1 + 32, privKey.toBytes().length); assertEquals(2 + 1 + 32, privKey.toBytes().length);


byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE }; byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE };
byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE }; byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE };
byte[] rawPubKeyBytes = pubKey.getRawKeyBytes(); byte[] rawPubKeyBytes = pubKey.getRawKeyBytes();
@@ -219,7 +219,7 @@ public class SM2CyptoFunctionTest {


algorithm = Crypto.getAlgorithm("sm3"); algorithm = Crypto.getAlgorithm("sm3");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE }; byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE };
byte[] rawKeyBytes = privKey.getRawKeyBytes(); byte[] rawKeyBytes = privKey.getRawKeyBytes();
byte[] sm3PubKeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes); byte[] sm3PubKeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes);
@@ -251,7 +251,7 @@ public class SM2CyptoFunctionTest {


algorithm = Crypto.getAlgorithm("sm3"); algorithm = Crypto.getAlgorithm("sm3");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE }; byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE };
byte[] rawKeyBytes = privKey.getRawKeyBytes(); byte[] rawKeyBytes = privKey.getRawKeyBytes();
byte[] sm3PubKeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes); byte[] sm3PubKeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes);
@@ -284,7 +284,7 @@ public class SM2CyptoFunctionTest {


algorithm = Crypto.getAlgorithm("sm3"); algorithm = Crypto.getAlgorithm("sm3");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE }; byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE };
byte[] rawKeyBytes = pubKey.getRawKeyBytes(); byte[] rawKeyBytes = pubKey.getRawKeyBytes();
byte[] sm3PrivKeyBytes = BytesUtils.concat(algoBytes, privKeyTypeBytes, rawKeyBytes); byte[] sm3PrivKeyBytes = BytesUtils.concat(algoBytes, privKeyTypeBytes, rawKeyBytes);
@@ -316,7 +316,7 @@ public class SM2CyptoFunctionTest {


algorithm = Crypto.getAlgorithm("sm3"); algorithm = Crypto.getAlgorithm("sm3");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE }; byte[] privKeyTypeBytes = new byte[] { PRIVATE.CODE };
byte[] rawKeyBytes = pubKey.getRawKeyBytes(); byte[] rawKeyBytes = pubKey.getRawKeyBytes();
byte[] sm3PrivKeyBytes = BytesUtils.concat(algoBytes, privKeyTypeBytes, rawKeyBytes); byte[] sm3PrivKeyBytes = BytesUtils.concat(algoBytes, privKeyTypeBytes, rawKeyBytes);
@@ -355,7 +355,7 @@ public class SM2CyptoFunctionTest {


algorithm = Crypto.getAlgorithm("sm3"); algorithm = Crypto.getAlgorithm("sm3");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] rawDigestBytes = signatureDigest.toBytes(); byte[] rawDigestBytes = signatureDigest.toBytes();
byte[] sm3SignatureBytes = BytesUtils.concat(algoBytes, rawDigestBytes); byte[] sm3SignatureBytes = BytesUtils.concat(algoBytes, rawDigestBytes);


@@ -392,7 +392,7 @@ public class SM2CyptoFunctionTest {


algorithm = Crypto.getAlgorithm("sm3"); algorithm = Crypto.getAlgorithm("sm3");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] rawDigestBytes = signatureDigest.getRawDigest(); byte[] rawDigestBytes = signatureDigest.getRawDigest();
byte[] sm3SignatureDigestBytes = BytesUtils.concat(algoBytes, rawDigestBytes); byte[] sm3SignatureDigestBytes = BytesUtils.concat(algoBytes, rawDigestBytes);


@@ -432,7 +432,7 @@ public class SM2CyptoFunctionTest {


algorithm = Crypto.getAlgorithm("sm3"); algorithm = Crypto.getAlgorithm("sm3");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] rawCiphertextBytes = ciphertext.toBytes(); byte[] rawCiphertextBytes = ciphertext.toBytes();
byte[] sm3CiphertextBytes = BytesUtils.concat(algoBytes, rawCiphertextBytes); byte[] sm3CiphertextBytes = BytesUtils.concat(algoBytes, rawCiphertextBytes);


@@ -470,7 +470,7 @@ public class SM2CyptoFunctionTest {


algorithm = Crypto.getAlgorithm("sm3"); algorithm = Crypto.getAlgorithm("sm3");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] rawCiphertextBytes = ciphertext.getRawCiphertext(); byte[] rawCiphertextBytes = ciphertext.getRawCiphertext();
byte[] sm3CiphertextBytes = BytesUtils.concat(algoBytes, rawCiphertextBytes); byte[] sm3CiphertextBytes = BytesUtils.concat(algoBytes, rawCiphertextBytes);




+ 3
- 3
source/crypto/crypto-sm/src/test/java/test/com/jd/blockchain/crypto/service/sm/SM3HashFunctionTest.java View File

@@ -55,7 +55,7 @@ public class SM3HashFunctionTest {


HashDigest digest = hashFunction.hash(data); HashDigest digest = hashFunction.hash(data);
byte[] rawDigestBytes = digest.getRawDigest(); byte[] rawDigestBytes = digest.getRawDigest();
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);


byte[] digestBytes = digest.toBytes(); byte[] digestBytes = digest.toBytes();
assertEquals(256 / 8 + 2, digestBytes.length); assertEquals(256 / 8 + 2, digestBytes.length);
@@ -109,7 +109,7 @@ public class SM3HashFunctionTest {


algorithm = Crypto.getAlgorithm("sm4"); algorithm = Crypto.getAlgorithm("sm4");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
System.arraycopy(algoBytes, 0, digestBytes, 0, algoBytes.length); System.arraycopy(algoBytes, 0, digestBytes, 0, algoBytes.length);
assertFalse(hashFunction.supportHashDigest(digestBytes)); assertFalse(hashFunction.supportHashDigest(digestBytes));
} }
@@ -138,7 +138,7 @@ public class SM3HashFunctionTest {


algorithm = Crypto.getAlgorithm("sm4"); algorithm = Crypto.getAlgorithm("sm4");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] rawDigestBytes = digest.getRawDigest(); byte[] rawDigestBytes = digest.getRawDigest();
byte[] aesDigestBytes = BytesUtils.concat(algoBytes, rawDigestBytes); byte[] aesDigestBytes = BytesUtils.concat(algoBytes, rawDigestBytes);




+ 5
- 5
source/crypto/crypto-sm/src/test/java/test/com/jd/blockchain/crypto/service/sm/SM4EncryptionFunctionTest.java View File

@@ -68,7 +68,7 @@ public class SM4EncryptionFunctionTest {
assertEquals(algorithm.code(), symmetricKey.getAlgorithm()); assertEquals(algorithm.code(), symmetricKey.getAlgorithm());


assertEquals(2 + 1 + 128 / 8, symmetricKey.toBytes().length); assertEquals(2 + 1 + 128 / 8, symmetricKey.toBytes().length);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] keyTypeBytes = new byte[] { SYMMETRIC.CODE }; byte[] keyTypeBytes = new byte[] { SYMMETRIC.CODE };
byte[] rawKeyBytes = symmetricKey.getRawKeyBytes(); byte[] rawKeyBytes = symmetricKey.getRawKeyBytes();
assertArrayEquals(BytesUtils.concat(algoBytes, keyTypeBytes, rawKeyBytes), symmetricKey.toBytes()); assertArrayEquals(BytesUtils.concat(algoBytes, keyTypeBytes, rawKeyBytes), symmetricKey.toBytes());
@@ -165,7 +165,7 @@ public class SM4EncryptionFunctionTest {


algorithm = Crypto.getAlgorithm("sm3"); algorithm = Crypto.getAlgorithm("sm3");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE }; byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE };
byte[] rawKeyBytes = symmetricKey.getRawKeyBytes(); byte[] rawKeyBytes = symmetricKey.getRawKeyBytes();
byte[] ripemd160KeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes); byte[] ripemd160KeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes);
@@ -194,7 +194,7 @@ public class SM4EncryptionFunctionTest {


algorithm = Crypto.getAlgorithm("sm3"); algorithm = Crypto.getAlgorithm("sm3");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE }; byte[] pubKeyTypeBytes = new byte[] { PUBLIC.CODE };
byte[] rawKeyBytes = symmetricKey.getRawKeyBytes(); byte[] rawKeyBytes = symmetricKey.getRawKeyBytes();
byte[] ripemd160KeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes); byte[] ripemd160KeyBytes = BytesUtils.concat(algoBytes, pubKeyTypeBytes, rawKeyBytes);
@@ -232,7 +232,7 @@ public class SM4EncryptionFunctionTest {


algorithm = Crypto.getAlgorithm("sm3"); algorithm = Crypto.getAlgorithm("sm3");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] rawCiphertextBytes = ciphertext.toBytes(); byte[] rawCiphertextBytes = ciphertext.toBytes();
byte[] sm3CiphertextBytes = BytesUtils.concat(algoBytes, rawCiphertextBytes); byte[] sm3CiphertextBytes = BytesUtils.concat(algoBytes, rawCiphertextBytes);


@@ -268,7 +268,7 @@ public class SM4EncryptionFunctionTest {


algorithm = Crypto.getAlgorithm("sm3"); algorithm = Crypto.getAlgorithm("sm3");
assertNotNull(algorithm); assertNotNull(algorithm);
byte[] algoBytes = CryptoAlgorithm.toBytes(algorithm);
byte[] algoBytes = CryptoAlgorithm.getCodeBytes(algorithm);
byte[] rawCiphertextBytes = ciphertext.getRawCiphertext(); byte[] rawCiphertextBytes = ciphertext.getRawCiphertext();
byte[] sm3CiphertextBytes = BytesUtils.concat(algoBytes, rawCiphertextBytes); byte[] sm3CiphertextBytes = BytesUtils.concat(algoBytes, rawCiphertextBytes);




+ 43
- 43
source/crypto/crypto-sm/src/test/java/test/com/jd/blockchain/crypto/utils/SM2UtilsTest.java View File

@@ -119,50 +119,50 @@ public class SM2UtilsTest {
byte[] plaintext = SM2Utils.decrypt(ciphertext,privKeyBytes); byte[] plaintext = SM2Utils.decrypt(ciphertext,privKeyBytes);
assertArrayEquals(expectedMessage.getBytes(),plaintext); assertArrayEquals(expectedMessage.getBytes(),plaintext);
} }
//

// @Test
public void encryptingPerformace(){

byte[] data = new byte[1000];
Random random = new Random();
random.nextBytes(data);

int count = 10000;

byte[] ciphertext = null;

AsymmetricCipherKeyPair keyPair = SM2Utils.generateKeyPair();
ECPublicKeyParameters ecPub = (ECPublicKeyParameters) keyPair.getPublic();
ECPrivateKeyParameters ecPriv = (ECPrivateKeyParameters) keyPair.getPrivate();

System.out.println("=================== do SM2 encrypt test ===================");

for (int r = 0; r < 5; r++) {
System.out.println("------------- round[" + r + "] --------------");
long startTS = System.currentTimeMillis();
for (int i = 0; i < count; i++) {
ciphertext = SM2Utils.encrypt(data,ecPub);
}
long elapsedTS = System.currentTimeMillis() - startTS;
System.out.println(String.format("SM2 Encrypting Count=%s; Elapsed Times=%s; KBPS=%.2f", count, elapsedTS,
(count * 1000.00D) / elapsedTS));
}

System.out.println("=================== do SM2 decrypt test ===================");
for (int r = 0; r < 5; r++) {
System.out.println("------------- round[" + r + "] --------------");
long startTS = System.currentTimeMillis();
for (int i = 0; i < count; i++) {
SM2Utils.decrypt(ciphertext,ecPriv);
}
long elapsedTS = System.currentTimeMillis() - startTS;
System.out.println(String.format("SM2 Decrypting Count=%s; Elapsed Times=%s; KBPS=%.2f", count, elapsedTS,
(count * 1000.00D) / elapsedTS));
}
}


// @Test // @Test
// public void encryptingPerformace(){
//
// byte[] data = new byte[1000];
// Random random = new Random();
// random.nextBytes(data);
//
// int count = 10000;
//
// byte[] ciphertext = null;
//
// AsymmetricCipherKeyPair keyPair = SM2Utils.generateKeyPair();
// ECPublicKeyParameters ecPub = (ECPublicKeyParameters) keyPair.getPublic();
// ECPrivateKeyParameters ecPriv = (ECPrivateKeyParameters) keyPair.getPrivate();
//
// System.out.println("=================== do SM2 encrypt test ===================");
//
// for (int r = 0; r < 5; r++) {
// System.out.println("------------- round[" + r + "] --------------");
// long startTS = System.currentTimeMillis();
// for (int i = 0; i < count; i++) {
// ciphertext = SM2Utils.encrypt(data,ecPub);
// }
// long elapsedTS = System.currentTimeMillis() - startTS;
// System.out.println(String.format("SM2 Encrypting Count=%s; Elapsed Times=%s; KBPS=%.2f", count, elapsedTS,
// (count * 1000.00D) / elapsedTS));
// }
//
// System.out.println("=================== do SM2 decrypt test ===================");
// for (int r = 0; r < 5; r++) {
// System.out.println("------------- round[" + r + "] --------------");
// long startTS = System.currentTimeMillis();
// for (int i = 0; i < count; i++) {
// SM2Utils.decrypt(ciphertext,ecPriv);
// }
// long elapsedTS = System.currentTimeMillis() - startTS;
// System.out.println(String.format("SM2 Decrypting Count=%s; Elapsed Times=%s; KBPS=%.2f", count, elapsedTS,
// (count * 1000.00D) / elapsedTS));
// }
// }
//
//
@Test
public void signingPerformace(){ public void signingPerformace(){


byte[] data = new byte[1024]; byte[] data = new byte[1024];


+ 22
- 0
source/deployment/deployment-peer/pom.xml View File

@@ -25,6 +25,28 @@
<artifactId>runtime-modular-booter</artifactId> <artifactId>runtime-modular-booter</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>

<dependency>
<groupId>com.jd.blockchain</groupId>
<artifactId>storage-composite</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.jd.blockchain</groupId>
<artifactId>storage-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.jd.blockchain</groupId>
<artifactId>storage-redis</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.jd.blockchain</groupId>
<artifactId>storage-rocksdb</artifactId>
<version>${project.version}</version>
</dependency>

<!-- <dependency> <groupId>com.jd.blockchain</groupId> <artifactId>gateway</artifactId> <!-- <dependency> <groupId>com.jd.blockchain</groupId> <artifactId>gateway</artifactId>
<version>${project.version}</version> </dependency> --> <version>${project.version}</version> </dependency> -->




+ 0
- 9
source/deployment/deployment-peer/src/main/resources/assembly.xml View File

@@ -62,15 +62,6 @@
<useAllReactorProjects>true</useAllReactorProjects> <useAllReactorProjects>true</useAllReactorProjects>
<includes> <includes>
<include>com.jd.blockchain:tools-initializer-booter</include> <include>com.jd.blockchain:tools-initializer-booter</include>
</includes>
<binaries>
<outputDirectory>libs</outputDirectory>
<unpack>false</unpack>
</binaries>
</moduleSet>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>com.jd.blockchain:tools-keygen-booter</include> <include>com.jd.blockchain:tools-keygen-booter</include>
</includes> </includes>
<binaries> <binaries>


+ 23
- 1
source/gateway/pom.xml View File

@@ -15,6 +15,17 @@
<artifactId>consensus-framework</artifactId> <artifactId>consensus-framework</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.jd.blockchain</groupId>
<artifactId>consensus-bftsmart</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.jd.blockchain</groupId>
<artifactId>consensus-mq</artifactId>
<version>${project.version}</version>
</dependency>

<dependency> <dependency>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>ledger-rpc</artifactId> <artifactId>ledger-rpc</artifactId>
@@ -43,11 +54,22 @@
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>


<dependency>
<groupId>com.jd.blockchain</groupId>
<artifactId>crypto-framework</artifactId>
<version>${project.version}</version>
</dependency>

<dependency> <dependency>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>crypto-classic</artifactId> <artifactId>crypto-classic</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.jd.blockchain</groupId>
<artifactId>crypto-sm</artifactId>
<version>${project.version}</version>
</dependency> </dependency>


<dependency> <dependency>


+ 10
- 0
source/gateway/src/main/java/com/jd/blockchain/gateway/service/GatewayQueryService.java View File

@@ -2,6 +2,7 @@ package com.jd.blockchain.gateway.service;


import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.ledger.ParticipantNode; import com.jd.blockchain.ledger.ParticipantNode;
import com.jd.blockchain.sdk.LedgerInitSettings;


/** /**
* queryService only for gateway; * queryService only for gateway;
@@ -24,4 +25,13 @@ public interface GatewayQueryService {
* @return * @return
*/ */
ParticipantNode[] getConsensusParticipants(HashDigest ledgerHash, int fromIndex, int count); ParticipantNode[] getConsensusParticipants(HashDigest ledgerHash, int fromIndex, int count);

/**
* 获取账本初始化配置信息
*
* @param ledgerHash
* 账本Hash
* @return
*/
LedgerInitSettings getLedgerInitSettings(HashDigest ledgerHash);
} }

+ 144
- 0
source/gateway/src/main/java/com/jd/blockchain/gateway/service/GatewayQueryServiceHandler.java View File

@@ -0,0 +1,144 @@
package com.jd.blockchain.gateway.service;

import com.jd.blockchain.consensus.ConsensusProvider;
import com.jd.blockchain.consensus.ConsensusProviders;
import com.jd.blockchain.consensus.ConsensusSettings;
import com.jd.blockchain.consensus.bftsmart.BftsmartConsensusProvider;
import com.jd.blockchain.consensus.mq.MsgQueueConsensusProvider;
import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.gateway.PeerService;
import com.jd.blockchain.ledger.LedgerMetadata;
import com.jd.blockchain.ledger.ParticipantNode;
import com.jd.blockchain.sdk.LedgerInitSettings;
import com.jd.blockchain.utils.QueryUtil;
import com.jd.blockchain.utils.codec.HexUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Arrays;


/**
* @Author zhaogw
* @Date 2019/2/22 10:39
*/
@Component
public class GatewayQueryServiceHandler implements GatewayQueryService {

@Autowired
private PeerService peerService;

@Override
public HashDigest[] getLedgersHash(int fromIndex, int count) {
HashDigest ledgersHash[] = peerService.getQueryService().getLedgerHashs();
int indexAndCount[] = QueryUtil.calFromIndexAndCount(fromIndex,count,ledgersHash.length);
HashDigest ledgersHashNew[] = Arrays.copyOfRange(ledgersHash,indexAndCount[0],indexAndCount[0]+indexAndCount[1]);
return ledgersHashNew;
}

@Override
public ParticipantNode[] getConsensusParticipants(HashDigest ledgerHash, int fromIndex, int count) {
ParticipantNode participantNode[] = peerService.getQueryService().getConsensusParticipants(ledgerHash);
int indexAndCount[] = QueryUtil.calFromIndexAndCount(fromIndex,count,participantNode.length);
ParticipantNode participantNodesNew[] = Arrays.copyOfRange(participantNode,indexAndCount[0],indexAndCount[0]+indexAndCount[1]);
return participantNodesNew;
}

@Override
public LedgerInitSettings getLedgerInitSettings(HashDigest ledgerHash) {

ParticipantNode[] participantNodes = peerService.getQueryService().getConsensusParticipants(ledgerHash);

LedgerMetadata ledgerMetadata = peerService.getQueryService().getLedgerMetadata(ledgerHash);

return initLedgerInitSettings(participantNodes, ledgerMetadata);
}

/**
* 初始化账本配置
*
* @param participantNodes
* 参与方列表
* @param ledgerMetadata
* 账本元数据
* @return
*/
private LedgerInitSettings initLedgerInitSettings(ParticipantNode[] participantNodes, LedgerMetadata ledgerMetadata) {
LedgerInitSettings ledgerInitSettings = new LedgerInitSettings();

// 设置参与方
ledgerInitSettings.setParticipantNodes(participantNodes);

// 设置共识设置
ledgerInitSettings.setConsensusSettings(initConsensusSettings(ledgerMetadata));

// 设置参与方根Hash
ledgerInitSettings.setParticipantsHash(ledgerMetadata.getParticipantsHash());

// 设置算法配置
ledgerInitSettings.setCryptoSetting(ledgerMetadata.getSetting().getCryptoSetting());

// 设置种子
ledgerInitSettings.setSeed(initSeed(ledgerMetadata.getSeed()));

// 设置共识协议
ledgerInitSettings.setConsensusProtocol(consensusProtocol(ledgerMetadata.getSetting().getConsensusProvider()));

return ledgerInitSettings;
}

/**
* 初始化账本种子信息
*
* @param seedBytes
* 种子的字节数组显示
* @return
* 种子以十六进制方式显示,为方便阅读,每隔八个字符中间以"-"分割
*/
private String initSeed(byte[] seedBytes) {
String seedString = HexUtils.encode(seedBytes);
// 每隔八个字符中加入一个一个横线
StringBuffer seed = new StringBuffer();

for( int i = 0; i < seedString.length(); i++) {
char c = seedString.charAt(i);
if (i != 0 && i % 8 == 0) {
seed.append("-");
}
seed.append(c);
}

return seed.toString();
}

/**
* 生成共识协议
*
* @param consensusProvider
* 共识协议提提供者
* @return
*/
private int consensusProtocol(String consensusProvider) {

if (consensusProvider.equals(BftsmartConsensusProvider.NAME)) {
return LedgerInitSettings.CONSENSUS_PROTOCOL.BFTSMART.code();
} else if (consensusProvider.equals(MsgQueueConsensusProvider.NAME)) {
return LedgerInitSettings.CONSENSUS_PROTOCOL.MSGQUEUE.code();
}

return LedgerInitSettings.CONSENSUS_PROTOCOL.UNKNOWN.code();
}

/**
* 初始化共识配置
*
* @param ledgerMetadata
* 账本元数据
* @return
*/
private ConsensusSettings initConsensusSettings(LedgerMetadata ledgerMetadata) {
String consensusProvider = ledgerMetadata.getSetting().getConsensusProvider();
ConsensusProvider provider = ConsensusProviders.getProvider(consensusProvider);
byte[] consensusSettingsBytes = ledgerMetadata.getSetting().getConsensusSetting().toBytes();
return provider.getSettingsFactory().getConsensusSettingsEncoder().decode(consensusSettingsBytes);
}
}

+ 37
- 37
source/gateway/src/main/java/com/jd/blockchain/gateway/service/GatewayQueryServiceImpl.java View File

@@ -1,37 +1,37 @@
package com.jd.blockchain.gateway.service;
import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.gateway.PeerService;
import com.jd.blockchain.ledger.ParticipantNode;
import com.jd.blockchain.utils.QueryUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import static com.jd.blockchain.utils.BaseConstant.QUERY_LIST_MAX;
/**
* @Author zhaogw
* @Date 2019/2/22 10:39
*/
@Component
public class GatewayQueryServiceImpl implements GatewayQueryService {
@Autowired
private PeerService peerService;
@Override
public HashDigest[] getLedgersHash(int fromIndex, int count) {
HashDigest ledgersHash[] = peerService.getQueryService().getLedgerHashs();
int indexAndCount[] = QueryUtil.calFromIndexAndCount(fromIndex,count,ledgersHash.length);
HashDigest ledgersHashNew[] = Arrays.copyOfRange(ledgersHash,indexAndCount[0],indexAndCount[0]+indexAndCount[1]);
return ledgersHashNew;
}
@Override
public ParticipantNode[] getConsensusParticipants(HashDigest ledgerHash, int fromIndex, int count) {
ParticipantNode participantNode[] = peerService.getQueryService().getConsensusParticipants(ledgerHash);
int indexAndCount[] = QueryUtil.calFromIndexAndCount(fromIndex,count,participantNode.length);
ParticipantNode participantNodesNew[] = Arrays.copyOfRange(participantNode,indexAndCount[0],indexAndCount[0]+indexAndCount[1]);
return participantNodesNew;
}
}
//package com.jd.blockchain.gateway.service;
//
//import com.jd.blockchain.crypto.HashDigest;
//import com.jd.blockchain.gateway.PeerService;
//import com.jd.blockchain.ledger.ParticipantNode;
//import com.jd.blockchain.utils.QueryUtil;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import java.util.Arrays;
//
//import static com.jd.blockchain.utils.BaseConstant.QUERY_LIST_MAX;
//
///**
// * @Author zhaogw
// * @Date 2019/2/22 10:39
// */
//@Component
//public class GatewayQueryServiceImpl implements GatewayQueryService {
// @Autowired
// private PeerService peerService;
//
// @Override
// public HashDigest[] getLedgersHash(int fromIndex, int count) {
// HashDigest ledgersHash[] = peerService.getQueryService().getLedgerHashs();
// int indexAndCount[] = QueryUtil.calFromIndexAndCount(fromIndex,count,ledgersHash.length);
// HashDigest ledgersHashNew[] = Arrays.copyOfRange(ledgersHash,indexAndCount[0],indexAndCount[0]+indexAndCount[1]);
// return ledgersHashNew;
// }
//
// @Override
// public ParticipantNode[] getConsensusParticipants(HashDigest ledgerHash, int fromIndex, int count) {
// ParticipantNode participantNode[] = peerService.getQueryService().getConsensusParticipants(ledgerHash);
// int indexAndCount[] = QueryUtil.calFromIndexAndCount(fromIndex,count,participantNode.length);
// ParticipantNode participantNodesNew[] = Arrays.copyOfRange(participantNode,indexAndCount[0],indexAndCount[0]+indexAndCount[1]);
// return participantNodesNew;
// }
//}

+ 12
- 0
source/gateway/src/main/java/com/jd/blockchain/gateway/web/BlockBrowserController.java View File

@@ -8,6 +8,7 @@ import com.jd.blockchain.gateway.service.DataRetrievalService;
import com.jd.blockchain.gateway.service.GatewayQueryService; import com.jd.blockchain.gateway.service.GatewayQueryService;
import com.jd.blockchain.ledger.*; import com.jd.blockchain.ledger.*;
import com.jd.blockchain.sdk.BlockchainExtendQueryService; import com.jd.blockchain.sdk.BlockchainExtendQueryService;
import com.jd.blockchain.sdk.LedgerInitSettings;
import com.jd.blockchain.tools.keygen.KeyGenCommand; import com.jd.blockchain.tools.keygen.KeyGenCommand;
import com.jd.blockchain.utils.BaseConstant; import com.jd.blockchain.utils.BaseConstant;
import com.jd.blockchain.utils.ConsoleUtils; import com.jd.blockchain.utils.ConsoleUtils;
@@ -58,6 +59,17 @@ public class BlockBrowserController implements BlockchainExtendQueryService {
return peerService.getQueryService().getConsensusParticipants(ledgerHash); return peerService.getQueryService().getConsensusParticipants(ledgerHash);
} }


@RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/metadata")
@Override
public LedgerMetadata getLedgerMetadata(@PathVariable(name = "ledgerHash") HashDigest ledgerHash) {
return peerService.getQueryService().getLedgerMetadata(ledgerHash);
}

@RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/settings")
public LedgerInitSettings getLedgerInitSettings(@PathVariable(name = "ledgerHash") HashDigest ledgerHash) {
return gatewayQueryService.getLedgerInitSettings(ledgerHash);
}

@RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/blocks") @RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/blocks")
public LedgerBlock[] getBlocks(@PathVariable(name = "ledgerHash") HashDigest ledgerHash) { public LedgerBlock[] getBlocks(@PathVariable(name = "ledgerHash") HashDigest ledgerHash) {
LedgerInfo ledgerInfo = peerService.getQueryService().getLedger(ledgerHash); LedgerInfo ledgerInfo = peerService.getQueryService().getLedger(ledgerHash);


+ 5
- 22
source/gateway/src/main/java/com/jd/blockchain/gateway/web/GatewayWebServerConfigurer.java View File

@@ -2,7 +2,7 @@ package com.jd.blockchain.gateway.web;


import java.util.List; import java.util.List;


import com.jd.blockchain.utils.io.BytesSlice;
import com.jd.blockchain.web.serializes.ByteArrayObjectUtil;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry; import org.springframework.format.FormatterRegistry;
import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter;
@@ -11,12 +11,6 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.PubKey;
import com.jd.blockchain.crypto.SignatureDigest;
import com.jd.blockchain.crypto.serialize.ByteArrayObjectDeserializer;
import com.jd.blockchain.crypto.serialize.ByteArrayObjectSerializer;
import com.jd.blockchain.utils.Bytes;
import com.jd.blockchain.utils.io.ByteArray; import com.jd.blockchain.utils.io.ByteArray;
import com.jd.blockchain.utils.serialize.json.JSONSerializeUtils; import com.jd.blockchain.utils.serialize.json.JSONSerializeUtils;
import com.jd.blockchain.utils.web.model.JsonWebResponseMessageConverter; import com.jd.blockchain.utils.web.model.JsonWebResponseMessageConverter;
@@ -30,13 +24,6 @@ import com.jd.blockchain.web.converters.HashDigestInputConverter;
@Configuration @Configuration
public class GatewayWebServerConfigurer implements WebMvcConfigurer { public class GatewayWebServerConfigurer implements WebMvcConfigurer {


private static final Class<?>[] BYTEARRAY_JSON_SERIALIZE_CLASS = new Class<?>[] {
HashDigest.class,
PubKey.class,
SignatureDigest.class,
Bytes.class,
BytesSlice.class};

static { static {
JSONSerializeUtils.disableCircularReferenceDetect(); JSONSerializeUtils.disableCircularReferenceDetect();
JSONSerializeUtils.configStringSerializer(ByteArray.class); JSONSerializeUtils.configStringSerializer(ByteArray.class);
@@ -67,11 +54,11 @@ public class GatewayWebServerConfigurer implements WebMvcConfigurer {
registry.addConverter(new HashDigestInputConverter()); registry.addConverter(new HashDigestInputConverter());
} }


@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/webjars/**") registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources"); .addResourceLocations("classpath:/META-INF/resources");
}
}


@Override @Override
public void addViewControllers(ViewControllerRegistry registry) { public void addViewControllers(ViewControllerRegistry registry) {
@@ -79,10 +66,6 @@ public class GatewayWebServerConfigurer implements WebMvcConfigurer {
} }


private void initByteArrayJsonSerialize() { private void initByteArrayJsonSerialize() {
for (Class<?> byteArrayClass : BYTEARRAY_JSON_SERIALIZE_CLASS) {
JSONSerializeUtils.configSerialization(byteArrayClass,
ByteArrayObjectSerializer.getInstance(byteArrayClass),
ByteArrayObjectDeserializer.getInstance(byteArrayClass));
}
ByteArrayObjectUtil.init();
} }
} }

+ 10
- 8
source/gateway/src/main/resources/gateway.conf View File

@@ -1,28 +1,30 @@
#网关的HTTP服务地址; #网关的HTTP服务地址;
http.host=127.0.0.1
http.host=0.0.0.0
#网关的HTTP服务端口; #网关的HTTP服务端口;
http.port=8081 http.port=8081
#网关的HTTP服务上下文路径,可选; #网关的HTTP服务上下文路径,可选;
#http.context-path= #http.context-path=
#共识节点的服务地址;
#共识节点的服务地址(与该网关节点连接的Peer节点的IP地址)
peer.host=127.0.0.1 peer.host=127.0.0.1
#共识节点的服务端口;
peer.port=7080
#共识节点的服务端口(与该网关节点连接的Peer节点的端口)
peer.port=12000
#共识节点的服务是否启用安全证书; #共识节点的服务是否启用安全证书;
peer.secure=false peer.secure=false
#共识节点的服务提供解析器 #共识节点的服务提供解析器
#BftSmart共识Provider:com.jd.blockchain.consensus.bftsmart.BftsmartConsensusProvider
#简单消息共识Provider:com.jd.blockchain.consensus.mq.MsgQueueConsensusProvider
peer.providers=com.jd.blockchain.consensus.bftsmart.BftsmartConsensusProvider peer.providers=com.jd.blockchain.consensus.bftsmart.BftsmartConsensusProvider
#数据检索服务对应URL
#数据检索服务对应URL,格式:http://{ip}:{port},例如:http://127.0.0.1:10001
#若该值不配置或配置不正确,则浏览器模糊查询部分无法正常显示 #若该值不配置或配置不正确,则浏览器模糊查询部分无法正常显示
data.retrieval.url=http://192.168.1.1:10001
data.retrieval.url=http://127.0.0.1:10001
#默认公钥的内容(Base58编码数据); #默认公钥的内容(Base58编码数据);
keys.default.pubkey=endPsK36g6bhgn5bj66uyX4uxqnkfGvdjpxWurAA5hbf8vVoVi8H
keys.default.pubkey=3snPdw7i7PapsDoW185c3kfK6p8s6SwiJAdEUzgnfeuUox12nxgzXu
#默认私钥的路径;在 pk-path 和 pk 之间必须设置其一; #默认私钥的路径;在 pk-path 和 pk 之间必须设置其一;
keys.default.privkey-path= keys.default.privkey-path=
#默认私钥的内容(加密的Base58编码数据);在 pk-path 和 pk 之间必须设置其一; #默认私钥的内容(加密的Base58编码数据);在 pk-path 和 pk 之间必须设置其一;
keys.default.privkey=177gjwmuvDnccAvrvmJyCN1dgAqqGzfYpe3pZ8dWWNBneM5GgdsS96vgjvBP4fX61jWfohQ
keys.default.privkey=177gjyoEUhdD1NkQSxBVvfSyovMd1ha5H46zsb9kyErLNBuQkLRAf2ea6CNjStjCFJQN8S1
#默认私钥的解码密码; #默认私钥的解码密码;
keys.default.privkey-password=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY keys.default.privkey-password=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY

+ 2
- 0
source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/LedgerAdminAccount.java View File

@@ -1,5 +1,7 @@
package com.jd.blockchain.ledger.core; package com.jd.blockchain.ledger.core;
import com.jd.blockchain.ledger.LedgerMetadata;
import com.jd.blockchain.ledger.LedgerSetting;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;


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

@@ -1,5 +1,6 @@
package com.jd.blockchain.ledger.core; package com.jd.blockchain.ledger.core;


import com.jd.blockchain.ledger.LedgerMetadata;
import com.jd.blockchain.ledger.ParticipantNode; import com.jd.blockchain.ledger.ParticipantNode;


public interface LedgerAdministration { public interface LedgerAdministration {


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

@@ -1,6 +1,7 @@
package com.jd.blockchain.ledger.core; package com.jd.blockchain.ledger.core;


import com.jd.blockchain.ledger.CryptoSetting; import com.jd.blockchain.ledger.CryptoSetting;
import com.jd.blockchain.ledger.LedgerSetting;
import com.jd.blockchain.utils.Bytes; import com.jd.blockchain.utils.Bytes;


public class LedgerConfiguration implements LedgerSetting { public class LedgerConfiguration implements LedgerSetting {


+ 36
- 36
source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/LedgerMetadata.java View File

@@ -1,36 +1,36 @@
package com.jd.blockchain.ledger.core;
import com.jd.blockchain.binaryproto.DataContract;
import com.jd.blockchain.binaryproto.DataField;
import com.jd.blockchain.binaryproto.PrimitiveType;
import com.jd.blockchain.consts.DataCodes;
import com.jd.blockchain.crypto.HashDigest;
@DataContract(code = DataCodes.METADATA)
public interface LedgerMetadata {
/**
* 账本的初始化种子;
*
* @return
*/
@DataField(order = 1, primitiveType = PrimitiveType.BYTES)
byte[] getSeed();
/**
* 共识参与方的默克尔树的根;
*
* @return
*/
@DataField(order = 2, primitiveType = PrimitiveType.BYTES)
HashDigest getParticipantsHash();
/**
* 账本配置;
*
* @return
*/
@DataField(order = 3, refContract = true)
LedgerSetting getSetting();
}
//package com.jd.blockchain.ledger.core;
//
//import com.jd.blockchain.binaryproto.DataContract;
//import com.jd.blockchain.binaryproto.DataField;
//import com.jd.blockchain.binaryproto.PrimitiveType;
//import com.jd.blockchain.consts.DataCodes;
//import com.jd.blockchain.crypto.HashDigest;
//
//@DataContract(code = DataCodes.METADATA)
//public interface LedgerMetadata {
//
// /**
// * 账本的初始化种子;
// *
// * @return
// */
// @DataField(order = 1, primitiveType = PrimitiveType.BYTES)
// byte[] getSeed();
//
// /**
// * 共识参与方的默克尔树的根;
// *
// * @return
// */
// @DataField(order = 2, primitiveType = PrimitiveType.BYTES)
// HashDigest getParticipantsHash();
//
// /**
// * 账本配置;
// *
// * @return
// */
// @DataField(order = 3, refContract = true)
// LedgerSetting getSetting();
//
//}

+ 24
- 24
source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/LedgerSetting.java View File

@@ -1,24 +1,24 @@
package com.jd.blockchain.ledger.core;
import com.jd.blockchain.binaryproto.DataContract;
import com.jd.blockchain.binaryproto.DataField;
import com.jd.blockchain.binaryproto.PrimitiveType;
import com.jd.blockchain.consts.DataCodes;
import com.jd.blockchain.ledger.CryptoSetting;
import com.jd.blockchain.utils.Bytes;
@DataContract(code = DataCodes.METADATA_LEDGER_SETTING)
public interface LedgerSetting {
@DataField(order=0, primitiveType=PrimitiveType.TEXT)
String getConsensusProvider();
@DataField(order=1, primitiveType=PrimitiveType.BYTES)
Bytes getConsensusSetting();
@DataField(order=2, refContract=true)
CryptoSetting getCryptoSetting();
// PrivilegeModelSetting getPrivilegesModelSetting();
}
//package com.jd.blockchain.ledger.core;
//
//import com.jd.blockchain.binaryproto.DataContract;
//import com.jd.blockchain.binaryproto.DataField;
//import com.jd.blockchain.binaryproto.PrimitiveType;
//import com.jd.blockchain.consts.DataCodes;
//import com.jd.blockchain.ledger.CryptoSetting;
//import com.jd.blockchain.utils.Bytes;
//
//@DataContract(code = DataCodes.METADATA_LEDGER_SETTING)
//public interface LedgerSetting {
//
// @DataField(order=0, primitiveType=PrimitiveType.TEXT)
// String getConsensusProvider();
//
// @DataField(order=1, primitiveType=PrimitiveType.BYTES)
// Bytes getConsensusSetting();
//
// @DataField(order=2, refContract=true)
// CryptoSetting getCryptoSetting();
//
//// PrivilegeModelSetting getPrivilegesModelSetting();
//
//}

+ 14
- 14
source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/impl/LedgerQueryService.java View File

@@ -3,16 +3,7 @@ package com.jd.blockchain.ledger.core.impl;
import com.jd.blockchain.binaryproto.BinaryProtocol; import com.jd.blockchain.binaryproto.BinaryProtocol;
import com.jd.blockchain.binaryproto.PrimitiveType; import com.jd.blockchain.binaryproto.PrimitiveType;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.ledger.AccountHeader;
import com.jd.blockchain.ledger.BytesValue;
import com.jd.blockchain.ledger.KVDataEntry;
import com.jd.blockchain.ledger.KVDataObject;
import com.jd.blockchain.ledger.LedgerBlock;
import com.jd.blockchain.ledger.LedgerInfo;
import com.jd.blockchain.ledger.LedgerTransaction;
import com.jd.blockchain.ledger.ParticipantNode;
import com.jd.blockchain.ledger.TransactionState;
import com.jd.blockchain.ledger.UserInfo;
import com.jd.blockchain.ledger.*;
import com.jd.blockchain.ledger.core.ContractAccountSet; import com.jd.blockchain.ledger.core.ContractAccountSet;
import com.jd.blockchain.ledger.core.DataAccount; import com.jd.blockchain.ledger.core.DataAccount;
import com.jd.blockchain.ledger.core.DataAccountSet; import com.jd.blockchain.ledger.core.DataAccountSet;
@@ -50,10 +41,12 @@ public class LedgerQueryService implements BlockchainQueryService {
@Override @Override
public ParticipantNode[] getConsensusParticipants(HashDigest ledgerHash) { public ParticipantNode[] getConsensusParticipants(HashDigest ledgerHash) {
LedgerRepository ledger = ledgerService.getLedger(ledgerHash);
LedgerBlock block = ledger.getLatestBlock();
LedgerAdministration administration = ledger.getAdminAccount(block);
return administration.getParticipants();
return ledgerAdministration(ledgerHash).getParticipants();
}
@Override
public LedgerMetadata getLedgerMetadata(HashDigest ledgerHash) {
return ledgerAdministration(ledgerHash).getMetadata();
} }
@Override @Override
@@ -338,4 +331,11 @@ public class LedgerQueryService implements BlockchainQueryService {
int pages[] = QueryUtil.calFromIndexAndCount(fromIndex,count,(int)contractAccountSet.getTotalCount()); int pages[] = QueryUtil.calFromIndexAndCount(fromIndex,count,(int)contractAccountSet.getTotalCount());
return contractAccountSet.getAccounts(pages[0],pages[1]); return contractAccountSet.getAccounts(pages[0],pages[1]);
} }
private LedgerAdministration ledgerAdministration(HashDigest ledgerHash) {
LedgerRepository ledger = ledgerService.getLedger(ledgerHash);
LedgerBlock block = ledger.getLatestBlock();
LedgerAdministration administration = ledger.getAdminAccount(block);
return administration;
}
} }

+ 2
- 8
source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/impl/LedgerRepositoryImpl.java View File

@@ -4,12 +4,7 @@ import com.jd.blockchain.binaryproto.BinaryProtocol;
import com.jd.blockchain.crypto.Crypto; import com.jd.blockchain.crypto.Crypto;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.HashFunction; import com.jd.blockchain.crypto.HashFunction;
import com.jd.blockchain.ledger.BlockBody;
import com.jd.blockchain.ledger.CryptoSetting;
import com.jd.blockchain.ledger.LedgerBlock;
import com.jd.blockchain.ledger.LedgerDataSnapshot;
import com.jd.blockchain.ledger.LedgerInitSetting;
import com.jd.blockchain.ledger.TransactionRequest;
import com.jd.blockchain.ledger.*;
import com.jd.blockchain.ledger.core.AccountAccessPolicy; import com.jd.blockchain.ledger.core.AccountAccessPolicy;
import com.jd.blockchain.ledger.core.ContractAccountSet; import com.jd.blockchain.ledger.core.ContractAccountSet;
import com.jd.blockchain.ledger.core.DataAccountSet; import com.jd.blockchain.ledger.core.DataAccountSet;
@@ -20,7 +15,6 @@ import com.jd.blockchain.ledger.core.LedgerDataSet;
import com.jd.blockchain.ledger.core.LedgerEditor; import com.jd.blockchain.ledger.core.LedgerEditor;
import com.jd.blockchain.ledger.core.LedgerException; import com.jd.blockchain.ledger.core.LedgerException;
import com.jd.blockchain.ledger.core.LedgerRepository; import com.jd.blockchain.ledger.core.LedgerRepository;
import com.jd.blockchain.ledger.core.LedgerSetting;
import com.jd.blockchain.ledger.core.LedgerTransactionContext; import com.jd.blockchain.ledger.core.LedgerTransactionContext;
import com.jd.blockchain.ledger.core.TransactionSet; import com.jd.blockchain.ledger.core.TransactionSet;
import com.jd.blockchain.ledger.core.UserAccountSet; import com.jd.blockchain.ledger.core.UserAccountSet;
@@ -486,7 +480,7 @@ public class LedgerRepositoryImpl implements LedgerRepository {
} }


static TransactionSet newTransactionSet(LedgerSetting ledgerSetting, String keyPrefix, static TransactionSet newTransactionSet(LedgerSetting ledgerSetting, String keyPrefix,
ExPolicyKVStorage ledgerExStorage, VersioningKVStorage ledgerVerStorage) {
ExPolicyKVStorage ledgerExStorage, VersioningKVStorage ledgerVerStorage) {
// TransactionSet transactionSet = new // TransactionSet transactionSet = new
// TransactionSet(ledgerSetting.getCryptoSetting(), // TransactionSet(ledgerSetting.getCryptoSetting(),
// PrefixAppender.prefix(TRANSACTION_SET_PREFIX, ledgerExStorage), // PrefixAppender.prefix(TRANSACTION_SET_PREFIX, ledgerExStorage),


+ 2
- 10
source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/impl/LedgerTransactionalEditor.java View File

@@ -5,17 +5,9 @@ import java.util.Stack;
import com.jd.blockchain.binaryproto.BinaryProtocol; import com.jd.blockchain.binaryproto.BinaryProtocol;
import com.jd.blockchain.crypto.Crypto; import com.jd.blockchain.crypto.Crypto;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.ledger.BlockBody;
import com.jd.blockchain.ledger.CryptoSetting;
import com.jd.blockchain.ledger.LedgerBlock;
import com.jd.blockchain.ledger.LedgerDataSnapshot;
import com.jd.blockchain.ledger.LedgerInitSetting;
import com.jd.blockchain.ledger.LedgerTransaction;
import com.jd.blockchain.ledger.TransactionRequest;
import com.jd.blockchain.ledger.TransactionState;
import com.jd.blockchain.ledger.*;
import com.jd.blockchain.ledger.core.LedgerDataSet; import com.jd.blockchain.ledger.core.LedgerDataSet;
import com.jd.blockchain.ledger.core.LedgerEditor; import com.jd.blockchain.ledger.core.LedgerEditor;
import com.jd.blockchain.ledger.core.LedgerSetting;
import com.jd.blockchain.ledger.core.LedgerTransactionContext; import com.jd.blockchain.ledger.core.LedgerTransactionContext;
import com.jd.blockchain.ledger.core.TransactionSet; import com.jd.blockchain.ledger.core.TransactionSet;
import com.jd.blockchain.storage.service.ExPolicyKVStorage; import com.jd.blockchain.storage.service.ExPolicyKVStorage;
@@ -67,7 +59,7 @@ public class LedgerTransactionalEditor implements LedgerEditor {
} }


public static LedgerTransactionalEditor createEditor(LedgerSetting ledgerSetting, LedgerBlock previousBlock, public static LedgerTransactionalEditor createEditor(LedgerSetting ledgerSetting, LedgerBlock previousBlock,
String ledgerKeyPrefix, ExPolicyKVStorage ledgerExStorage, VersioningKVStorage ledgerVerStorage) {
String ledgerKeyPrefix, ExPolicyKVStorage ledgerExStorage, VersioningKVStorage ledgerVerStorage) {
// new block; // new block;
LedgerBlockData currBlock = new LedgerBlockData(previousBlock.getHeight() + 1, previousBlock.getLedgerHash(), LedgerBlockData currBlock = new LedgerBlockData(previousBlock.getHeight() + 1, previousBlock.getLedgerHash(),
previousBlock.getHash()); previousBlock.getHash());


+ 6
- 16
source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/impl/handles/ContractLedgerContext.java View File

@@ -6,22 +6,7 @@ import java.util.List;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.jd.blockchain.contract.LedgerContext; import com.jd.blockchain.contract.LedgerContext;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.ledger.AccountHeader;
import com.jd.blockchain.ledger.BlockchainIdentity;
import com.jd.blockchain.ledger.BytesValue;
import com.jd.blockchain.ledger.BytesValueEntry;
import com.jd.blockchain.ledger.DataAccountKVSetOperation;
import com.jd.blockchain.ledger.DataAccountRegisterOperation;
import com.jd.blockchain.ledger.BytesValueType;
import com.jd.blockchain.ledger.KVDataEntry;
import com.jd.blockchain.ledger.LedgerBlock;
import com.jd.blockchain.ledger.LedgerInfo;
import com.jd.blockchain.ledger.LedgerTransaction;
import com.jd.blockchain.ledger.Operation;
import com.jd.blockchain.ledger.ParticipantNode;
import com.jd.blockchain.ledger.TransactionState;
import com.jd.blockchain.ledger.UserInfo;
import com.jd.blockchain.ledger.UserRegisterOperation;
import com.jd.blockchain.ledger.*;
import com.jd.blockchain.ledger.core.impl.OperationHandleContext; import com.jd.blockchain.ledger.core.impl.OperationHandleContext;
import com.jd.blockchain.transaction.BlockchainQueryService; import com.jd.blockchain.transaction.BlockchainQueryService;
import com.jd.blockchain.transaction.DataAccountKVSetOperationBuilder; import com.jd.blockchain.transaction.DataAccountKVSetOperationBuilder;
@@ -61,6 +46,11 @@ public class ContractLedgerContext implements LedgerContext {
return innerQueryService.getConsensusParticipants(ledgerHash); return innerQueryService.getConsensusParticipants(ledgerHash);
} }


@Override
public LedgerMetadata getLedgerMetadata(HashDigest ledgerHash) {
return innerQueryService.getLedgerMetadata(ledgerHash);
}

@Override @Override
public LedgerBlock getBlock(HashDigest ledgerHash, long height) { public LedgerBlock getBlock(HashDigest ledgerHash, long height) {
return innerQueryService.getBlock(ledgerHash, height); return innerQueryService.getBlock(ledgerHash, height);


+ 1
- 1
source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerAdminAccountTest.java View File

@@ -9,6 +9,7 @@ import static org.junit.Assert.assertTrue;
import java.util.Arrays; import java.util.Arrays;
import java.util.Random; import java.util.Random;


import com.jd.blockchain.ledger.LedgerMetadata;
import org.junit.Test; import org.junit.Test;


import com.jd.blockchain.crypto.AddressEncoding; import com.jd.blockchain.crypto.AddressEncoding;
@@ -20,7 +21,6 @@ import com.jd.blockchain.ledger.ParticipantNode;
import com.jd.blockchain.ledger.core.CryptoConfig; import com.jd.blockchain.ledger.core.CryptoConfig;
import com.jd.blockchain.ledger.core.LedgerAdminAccount; import com.jd.blockchain.ledger.core.LedgerAdminAccount;
import com.jd.blockchain.ledger.core.LedgerConfiguration; import com.jd.blockchain.ledger.core.LedgerConfiguration;
import com.jd.blockchain.ledger.core.LedgerMetadata;
import com.jd.blockchain.storage.service.utils.MemoryKVStorage; import com.jd.blockchain.storage.service.utils.MemoryKVStorage;
import com.jd.blockchain.transaction.ConsensusParticipantData; import com.jd.blockchain.transaction.ConsensusParticipantData;
import com.jd.blockchain.transaction.LedgerInitSettingData; import com.jd.blockchain.transaction.LedgerInitSettingData;


+ 2
- 2
source/ledger/ledger-core/src/test/java/test/com/jd/blockchain/ledger/LedgerMetaDataTest.java View File

@@ -7,6 +7,8 @@ import static org.junit.Assert.assertTrue;


import java.util.Random; import java.util.Random;


import com.jd.blockchain.ledger.LedgerMetadata;
import com.jd.blockchain.ledger.LedgerSetting;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;


@@ -21,8 +23,6 @@ import com.jd.blockchain.ledger.ParticipantNode;
import com.jd.blockchain.ledger.core.CryptoConfig; import com.jd.blockchain.ledger.core.CryptoConfig;
import com.jd.blockchain.ledger.core.LedgerAdminAccount; import com.jd.blockchain.ledger.core.LedgerAdminAccount;
import com.jd.blockchain.ledger.core.LedgerConfiguration; import com.jd.blockchain.ledger.core.LedgerConfiguration;
import com.jd.blockchain.ledger.core.LedgerMetadata;
import com.jd.blockchain.ledger.core.LedgerSetting;
import com.jd.blockchain.ledger.core.ParticipantCertData; import com.jd.blockchain.ledger.core.ParticipantCertData;
import com.jd.blockchain.utils.Bytes; import com.jd.blockchain.utils.Bytes;




+ 12
- 0
source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/CryptoProviderInfo.java View File

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

import com.jd.blockchain.crypto.CryptoAlgorithm;

public interface CryptoProviderInfo {
String getName();
CryptoAlgorithm[] getAlgorithms();
}

+ 36
- 0
source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/LedgerMetadata.java View File

@@ -0,0 +1,36 @@
package com.jd.blockchain.ledger;

import com.jd.blockchain.binaryproto.DataContract;
import com.jd.blockchain.binaryproto.DataField;
import com.jd.blockchain.binaryproto.PrimitiveType;
import com.jd.blockchain.consts.DataCodes;
import com.jd.blockchain.crypto.HashDigest;

@DataContract(code = DataCodes.METADATA)
public interface LedgerMetadata {

/**
* 账本的初始化种子;
*
* @return
*/
@DataField(order = 1, primitiveType = PrimitiveType.BYTES)
byte[] getSeed();

/**
* 共识参与方的默克尔树的根;
*
* @return
*/
@DataField(order = 2, primitiveType = PrimitiveType.BYTES)
HashDigest getParticipantsHash();

/**
* 账本配置;
*
* @return
*/
@DataField(order = 3, refContract = true)
LedgerSetting getSetting();

}

+ 24
- 0
source/ledger/ledger-model/src/main/java/com/jd/blockchain/ledger/LedgerSetting.java View File

@@ -0,0 +1,24 @@
package com.jd.blockchain.ledger;

import com.jd.blockchain.binaryproto.DataContract;
import com.jd.blockchain.binaryproto.DataField;
import com.jd.blockchain.binaryproto.PrimitiveType;
import com.jd.blockchain.consts.DataCodes;
import com.jd.blockchain.ledger.CryptoSetting;
import com.jd.blockchain.utils.Bytes;

@DataContract(code = DataCodes.METADATA_LEDGER_SETTING)
public interface LedgerSetting {

@DataField(order=0, primitiveType=PrimitiveType.TEXT)
String getConsensusProvider();

@DataField(order=1, primitiveType=PrimitiveType.BYTES)
Bytes getConsensusSetting();

@DataField(order=2, refContract=true)
CryptoSetting getCryptoSetting();

// PrivilegeModelSetting getPrivilegesModelSetting();

}

+ 8
- 0
source/ledger/ledger-model/src/main/java/com/jd/blockchain/transaction/BlockchainQueryService.java View File

@@ -36,6 +36,14 @@ public interface BlockchainQueryService {
*/ */
ParticipantNode[] getConsensusParticipants(HashDigest ledgerHash); ParticipantNode[] getConsensusParticipants(HashDigest ledgerHash);
/**
* 返回当前账本的元数据
*
* @param ledgerHash
* @return
*/
LedgerMetadata getLedgerMetadata(HashDigest ledgerHash);
/** /**
* 返回指定账本序号的区块; * 返回指定账本序号的区块;
* *


+ 1
- 1
source/ledger/ledger-model/src/test/java/test/com/jd/blockchain/ledger/data/ED25519SignatureTest.java View File

@@ -11,7 +11,7 @@ import com.jd.blockchain.utils.security.Ed25519Utils;


public class ED25519SignatureTest { public class ED25519SignatureTest {


@Test
// @Test
public void perfomanceTest() { public void perfomanceTest() {
Random rand = new Random(); Random rand = new Random();
byte[] data = new byte[64]; byte[] data = new byte[64];


+ 101
- 0
source/ledger/ledger-rpc/src/main/java/com/jd/blockchain/web/serializes/ByteArrayObjectJsonDeserializer.java View File

@@ -0,0 +1,101 @@
package com.jd.blockchain.web.serializes;

import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.JSONToken;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer;
import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.PubKey;
import com.jd.blockchain.crypto.SignatureDigest;
import com.jd.blockchain.utils.Bytes;
import com.jd.blockchain.utils.codec.Base58Utils;
import com.jd.blockchain.utils.io.BytesSlice;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Type;
import java.util.Map;

public class ByteArrayObjectJsonDeserializer extends JavaBeanDeserializer {

private ByteArrayObjectJsonDeserializer(Class<?> clazz) {
super(ParserConfig.global, clazz);
}

public static ByteArrayObjectJsonDeserializer getInstance(Class<?> clazz) {
return new ByteArrayObjectJsonDeserializer(clazz);
}

@SuppressWarnings("unchecked")
@Override
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
if (type instanceof Class && clazz.isAssignableFrom((Class<?>) type)) {
String parseText = parser.parseObject(String.class);
byte[] hashBytes = Base58Utils.decode(parseText);
if (clazz == HashDigest.class) {
return (T) new HashDigest(hashBytes);
} else if (clazz == PubKey.class) {
return (T) new HashDigest(hashBytes);
} else if (clazz == SignatureDigest.class) {
return (T) new SignatureDigest(hashBytes);
} else if (clazz == Bytes.class) {
return (T) new Bytes(hashBytes);
} else if (clazz == BytesSlice.class) {
return (T) new BytesSlice(hashBytes);
}

// else if (clazz == BytesValue.class) {
// ByteArrayObjectJsonSerializer.BytesValueJson valueJson = JSON.parseObject(parseText, ByteArrayObjectJsonSerializer.BytesValueJson.class);
// DataType dataType = valueJson.getType();
// Object dataVal = valueJson.getValue();
// byte[] bytes = null;
// switch (dataType) {
// case BYTES:
// bytes = ByteArray.fromHex((String) dataVal);
// break;
// case TEXT:
// bytes = ((String) dataVal).getBytes();
// break;
// case INT64:
// bytes = BytesUtils.toBytes((Long) dataVal);
// break;
// case JSON:
// bytes = ((String) dataVal).getBytes();
// break;
// }
// BytesValue bytesValue = new BytesValueImpl(dataType, bytes);
// return (T) bytesValue;
// }
}
return (T) parser.parse(fieldName);
}

@Override
public Object createInstance(Map<String, Object> map, ParserConfig config) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
if (map == null || map.isEmpty()) {
return null;
}
for (Map.Entry<String, Object> entry : map.entrySet()) {
Object value = entry.getValue();
if (value instanceof String) {
byte[] hashBytes = Base58Utils.decode((String) value);
if (clazz == HashDigest.class) {
return new HashDigest(hashBytes);
} else if (clazz == PubKey.class) {
return new PubKey(hashBytes);
} else if (clazz == SignatureDigest.class) {
return new SignatureDigest(hashBytes);
} else if (clazz == Bytes.class) {
return new Bytes(hashBytes);
} else if (clazz == BytesSlice.class) {
return new BytesSlice(hashBytes);
}
}
}
return null;
}

@Override
public int getFastMatchToken() {
return JSONToken.LBRACE;
}
}

+ 120
- 0
source/ledger/ledger-rpc/src/main/java/com/jd/blockchain/web/serializes/ByteArrayObjectJsonSerializer.java View File

@@ -0,0 +1,120 @@
package com.jd.blockchain.web.serializes;

import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;
import com.jd.blockchain.binaryproto.DataType;
import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.PubKey;
import com.jd.blockchain.crypto.SignatureDigest;
import com.jd.blockchain.utils.Bytes;
import com.jd.blockchain.utils.codec.Base58Utils;
import com.jd.blockchain.utils.io.BytesSlice;

import java.lang.reflect.Type;

public class ByteArrayObjectJsonSerializer implements ObjectSerializer {

private Class<?> clazz;

private ByteArrayObjectJsonSerializer(Class<?> clazz) {
this.clazz = clazz;
}

public static ByteArrayObjectJsonSerializer getInstance(Class<?> clazz) {
return new ByteArrayObjectJsonSerializer(clazz);
}

@Override
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) {
if (object.getClass() != clazz) {
serializer.writeNull();
return;
}
if (object instanceof HashDigest) {
serializer.write(new HashDigestJson(((HashDigest) object).toBase58()));
} else if (object instanceof PubKey) {
serializer.write(new HashDigestJson(((PubKey) object).toBase58()));
} else if (object instanceof SignatureDigest) {
serializer.write(new HashDigestJson(((SignatureDigest) object).toBase58()));
} else if (object instanceof Bytes) {
serializer.write(new HashDigestJson(((Bytes) object).toBase58()));
} else if (object instanceof BytesSlice) {
serializer.write(Base58Utils.encode(((BytesSlice) object).toBytes()));
}

// else if (object instanceof BytesValue) {
// DataType dataType = ((BytesValue) object).getType();
// BytesSlice bytesValue = ((BytesValue) object).getValue();
// Object realVal;
// switch (dataType) {
// case NIL:
// realVal = null;
// break;
// case TEXT:
// realVal = bytesValue.getString();
// break;
// case BYTES:
// realVal = ByteArray.toHex(bytesValue.toBytes());
// break;
// case INT32:
// realVal = bytesValue.getInt();
// break;
// case INT64:
// realVal = bytesValue.getLong();
// break;
// case JSON:
// realVal = bytesValue.getString();
// break;
// default:
// realVal = ByteArray.toHex(bytesValue.toBytes());
// break;
// }
// serializer.write(new BytesValueJson(dataType, realVal));
// }
}

private static class HashDigestJson {

String value;

public HashDigestJson(String value) {
this.value = value;
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}
}

public static class BytesValueJson {

public BytesValueJson(DataType type, Object value) {
this.type = type;
this.value = value;
}

DataType type;

Object value;

public DataType getType() {
return type;
}

public void setType(DataType type) {
this.type = type;
}

public Object getValue() {
return value;
}

public void setValue(Object value) {
this.value = value;
}
}
}

+ 41
- 0
source/ledger/ledger-rpc/src/main/java/com/jd/blockchain/web/serializes/ByteArrayObjectUtil.java View File

@@ -0,0 +1,41 @@
/**
* Copyright: Copyright 2016-2020 JD.COM All Right Reserved
* FileName: com.jd.blockchain.web.serializes.ByteArrayObjectUtil
* Author: shaozhuguang
* Department: Y事业部
* Date: 2019/3/27 上午11:23
* Description:
*/
package com.jd.blockchain.web.serializes;

import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.PubKey;
import com.jd.blockchain.crypto.SignatureDigest;
import com.jd.blockchain.utils.Bytes;
import com.jd.blockchain.utils.io.BytesSlice;
import com.jd.blockchain.utils.serialize.json.JSONSerializeUtils;

/**
*
* @author shaozhuguang
* @create 2019/3/27
* @since 1.0.0
*/

public class ByteArrayObjectUtil {

public static final Class<?>[] BYTEARRAY_JSON_SERIALIZE_CLASS = new Class<?>[] {
HashDigest.class,
PubKey.class,
SignatureDigest.class,
Bytes.class,
BytesSlice.class};

public static void init() {
for (Class<?> byteArrayClass : BYTEARRAY_JSON_SERIALIZE_CLASS) {
JSONSerializeUtils.configSerialization(byteArrayClass,
ByteArrayObjectJsonSerializer.getInstance(byteArrayClass),
ByteArrayObjectJsonDeserializer.getInstance(byteArrayClass));
}
}
}

+ 11
- 19
source/peer/src/main/java/com/jd/blockchain/peer/web/LedgerQueryController.java View File

@@ -1,5 +1,7 @@
package com.jd.blockchain.peer.web; package com.jd.blockchain.peer.web;
import com.jd.blockchain.ledger.*;
import com.jd.blockchain.ledger.core.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@@ -10,25 +12,6 @@ import org.springframework.web.bind.annotation.RestController;
import com.jd.blockchain.binaryproto.BinaryProtocol; import com.jd.blockchain.binaryproto.BinaryProtocol;
import com.jd.blockchain.binaryproto.PrimitiveType; import com.jd.blockchain.binaryproto.PrimitiveType;
import com.jd.blockchain.crypto.HashDigest; import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.ledger.AccountHeader;
import com.jd.blockchain.ledger.BytesValue;
import com.jd.blockchain.ledger.KVDataEntry;
import com.jd.blockchain.ledger.KVDataObject;
import com.jd.blockchain.ledger.LedgerBlock;
import com.jd.blockchain.ledger.LedgerInfo;
import com.jd.blockchain.ledger.LedgerTransaction;
import com.jd.blockchain.ledger.ParticipantNode;
import com.jd.blockchain.ledger.TransactionState;
import com.jd.blockchain.ledger.UserInfo;
import com.jd.blockchain.ledger.core.ContractAccountSet;
import com.jd.blockchain.ledger.core.DataAccount;
import com.jd.blockchain.ledger.core.DataAccountSet;
import com.jd.blockchain.ledger.core.LedgerAdministration;
import com.jd.blockchain.ledger.core.LedgerRepository;
import com.jd.blockchain.ledger.core.LedgerService;
import com.jd.blockchain.ledger.core.ParticipantCertData;
import com.jd.blockchain.ledger.core.TransactionSet;
import com.jd.blockchain.ledger.core.UserAccountSet;
import com.jd.blockchain.transaction.BlockchainQueryService; import com.jd.blockchain.transaction.BlockchainQueryService;
import com.jd.blockchain.utils.Bytes; import com.jd.blockchain.utils.Bytes;
import com.jd.blockchain.utils.QueryUtil; import com.jd.blockchain.utils.QueryUtil;
@@ -79,6 +62,15 @@ public class LedgerQueryController implements BlockchainQueryService {
return null; return null;
} }
@RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/metadata")
@Override
public LedgerMetadata getLedgerMetadata(@PathVariable(name = "ledgerHash") HashDigest ledgerHash) {
LedgerRepository ledger = ledgerService.getLedger(ledgerHash);
LedgerAdministration ledgerAdministration = ledger.getAdminInfo();
LedgerMetadata ledgerMetadata = ledgerAdministration.getMetadata();
return ledgerMetadata;
}
@RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/blocks/height/{blockHeight}") @RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/blocks/height/{blockHeight}")
@Override @Override
public LedgerBlock getBlock(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, public LedgerBlock getBlock(@PathVariable(name = "ledgerHash") HashDigest ledgerHash,


+ 2
- 19
source/peer/src/main/java/com/jd/blockchain/peer/web/PeerWebServerConfigurer.java View File

@@ -2,22 +2,16 @@ package com.jd.blockchain.peer.web;
import java.util.List; import java.util.List;
import com.jd.blockchain.utils.io.BytesSlice;
import com.jd.blockchain.web.converters.BinaryMessageConverter; import com.jd.blockchain.web.converters.BinaryMessageConverter;
import com.jd.blockchain.web.converters.HashDigestInputConverter; import com.jd.blockchain.web.converters.HashDigestInputConverter;
import com.jd.blockchain.web.serializes.ByteArrayObjectUtil;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry; import org.springframework.format.FormatterRegistry;
import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.crypto.PubKey;
import com.jd.blockchain.crypto.SignatureDigest;
import com.jd.blockchain.crypto.serialize.ByteArrayObjectDeserializer;
import com.jd.blockchain.crypto.serialize.ByteArrayObjectSerializer;
import com.jd.blockchain.utils.Bytes;
import com.jd.blockchain.utils.io.ByteArray; import com.jd.blockchain.utils.io.ByteArray;
import com.jd.blockchain.utils.serialize.json.JSONSerializeUtils; import com.jd.blockchain.utils.serialize.json.JSONSerializeUtils;
import com.jd.blockchain.utils.web.model.JsonWebResponseMessageConverter; import com.jd.blockchain.utils.web.model.JsonWebResponseMessageConverter;
@@ -25,13 +19,6 @@ import com.jd.blockchain.utils.web.model.JsonWebResponseMessageConverter;
@Configuration @Configuration
public class PeerWebServerConfigurer implements WebMvcConfigurer { public class PeerWebServerConfigurer implements WebMvcConfigurer {
private static final Class<?>[] BYTEARRAY_JSON_SERIALIZE_CLASS = new Class<?>[] {
HashDigest.class,
PubKey.class,
SignatureDigest.class,
Bytes.class,
BytesSlice.class};
static { static {
JSONSerializeUtils.disableCircularReferenceDetect(); JSONSerializeUtils.disableCircularReferenceDetect();
JSONSerializeUtils.configStringSerializer(ByteArray.class); JSONSerializeUtils.configStringSerializer(ByteArray.class);
@@ -59,10 +46,6 @@ public class PeerWebServerConfigurer implements WebMvcConfigurer {
} }
private void initByteArrayJsonSerialize() { private void initByteArrayJsonSerialize() {
for (Class<?> byteArrayClass : BYTEARRAY_JSON_SERIALIZE_CLASS) {
JSONSerializeUtils.configSerialization(byteArrayClass,
ByteArrayObjectSerializer.getInstance(byteArrayClass),
ByteArrayObjectDeserializer.getInstance(byteArrayClass));
}
ByteArrayObjectUtil.init();
} }
} }

+ 13
- 8
source/pom.xml View File

@@ -32,12 +32,10 @@
<module>storage</module> <module>storage</module>
<module>gateway</module> <module>gateway</module>
<module>peer</module> <module>peer</module>
<module>state-transfer</module>
<module>sdk</module> <module>sdk</module>
<module>tools</module> <module>tools</module>
<module>test</module> <module>test</module>
<module>deployment</module> <module>deployment</module>
<module>stp</module>
</modules> </modules>


<properties> <properties>
@@ -281,12 +279,6 @@
<artifactId>bcprov-jdk15on</artifactId> <artifactId>bcprov-jdk15on</artifactId>
<version>1.61</version> <version>1.61</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.bouncycastle/bcpkix-jdk15on -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.61</version>
</dependency>


<dependency> <dependency>
<groupId>io.nats</groupId> <groupId>io.nats</groupId>
@@ -306,6 +298,19 @@
<version>4.1</version> <version>4.1</version>
</dependency> </dependency>


<!-- jar包扫描 -->
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.10</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>


+ 113
- 0
source/sdk/sdk-base/src/main/java/com/jd/blockchain/sdk/LedgerInitSettings.java View File

@@ -0,0 +1,113 @@
package com.jd.blockchain.sdk;


import com.jd.blockchain.consensus.ConsensusSettings;
import com.jd.blockchain.crypto.HashDigest;
import com.jd.blockchain.ledger.CryptoSetting;
import com.jd.blockchain.ledger.ParticipantNode;

/**
* 账本初始化配置
*
* @author shaozhuguang
* @date 2019-04-23
* @since 1.0.0
*
*/
public class LedgerInitSettings {

/**
* 账本初始化种子
*/
private String seed;

/**
* 共识参与方的默克尔树的根;
*/
private HashDigest participantsHash;

/**
* 算法配置
*/
private CryptoSetting cryptoSetting;

/**
* 共识协议
*/
private int consensusProtocol;

/**
* 共识配置
*/
private ConsensusSettings consensusSettings;

/**
* 共识参与方
*/
private ParticipantNode[] participantNodes;

public void setSeed(String seed) {
this.seed = seed;
}

public String getSeed() {
return seed;
}

public HashDigest getParticipantsHash() {
return participantsHash;
}

public void setParticipantsHash(HashDigest participantsHash) {
this.participantsHash = participantsHash;
}

public CryptoSetting getCryptoSetting() {
return cryptoSetting;
}

public void setCryptoSetting(CryptoSetting cryptoSetting) {
this.cryptoSetting = cryptoSetting;
}

public int getConsensusProtocol() {
return consensusProtocol;
}

public void setConsensusProtocol(int consensusProtocol) {
this.consensusProtocol = consensusProtocol;
}

public ConsensusSettings getConsensusSettings() {
return consensusSettings;
}

public void setConsensusSettings(ConsensusSettings consensusSettings) {
this.consensusSettings = consensusSettings;
}

public ParticipantNode[] getParticipantNodes() {
return participantNodes;
}

public void setParticipantNodes(ParticipantNode[] participantNodes) {
this.participantNodes = participantNodes;
}

public enum CONSENSUS_PROTOCOL {
UNKNOWN(0),
BFTSMART(1),
MSGQUEUE(2),
;

private int code;

CONSENSUS_PROTOCOL(int code) {
this.code = code;
}

public int code() {
return code;
}
}
}

+ 6
- 1
source/sdk/sdk-base/src/main/java/com/jd/blockchain/sdk/proxy/BlockchainServiceProxy.java View File

@@ -37,7 +37,12 @@ public abstract class BlockchainServiceProxy implements BlockchainService {
return getQueryService(ledgerHash).getConsensusParticipants(ledgerHash); return getQueryService(ledgerHash).getConsensusParticipants(ledgerHash);
} }


@Override
@Override
public LedgerMetadata getLedgerMetadata(HashDigest ledgerHash) {
return getQueryService(ledgerHash).getLedgerMetadata(ledgerHash);
}

@Override
public LedgerBlock getBlock(HashDigest ledgerHash, long height) { public LedgerBlock getBlock(HashDigest ledgerHash, long height) {
return getQueryService(ledgerHash).getBlock(ledgerHash, height); return getQueryService(ledgerHash).getBlock(ledgerHash, height);
} }


+ 11
- 0
source/sdk/sdk-base/src/main/java/com/jd/blockchain/sdk/proxy/HttpBlockchainQueryService.java View File

@@ -204,6 +204,17 @@ public interface HttpBlockchainQueryService extends BlockchainExtendQueryService
@Override @Override
ParticipantNode[] getConsensusParticipants(@PathParam(name="ledgerHash", converter=HashDigestToStringConverter.class) HashDigest ledgerHash); ParticipantNode[] getConsensusParticipants(@PathParam(name="ledgerHash", converter=HashDigestToStringConverter.class) HashDigest ledgerHash);



/**
* 返回指定账本的元数据
*
* @param ledgerHash
* @return
*/
@HttpAction(method=HttpMethod.GET, path="ledgers/{ledgerHash}/metadata")
@Override
LedgerMetadata getLedgerMetadata(@PathParam(name="ledgerHash", converter=HashDigestToStringConverter.class) HashDigest ledgerHash);

/** /**
* 返回指定账本序号的区块; * 返回指定账本序号的区块;
* *


+ 1
- 1
source/sdk/sdk-base/src/main/java/com/jd/blockchain/sdk/service/NodeSigningAppender.java View File

@@ -72,7 +72,7 @@ public class NodeSigningAppender implements TransactionService {


// 计算交易哈希; // 计算交易哈希;
byte[] nodeRequestBytes = BinaryProtocol.encode(txMessage, TransactionRequest.class); byte[] nodeRequestBytes = BinaryProtocol.encode(txMessage, TransactionRequest.class);
HashFunction hashFunc = Crypto.getHashFunction(signAlgorithm);
HashFunction hashFunc = Crypto.getHashFunction(this.hashAlgorithm);
HashDigest txHash = hashFunc.hash(nodeRequestBytes); HashDigest txHash = hashFunc.hash(nodeRequestBytes);
txMessage.setHash(txHash); txMessage.setHash(txHash);




+ 6
- 0
source/sdk/sdk-client/pom.xml View File

@@ -14,5 +14,11 @@
<artifactId>sdk-base</artifactId> <artifactId>sdk-base</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.jd.blockchain</groupId>
<artifactId>ledger-rpc</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

+ 32
- 5
source/sdk/sdk-client/src/main/java/com/jd/blockchain/sdk/client/GatewayServiceFactory.java View File

@@ -3,15 +3,16 @@ package com.jd.blockchain.sdk.client;
import java.io.Closeable; import java.io.Closeable;
import com.jd.blockchain.binaryproto.BinaryProtocol; import com.jd.blockchain.binaryproto.BinaryProtocol;
import com.jd.blockchain.binaryproto.DataContractRegistry;
import com.jd.blockchain.consensus.ClientIdentification;
import com.jd.blockchain.consensus.ClientIdentifications;
import com.jd.blockchain.consensus.action.ActionRequest;
import com.jd.blockchain.consensus.action.ActionResponse;
import com.jd.blockchain.crypto.Crypto; import com.jd.blockchain.crypto.Crypto;
import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.PrivKey;
import com.jd.blockchain.crypto.SignatureDigest; import com.jd.blockchain.crypto.SignatureDigest;
import com.jd.blockchain.crypto.SignatureFunction; import com.jd.blockchain.crypto.SignatureFunction;
import com.jd.blockchain.ledger.BlockchainKeypair;
import com.jd.blockchain.ledger.DigitalSignature;
import com.jd.blockchain.ledger.TransactionContent;
import com.jd.blockchain.ledger.TransactionRequest;
import com.jd.blockchain.ledger.TransactionResponse;
import com.jd.blockchain.ledger.*;
import com.jd.blockchain.sdk.BlockchainService; import com.jd.blockchain.sdk.BlockchainService;
import com.jd.blockchain.sdk.BlockchainServiceFactory; import com.jd.blockchain.sdk.BlockchainServiceFactory;
import com.jd.blockchain.sdk.proxy.HttpBlockchainQueryService; import com.jd.blockchain.sdk.proxy.HttpBlockchainQueryService;
@@ -24,6 +25,7 @@ import com.jd.blockchain.utils.http.agent.ServiceConnection;
import com.jd.blockchain.utils.http.agent.ServiceConnectionManager; import com.jd.blockchain.utils.http.agent.ServiceConnectionManager;
import com.jd.blockchain.utils.http.agent.ServiceEndpoint; import com.jd.blockchain.utils.http.agent.ServiceEndpoint;
import com.jd.blockchain.utils.net.NetworkAddress; import com.jd.blockchain.utils.net.NetworkAddress;
import com.jd.blockchain.web.serializes.ByteArrayObjectUtil;
public class GatewayServiceFactory implements BlockchainServiceFactory, Closeable { public class GatewayServiceFactory implements BlockchainServiceFactory, Closeable {
@@ -33,6 +35,31 @@ public class GatewayServiceFactory implements BlockchainServiceFactory, Closeabl
private BlockchainService blockchainService; private BlockchainService blockchainService;
static {
DataContractRegistry.register(TransactionContent.class);
DataContractRegistry.register(TransactionContentBody.class);
DataContractRegistry.register(TransactionRequest.class);
DataContractRegistry.register(NodeRequest.class);
DataContractRegistry.register(EndpointRequest.class);
DataContractRegistry.register(TransactionResponse.class);
DataContractRegistry.register(DataAccountKVSetOperation.class);
DataContractRegistry.register(DataAccountKVSetOperation.KVWriteEntry.class);
DataContractRegistry.register(Operation.class);
DataContractRegistry.register(ContractCodeDeployOperation.class);
DataContractRegistry.register(ContractEventSendOperation.class);
DataContractRegistry.register(DataAccountRegisterOperation.class);
DataContractRegistry.register(UserRegisterOperation.class);
DataContractRegistry.register(ActionRequest.class);
DataContractRegistry.register(ActionResponse.class);
DataContractRegistry.register(ClientIdentifications.class);
DataContractRegistry.register(ClientIdentification.class);
ByteArrayObjectUtil.init();
}
protected GatewayServiceFactory(ServiceEndpoint gatewayEndpoint, BlockchainKeypair userKey) { protected GatewayServiceFactory(ServiceEndpoint gatewayEndpoint, BlockchainKeypair userKey) {
httpConnectionManager = new ServiceConnectionManager(); httpConnectionManager = new ServiceConnectionManager();
this.userKey = userKey; this.userKey = userKey;


+ 0
- 13
source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_Query_Test_.java View File

@@ -19,8 +19,6 @@ import com.jd.blockchain.crypto.HashFunction;
import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.PubKey;
import com.jd.blockchain.crypto.SignatureDigest; import com.jd.blockchain.crypto.SignatureDigest;
import com.jd.blockchain.crypto.SignatureFunction; import com.jd.blockchain.crypto.SignatureFunction;
import com.jd.blockchain.crypto.serialize.ByteArrayObjectDeserializer;
import com.jd.blockchain.crypto.serialize.ByteArrayObjectSerializer;
import com.jd.blockchain.ledger.AccountHeader; import com.jd.blockchain.ledger.AccountHeader;
import com.jd.blockchain.ledger.BlockchainKeyGenerator; import com.jd.blockchain.ledger.BlockchainKeyGenerator;
import com.jd.blockchain.ledger.BlockchainKeypair; import com.jd.blockchain.ledger.BlockchainKeypair;
@@ -53,17 +51,6 @@ import com.jd.blockchain.utils.serialize.json.JSONSerializeUtils;


public class SDK_GateWay_Query_Test_ { public class SDK_GateWay_Query_Test_ {


private static Class<?>[] byteArrayClasss = new Class<?>[] { HashDigest.class, PubKey.class,
SignatureDigest.class };

static {
for (Class<?> byteArrayClass : byteArrayClasss) {
JSONSerializeUtils.configSerialization(byteArrayClass,
ByteArrayObjectSerializer.getInstance(byteArrayClass),
ByteArrayObjectDeserializer.getInstance(byteArrayClass));
}
}

private BlockchainKeypair CLIENT_CERT = null; private BlockchainKeypair CLIENT_CERT = null;


private String GATEWAY_IPADDR = null; private String GATEWAY_IPADDR = null;


+ 30
- 1
source/storage/storage-composite/pom.xml View File

@@ -14,7 +14,7 @@
<artifactId>storage-service</artifactId> <artifactId>storage-service</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<!--<dependency>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>storage-redis</artifactId> <artifactId>storage-redis</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
@@ -24,6 +24,35 @@
<artifactId>storage-rocksdb</artifactId> <artifactId>storage-rocksdb</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.jd.blockchain</groupId>
<artifactId>storage-tikv</artifactId>
<version>${project.version}</version>
</dependency>-->
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>

<!--<dependency> <!--<dependency>
<groupId>org.rocksdb</groupId> <groupId>org.rocksdb</groupId>
<artifactId>rocksdbjni</artifactId> <artifactId>rocksdbjni</artifactId>


+ 88
- 64
source/storage/storage-composite/src/main/java/com/jd/blockchain/storage/service/impl/composite/CompositeConnectionFactory.java View File

@@ -1,76 +1,100 @@
package com.jd.blockchain.storage.service.impl.composite; package com.jd.blockchain.storage.service.impl.composite;


import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;


import com.jd.blockchain.storage.service.DbConnection; import com.jd.blockchain.storage.service.DbConnection;
import com.jd.blockchain.storage.service.DbConnectionFactory; import com.jd.blockchain.storage.service.DbConnectionFactory;
import com.jd.blockchain.storage.service.impl.redis.JedisConnection;
import com.jd.blockchain.storage.service.impl.redis.RedisConnectionFactory;
import com.jd.blockchain.storage.service.impl.rocksdb.RocksDBConnection;
import com.jd.blockchain.storage.service.impl.rocksdb.RocksDBConnectionFactory;
//import com.jd.blockchain.storage.service.utils.MemoryBasedDb;
import com.jd.blockchain.storage.service.utils.MemoryDBConn;
import com.jd.blockchain.storage.service.utils.MemoryDBConnFactory;
import org.reflections.Reflections;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;




public class CompositeConnectionFactory implements DbConnectionFactory { public class CompositeConnectionFactory implements DbConnectionFactory {


private static final RocksDBConnectionFactory rocksDBConnFactory = new RocksDBConnectionFactory();

private static final RedisConnectionFactory redisConnFactory = new RedisConnectionFactory();

private static final MemoryDBConnFactory memoryConnFactory = new MemoryDBConnFactory();

private static final String CONN_PREFIX_REDIS = "redis://";

private static final String CONN_PREFIX_ROCKSDB = "rocksdb://";

private static final String CONN_PREFIX_MEMORY = "memory://";

private final Map<String, DbConnection> connections = new ConcurrentHashMap<>();

@Override
public DbConnection connect(String dbUri) {
return connect(dbUri, null);
}

@Override
public DbConnection connect(String dbConnectionString, String password) {
if (!dbConnectionString.startsWith(CONN_PREFIX_REDIS) &&
!dbConnectionString.startsWith(CONN_PREFIX_ROCKSDB) &&
!dbConnectionString.startsWith(CONN_PREFIX_MEMORY)){
throw new IllegalArgumentException("Illegal format of composite db connection string!");
}

if (dbConnectionString.startsWith(CONN_PREFIX_REDIS)) {
return redisConnFactory.connect(dbConnectionString, password);
} else if (dbConnectionString.startsWith(CONN_PREFIX_ROCKSDB)) {
return rocksDBConnFactory.connect(dbConnectionString, password);
} else if (dbConnectionString.startsWith(CONN_PREFIX_MEMORY)) {
return memoryConnFactory.connect(dbConnectionString, password);
}
return null;
}

@Override
public void close() {
for (DbConnection dbConnection : connections.values()) {
if (dbConnection.getClass().equals(JedisConnection.class)) {
((JedisConnection)dbConnection).close();
}
else if (dbConnection.getClass().equals(RocksDBConnection.class)) {
((RocksDBConnection)dbConnection).dbClose();
}
else if (dbConnection.getClass().equals(MemoryDBConn.class)) {
((MemoryDBConn)dbConnection).close();
}
}
connections.clear();
}

@Override
public boolean support(String scheme) {
return rocksDBConnFactory.support(scheme) || redisConnFactory.support(scheme) || memoryConnFactory.support(scheme);
}
// SPI的方式,需要初始化对应的Factory
private static final Map<String, DbConnectionFactory> connectionFactoryMap = new ConcurrentHashMap<>();

private static Logger LOGGER = LoggerFactory.getLogger(CompositeConnectionFactory.class);

public CompositeConnectionFactory() {
init();
}

private void init() {
// 初始化所有实现类
Reflections reflections = new Reflections("com.jd.blockchain.storage.service");

Set<Class<? extends DbConnectionFactory>> connectionSet =
reflections.getSubTypesOf(DbConnectionFactory.class);

for (Class<? extends DbConnectionFactory> clazz : connectionSet) {
if (clazz.equals(CompositeConnectionFactory.class)) {
continue;
} else {
try {
// 根据class生成对象
DbConnectionFactory dbConnectionFactory = clazz.newInstance();
String dbPrefix = dbConnectionFactory.dbPrefix();
if (dbPrefix != null && dbPrefix.length() > 0 &&
!connectionFactoryMap.containsKey(dbPrefix)) {
connectionFactoryMap.put(dbPrefix, dbConnectionFactory);
}
} catch (Exception e) {
LOGGER.error("class:{%s} init error {%s}", clazz.getName(), e.getMessage());
}
}
}
}


@Override
public DbConnection connect(String dbUri) {
return connect(dbUri, null);
}

@Override
public DbConnection connect(String dbConnectionString, String password) {
if (connectionFactoryMap.isEmpty()) {
throw new IllegalArgumentException("DB connections is empty, please init first!");
}

for (Map.Entry<String, DbConnectionFactory> entry : connectionFactoryMap.entrySet()) {
String prefix = entry.getKey();
if (dbConnectionString.startsWith(prefix)) {
return entry.getValue().connect(dbConnectionString, password);
}
}

throw new IllegalArgumentException("Illegal format of composite db connection string!");
}

@Override
public void close() {
if (!connectionFactoryMap.isEmpty()) {
for (Map.Entry<String, DbConnectionFactory> entry : connectionFactoryMap.entrySet()) {
DbConnectionFactory dbConnectionFactory = entry.getValue();
dbConnectionFactory.close();
}
}
}

@Override
public String dbPrefix() {
return null;
}

@Override
public boolean support(String scheme) {
if (!connectionFactoryMap.isEmpty()) {
for (Map.Entry<String, DbConnectionFactory> entry : connectionFactoryMap.entrySet()) {
DbConnectionFactory dbConnectionFactory = entry.getValue();
if (dbConnectionFactory.support(scheme)) {
return true;
}
}
}
return false;
}
} }

+ 1
- 0
source/storage/storage-composite/src/main/java/com/jd/blockchain/storage/service/impl/composite/CompositeStorageConfiguration.java View File

@@ -12,6 +12,7 @@ import org.springframework.context.annotation.Configuration;
@Configuration @Configuration
@ComponentScan @ComponentScan
public class CompositeStorageConfiguration { public class CompositeStorageConfiguration {

@ConditionalOnMissingBean @ConditionalOnMissingBean
@Bean @Bean
public DbConnectionFactory compositeConnectionFactory() { public DbConnectionFactory compositeConnectionFactory() {


+ 110
- 112
source/storage/storage-composite/src/test/java/test/com/jd/blockchain/storage/service/impl/composite/CompositeConnectionFactoryTest.java View File

@@ -1,112 +1,110 @@
package test.com.jd.blockchain.storage.service.impl.composite;
import static org.junit.Assert.*;

import com.jd.blockchain.storage.service.DbConnection;
import com.jd.blockchain.storage.service.DbConnectionFactory;
import com.jd.blockchain.storage.service.ExPolicyKVStorage;
import com.jd.blockchain.storage.service.VersioningKVStorage;
import com.jd.blockchain.storage.service.impl.composite.CompositeConnectionFactory;
import com.jd.blockchain.storage.service.impl.rocksdb.RocksDBConnectionFactory;
import com.jd.blockchain.utils.Bytes;
import com.jd.blockchain.utils.io.BytesUtils;
import com.jd.blockchain.utils.io.FileUtils;

import org.junit.Test;

import java.io.File;
import java.util.regex.Pattern;

public class CompositeConnectionFactoryTest {

public static final Pattern URI_PATTER_REDIS = Pattern
.compile("^\\w+\\://(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})\\:\\d+(/\\d*(/.*)*)?$");

@Test
public void testRedisConnectionString() {
String connStr = "redis://192.168.86.130:6379/";
boolean match = URI_PATTER_REDIS.matcher(connStr).matches();
assertTrue(match);

connStr = "redis://192.168.86.131:6379/";
match = URI_PATTER_REDIS.matcher(connStr).matches();
assertTrue(match);

connStr = "redis://192.168.86.132:6379/";
match = URI_PATTER_REDIS.matcher(connStr).matches();
assertTrue(match);

connStr = "redis://192.168.86.133:6379/";
match = URI_PATTER_REDIS.matcher(connStr).matches();
assertTrue(match);
}

@Test
public void testRocksDbConnect() {
String dbUri = initEmptyDB("rocksdb_storage_test");
long expectedVersion;
try (CompositeConnectionFactory dbConnFactory = new CompositeConnectionFactory()) {
// try (CompositeConnectionFactory dbConnFactory = CompositeConnectionFactory.getInstance()) {
DbConnection conn = dbConnFactory.connect(dbUri);
VersioningKVStorage verStorage = conn.getStorageService().getVersioningKVStorage();
ExPolicyKVStorage exStorage = conn.getStorageService().getExPolicyKVStorage();

expectedVersion = test(verStorage);

test(exStorage);
}
}
private String initEmptyDB(String name) {
String currDir = FileUtils.getCurrentDir();
String dbDir = new File(currDir, name + ".db").getAbsolutePath();
FileUtils.deleteFile(dbDir);
String dbURI = "rocksdb://" + dbDir;
return dbURI;
}
private long test(VersioningKVStorage verStorage) {
String key = "k1";
long v = verStorage.getVersion(Bytes.fromString(key));
assertEquals(-1, v);
byte[] data = verStorage.get(Bytes.fromString(key), -1);
assertNull(data);
data = verStorage.get(Bytes.fromString(key), 0);
assertNull(data);
data = verStorage.get(Bytes.fromString(key), 1);
assertNull(data);

data = BytesUtils.toBytes("data");
v = verStorage.set(Bytes.fromString(key), data, -1);
assertEquals(0, v);
v = verStorage.set(Bytes.fromString(key), data, -1);
assertEquals(-1, v);
v = verStorage.set(Bytes.fromString(key), data, 0);
assertEquals(1, v);
return v;
}

private void test(ExPolicyKVStorage exStorage) {
String key = "kex";
assertFalse(exStorage.exist(Bytes.fromString(key)));

byte[] data = exStorage.get(Bytes.fromString(key));
assertNull(data);

data = BytesUtils.toBytes("data");
assertFalse(exStorage.set(Bytes.fromString(key), data, ExPolicyKVStorage.ExPolicy.EXISTING));

assertTrue(exStorage.set(Bytes.fromString(key), data, ExPolicyKVStorage.ExPolicy.NOT_EXISTING));
assertTrue(exStorage.exist(Bytes.fromString(key)));

assertFalse(exStorage.set(Bytes.fromString(key), data, ExPolicyKVStorage.ExPolicy.NOT_EXISTING));

assertTrue(exStorage.set(Bytes.fromString(key), data, ExPolicyKVStorage.ExPolicy.EXISTING));
assertTrue(exStorage.set(Bytes.fromString(key), data, ExPolicyKVStorage.ExPolicy.EXISTING));
assertFalse(exStorage.set(Bytes.fromString(key), data, ExPolicyKVStorage.ExPolicy.NOT_EXISTING));

assertTrue(exStorage.exist(Bytes.fromString(key)));

byte[] reloadData = exStorage.get(Bytes.fromString(key));
assertTrue(BytesUtils.equals(data, reloadData));
}


}
//package test.com.jd.blockchain.storage.service.impl.composite;
//import static org.junit.Assert.*;
//
//import com.jd.blockchain.storage.service.DbConnection;
//import com.jd.blockchain.storage.service.ExPolicyKVStorage;
//import com.jd.blockchain.storage.service.VersioningKVStorage;
//import com.jd.blockchain.storage.service.impl.composite.CompositeConnectionFactory;
//import com.jd.blockchain.utils.Bytes;
//import com.jd.blockchain.utils.io.BytesUtils;
//import com.jd.blockchain.utils.io.FileUtils;
//
//import org.junit.Test;
//
//import java.io.File;
//import java.util.regex.Pattern;
//
//public class CompositeConnectionFactoryTest {
//
// public static final Pattern URI_PATTER_REDIS = Pattern
// .compile("^\\w+\\://(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})\\:\\d+(/\\d*(/.*)*)?$");
//
// @Test
// public void testRedisConnectionString() {
// String connStr = "redis://192.168.86.130:6379/";
// boolean match = URI_PATTER_REDIS.matcher(connStr).matches();
// assertTrue(match);
//
// connStr = "redis://192.168.86.131:6379/";
// match = URI_PATTER_REDIS.matcher(connStr).matches();
// assertTrue(match);
//
// connStr = "redis://192.168.86.132:6379/";
// match = URI_PATTER_REDIS.matcher(connStr).matches();
// assertTrue(match);
//
// connStr = "redis://192.168.86.133:6379/";
// match = URI_PATTER_REDIS.matcher(connStr).matches();
// assertTrue(match);
// }
//
// @Test
// public void testRocksDbConnect() {
// String dbUri = initEmptyDB("rocksdb_storage_test");
// long expectedVersion;
// try (CompositeConnectionFactory dbConnFactory = new CompositeConnectionFactory()) {
//// try (CompositeConnectionFactory dbConnFactory = CompositeConnectionFactory.getInstance()) {
// DbConnection conn = dbConnFactory.connect(dbUri);
// VersioningKVStorage verStorage = conn.getStorageService().getVersioningKVStorage();
// ExPolicyKVStorage exStorage = conn.getStorageService().getExPolicyKVStorage();
//
// expectedVersion = test(verStorage);
//
// test(exStorage);
// }
// }
// private String initEmptyDB(String name) {
// String currDir = FileUtils.getCurrentDir();
// String dbDir = new File(currDir, name + ".db").getAbsolutePath();
// FileUtils.deleteFile(dbDir);
// String dbURI = "rocksdb://" + dbDir;
// return dbURI;
// }
// private long test(VersioningKVStorage verStorage) {
// String key = "k1";
// long v = verStorage.getVersion(Bytes.fromString(key));
// assertEquals(-1, v);
// byte[] data = verStorage.get(Bytes.fromString(key), -1);
// assertNull(data);
// data = verStorage.get(Bytes.fromString(key), 0);
// assertNull(data);
// data = verStorage.get(Bytes.fromString(key), 1);
// assertNull(data);
//
// data = BytesUtils.toBytes("data");
// v = verStorage.set(Bytes.fromString(key), data, -1);
// assertEquals(0, v);
// v = verStorage.set(Bytes.fromString(key), data, -1);
// assertEquals(-1, v);
// v = verStorage.set(Bytes.fromString(key), data, 0);
// assertEquals(1, v);
// return v;
// }
//
// private void test(ExPolicyKVStorage exStorage) {
// String key = "kex";
// assertFalse(exStorage.exist(Bytes.fromString(key)));
//
// byte[] data = exStorage.get(Bytes.fromString(key));
// assertNull(data);
//
// data = BytesUtils.toBytes("data");
// assertFalse(exStorage.set(Bytes.fromString(key), data, ExPolicyKVStorage.ExPolicy.EXISTING));
//
// assertTrue(exStorage.set(Bytes.fromString(key), data, ExPolicyKVStorage.ExPolicy.NOT_EXISTING));
// assertTrue(exStorage.exist(Bytes.fromString(key)));
//
// assertFalse(exStorage.set(Bytes.fromString(key), data, ExPolicyKVStorage.ExPolicy.NOT_EXISTING));
//
// assertTrue(exStorage.set(Bytes.fromString(key), data, ExPolicyKVStorage.ExPolicy.EXISTING));
// assertTrue(exStorage.set(Bytes.fromString(key), data, ExPolicyKVStorage.ExPolicy.EXISTING));
// assertFalse(exStorage.set(Bytes.fromString(key), data, ExPolicyKVStorage.ExPolicy.NOT_EXISTING));
//
// assertTrue(exStorage.exist(Bytes.fromString(key)));
//
// byte[] reloadData = exStorage.get(Bytes.fromString(key));
// assertTrue(BytesUtils.equals(data, reloadData));
// }
//
//
//}

+ 28
- 2
source/storage/storage-redis/src/main/java/com/jd/blockchain/storage/service/impl/redis/RedisConnectionFactory.java View File

@@ -1,6 +1,9 @@
package com.jd.blockchain.storage.service.impl.redis; package com.jd.blockchain.storage.service.impl.redis;


import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern; import java.util.regex.Pattern;


import com.jd.blockchain.storage.service.DbConnection; import com.jd.blockchain.storage.service.DbConnection;
@@ -17,13 +20,20 @@ public class RedisConnectionFactory implements DbConnectionFactory {
// public static final Pattern URI_PATTER = Pattern // public static final Pattern URI_PATTER = Pattern
// .compile("^\\w+\\://(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})\\:\\d+(/\\d+)?(/.*)*$"); // .compile("^\\w+\\://(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})\\:\\d+(/\\d+)?(/.*)*$");


private static final Map<String, DbConnection> connections = new ConcurrentHashMap<>();

@Override @Override
public DbConnection connect(String dbUri) { public DbConnection connect(String dbUri) {
return connect(dbUri, null); return connect(dbUri, null);
} }


@Override @Override
public DbConnection connect(String dbConnectionString, String password) {
public synchronized DbConnection connect(String dbConnectionString, String password) {

if (connections.containsKey(dbConnectionString)) {
// 暂不处理密码变化问题
return connections.get(dbConnectionString);
}


URI dbUri = URI.create(dbConnectionString); URI dbUri = URI.create(dbConnectionString);
if (!(dbUri.getScheme().equalsIgnoreCase("redis"))) { if (!(dbUri.getScheme().equalsIgnoreCase("redis"))) {
@@ -42,7 +52,9 @@ public class RedisConnectionFactory implements DbConnectionFactory {
int port = dbUri.getPort(); int port = dbUri.getPort();
int dbId = retriveDbIdFromPath(dbUri.getPath()); int dbId = retriveDbIdFromPath(dbUri.getPath());
JedisPool pool = new JedisPool(config, host, port, Protocol.DEFAULT_TIMEOUT, password, dbId, false); JedisPool pool = new JedisPool(config, host, port, Protocol.DEFAULT_TIMEOUT, password, dbId, false);
return new JedisConnection(pool);
JedisConnection jedisConnection = new JedisConnection(pool);
connections.put(dbConnectionString, jedisConnection);
return jedisConnection;
} }


/** /**
@@ -71,6 +83,11 @@ public class RedisConnectionFactory implements DbConnectionFactory {
return dbId; return dbId;
} }


@Override
public String dbPrefix() {
return "redis://";
}

@Override @Override
public boolean support(String scheme) { public boolean support(String scheme) {
return RedisConsts.URI_SCHEME.equalsIgnoreCase(scheme); return RedisConsts.URI_SCHEME.equalsIgnoreCase(scheme);
@@ -79,5 +96,14 @@ public class RedisConnectionFactory implements DbConnectionFactory {
@Override @Override
public void close() { public void close() {
// TODO:  未实现连接池的关闭; // TODO:  未实现连接池的关闭;
if (!connections.isEmpty()) {
for (Map.Entry<String, DbConnection> entry : connections.entrySet()) {
try {
entry.getValue().close();
} catch (IOException e) {
// 打印关闭异常日志
}
}
}
} }
} }

+ 6
- 1
source/storage/storage-rocksdb/src/main/java/com/jd/blockchain/storage/service/impl/rocksdb/RocksDBConnectionFactory.java View File

@@ -46,7 +46,7 @@ public class RocksDBConnectionFactory implements DbConnectionFactory {
String.format("Not supported db connection string with scheme \"%s\"!", dbUri.getScheme())); String.format("Not supported db connection string with scheme \"%s\"!", dbUri.getScheme()));
} }


String uriHead = URI_SCHEME + "://";
String uriHead = dbPrefix();
int beginIndex = dbConnectionString.indexOf(uriHead); int beginIndex = dbConnectionString.indexOf(uriHead);
String dbPath = dbConnectionString.substring(beginIndex + uriHead.length()); String dbPath = dbConnectionString.substring(beginIndex + uriHead.length());
if (!dbPath.startsWith(File.separator)) { if (!dbPath.startsWith(File.separator)) {
@@ -67,6 +67,11 @@ public class RocksDBConnectionFactory implements DbConnectionFactory {
} }




@Override
public String dbPrefix() {
return URI_SCHEME + "://";
}

@Override @Override
public boolean support(String scheme) { public boolean support(String scheme) {
return URI_SCHEME.equalsIgnoreCase(scheme); return URI_SCHEME.equalsIgnoreCase(scheme);


+ 7
- 1
source/storage/storage-service/src/main/java/com/jd/blockchain/storage/service/DbConnectionFactory.java View File

@@ -3,7 +3,13 @@ package com.jd.blockchain.storage.service;
import java.io.Closeable; import java.io.Closeable;


public interface DbConnectionFactory extends Closeable { public interface DbConnectionFactory extends Closeable {

/**
* 数据库连接前缀
* @return
*/
String dbPrefix();

/** /**
* 是否支持指定 scheme 的连接字符串; * 是否支持指定 scheme 的连接字符串;
* @param scheme * @param scheme


+ 5
- 0
source/storage/storage-service/src/main/java/com/jd/blockchain/storage/service/utils/MemoryDBConnFactory.java View File

@@ -25,6 +25,11 @@ public class MemoryDBConnFactory implements DbConnectionFactory {


private Map<String, DbConnection> memMap = new ConcurrentHashMap<>(); private Map<String, DbConnection> memMap = new ConcurrentHashMap<>();


@Override
public String dbPrefix() {
return "memory://";
}

@Override @Override
public boolean support(String scheme) { public boolean support(String scheme) {
return true; return true;


+ 1
- 1
source/test/test-integration/src/main/resources/ledger_init_test_integration.init View File

@@ -51,7 +51,7 @@ cons_parti.2.name=bt.com
#第2个参与方的公钥文件路径; #第2个参与方的公钥文件路径;
cons_parti.2.pubkey-path=keys/bt-com.pub cons_parti.2.pubkey-path=keys/bt-com.pub
#第2个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; #第2个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数;
cons_parti.2.pubkey=
cons_parti.2.pubkey=3snPdw7i7PezptA6dNBkotPjmKEbTkY8fmusLBnfj8Cf7eFwhWDwKr
#第2个参与方的共识服务的主机地址; #第2个参与方的共识服务的主机地址;
cons_parti.2.consensus.host=127.0.0.1 cons_parti.2.consensus.host=127.0.0.1
#第2个参与方的共识服务的端口; #第2个参与方的共识服务的端口;


+ 0
- 1
source/test/test-integration/src/main/resources/ledger_init_test_web2.init View File

@@ -1,4 +1,3 @@

#账本的种子;一段16进制字符,最长可以包含64个字符;可以用字符“-”分隔,以便更容易读取; #账本的种子;一段16进制字符,最长可以包含64个字符;可以用字符“-”分隔,以便更容易读取;
ledger.seed=932dfe23-fe23232f-283f32fa-dd32aa76-8322ca2f-56236cda-7136b322-cb323ffe ledger.seed=932dfe23-fe23232f-283f32fa-dd32aa76-8322ca2f-56236cda-7136b322-cb323ffe




+ 8
- 8
source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationBase.java View File

@@ -60,16 +60,16 @@ public class IntegrationBase {


public static final String PASSWORD = "abc"; public static final String PASSWORD = "abc";


public static final String[] PUB_KEYS = { "3snPdw7i7PapsDoW185c3kfK6p8s6SwiJAdEUzgnfeuUox12nxgzXu",
"3snPdw7i7Ph1SYLQt9uqVEqiuvNXjxCdGvEdN6otJsg5rbr7Aze7kf",
"3snPdw7i7PezptA6dNBkotPjmKEbTkY8fmusLBnfj8Cf7eFwhWDwKr",
"3snPdw7i7PerZYfRzEB61SAN9tFK4yHm9wUSRtkLSSGXHkQRbB5PkS" };
public static final String[] PUB_KEYS = { "3snPdw7i7PjVKiTH2VnXZu5H8QmNaSXpnk4ei533jFpuifyjS5zzH9",
"3snPdw7i7PajLB35tEau1kmixc6ZrjLXgxwKbkv5bHhP7nT5dhD9eX",
"3snPdw7i7PZi6TStiyc6mzjprnNhgs2atSGNS8wPYzhbKaUWGFJt7x",
"3snPdw7i7PifPuRX7fu3jBjsb3rJRfDe9GtbDfvFJaJ4V4hHXQfhwk" };


public static final String[] PRIV_KEYS = { public static final String[] PRIV_KEYS = {
"177gjyoEUhdD1NkQSxBVvfSyovMd1ha5H46zsb9kyErLNBuQkLRAf2ea6CNjStjCFJQN8S1",
"177gjsa6KcyxUpx7T3tvCVMuqHvvguiQFRLmDY9jaMcH6L9R4k7XgANLfY3paC5XaXeASej",
"177gju7AgXp371qqprjEN3Lg4Hc4EWHnDH9eWgTttEUoN8PuNpQTbS253uTxdKn5w1zZXUp",
"177gjtddYr7CtN6iN6KRgu1kKzFn6quQsx3DQLnUD1xgj5E2QhUTMDnpZKzSKbB7kt35gzj" };
"177gjzHTznYdPgWqZrH43W3yp37onm74wYXT4v9FukpCHBrhRysBBZh7Pzdo5AMRyQGJD7x",
"177gju9p5zrNdHJVEQnEEKF4ZjDDYmAXyfG84V5RPGVc5xFfmtwnHA7j51nyNLUFffzz5UT",
"177gjtwLgmSx5v1hFb46ijh7L9kdbKUpJYqdKVf9afiEmAuLgo8Rck9yu5UuUcHknWJuWaF",
"177gk1pudweTq5zgJTh8y3ENCTwtSFsKyX7YnpuKPo7rKgCkCBXVXh5z2syaTCPEMbuWRns" };


public static final AtomicLong validLong = new AtomicLong(); public static final AtomicLong validLong = new AtomicLong();




+ 3
- 3
source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest4Bftsmart.java View File

@@ -114,10 +114,9 @@ public class IntegrationTest4Bftsmart {
System.out.printf(" sdk execute time = %s threadId = %s \r\n", System.currentTimeMillis(), Thread.currentThread().getId()); System.out.printf(" sdk execute time = %s threadId = %s \r\n", System.currentTimeMillis(), Thread.currentThread().getId());
IntegrationBase.KeyPairResponse userResponse = IntegrationBase.testSDK_RegisterUser(adminKey, ledgerHash, blockchainService); IntegrationBase.KeyPairResponse userResponse = IntegrationBase.testSDK_RegisterUser(adminKey, ledgerHash, blockchainService);


validKeyPair(userResponse, ledgerRepository, IntegrationBase.KeyPairType.USER);
// validKeyPair(userResponse, ledgerRepository, IntegrationBase.KeyPairType.USER);
countDownLatch.countDown(); countDownLatch.countDown();
}); });

} }
} }
try { try {
@@ -139,7 +138,8 @@ public class IntegrationTest4Bftsmart {
} }


try { try {
Thread.sleep(60000);
System.out.println("----------------- Init Completed -----------------");
Thread.sleep(Integer.MAX_VALUE);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }


+ 8
- 8
source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTestAll4Redis.java View File

@@ -54,16 +54,16 @@ public class IntegrationTestAll4Redis {


public static final String PASSWORD = "abc"; public static final String PASSWORD = "abc";


public static final String[] PUB_KEYS = { "endPsK36imXrY66pru6ttZ8dZ3TynWekmdqoM1K7ZRRoRBBiYVzM",
"endPsK36jQE1uYpdVRSnwQXVYhgAMWTaMJiAqii7URiULoBDLUUN",
"endPsK36fc7FSecKAJCJdFhTejbPHMLaGcihJVQCv95czCq4tW5n",
"endPsK36m1grx8mkTMgh8XQHiiaNzajdC5hkuqP6pAuLmMbYkzd4" };
public static final String[] PUB_KEYS = { "3snPdw7i7PjVKiTH2VnXZu5H8QmNaSXpnk4ei533jFpuifyjS5zzH9",
"3snPdw7i7PajLB35tEau1kmixc6ZrjLXgxwKbkv5bHhP7nT5dhD9eX",
"3snPdw7i7PZi6TStiyc6mzjprnNhgs2atSGNS8wPYzhbKaUWGFJt7x",
"3snPdw7i7PifPuRX7fu3jBjsb3rJRfDe9GtbDfvFJaJ4V4hHXQfhwk" };


public static final String[] PRIV_KEYS = { public static final String[] PRIV_KEYS = {
"177gjsuHdbf3PU68Sm1ZU2aMcyB7sLWj94xwBUoUKvTgHq7qGUfg6ynDB62hocYYXSRXD4X",
"177gjwQwTdXthkutDKVgKwiq6wWfLWYuxhji1U2N1C5MzqLRWCLZXo3i2g4vpfcEAQUPG8H",
"177gjvLHUjxvAWsqVcGgV8eHgVNBvJZYDfpP9FLjTouR1gEJNiamYu1qjTNDh18XWyLg8or",
"177gk2VtYeGbK5TS2xWhbSZA4BsT9Xj5Fb8hqCzxzgbojVVcqaDSFFrFPsLbZBx7rszyCNy" };
"177gjzHTznYdPgWqZrH43W3yp37onm74wYXT4v9FukpCHBrhRysBBZh7Pzdo5AMRyQGJD7x",
"177gju9p5zrNdHJVEQnEEKF4ZjDDYmAXyfG84V5RPGVc5xFfmtwnHA7j51nyNLUFffzz5UT",
"177gjtwLgmSx5v1hFb46ijh7L9kdbKUpJYqdKVf9afiEmAuLgo8Rck9yu5UuUcHknWJuWaF",
"177gk1pudweTq5zgJTh8y3ENCTwtSFsKyX7YnpuKPo7rKgCkCBXVXh5z2syaTCPEMbuWRns" };


// batch transactions keys // batch transactions keys
BlockchainKeypair userKey = BlockchainKeyGenerator.getInstance().generate(); BlockchainKeypair userKey = BlockchainKeyGenerator.getInstance().generate();


+ 18
- 2
source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/initializer/LedgerInitSettingTest.java View File

@@ -5,6 +5,7 @@ import static org.junit.Assert.*;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;


import com.jd.blockchain.crypto.AddressEncoding;
import org.junit.Test; import org.junit.Test;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;


@@ -13,6 +14,7 @@ import com.jd.blockchain.tools.initializer.LedgerInitProperties;
import com.jd.blockchain.tools.initializer.LedgerInitProperties.ConsensusParticipantConfig; import com.jd.blockchain.tools.initializer.LedgerInitProperties.ConsensusParticipantConfig;
import com.jd.blockchain.tools.keygen.KeyGenCommand; import com.jd.blockchain.tools.keygen.KeyGenCommand;
import com.jd.blockchain.utils.codec.HexUtils; import com.jd.blockchain.utils.codec.HexUtils;
import test.com.jd.blockchain.intgr.IntegrationBase;


public class LedgerInitSettingTest { public class LedgerInitSettingTest {


@@ -30,7 +32,7 @@ public class LedgerInitSettingTest {
ConsensusParticipantConfig part0 = setting.getConsensusParticipant(0); ConsensusParticipantConfig part0 = setting.getConsensusParticipant(0);
assertEquals("jd.com", part0.getName()); assertEquals("jd.com", part0.getName());
assertEquals("keys/jd-com.pub", part0.getPubKeyPath()); assertEquals("keys/jd-com.pub", part0.getPubKeyPath());
PubKey pubKey0 = KeyGenCommand.decodePubKey("3snPdw7i7PapsDoW185c3kfK6p8s6SwiJAdEUzgnfeuUox12nxgzXu");
PubKey pubKey0 = KeyGenCommand.decodePubKey("3snPdw7i7PjVKiTH2VnXZu5H8QmNaSXpnk4ei533jFpuifyjS5zzH9");
assertEquals(pubKey0, part0.getPubKey()); assertEquals(pubKey0, part0.getPubKey());
// assertEquals("127.0.0.1", part0.getConsensusAddress().getHost()); // assertEquals("127.0.0.1", part0.getConsensusAddress().getHost());
// assertEquals(8900, part0.getConsensusAddress().getPort()); // assertEquals(8900, part0.getConsensusAddress().getPort());
@@ -41,7 +43,7 @@ public class LedgerInitSettingTest {
ConsensusParticipantConfig part1 = setting.getConsensusParticipant(1); ConsensusParticipantConfig part1 = setting.getConsensusParticipant(1);
assertEquals(false, part1.getInitializerAddress().isSecure()); assertEquals(false, part1.getInitializerAddress().isSecure());
PubKey pubKey1 = KeyGenCommand.decodePubKey("3snPdw7i7Ph1SYLQt9uqVEqiuvNXjxCdGvEdN6otJsg5rbr7Aze7kf");
PubKey pubKey1 = KeyGenCommand.decodePubKey("3snPdw7i7PajLB35tEau1kmixc6ZrjLXgxwKbkv5bHhP7nT5dhD9eX");
assertEquals(pubKey1, part1.getPubKey()); assertEquals(pubKey1, part1.getPubKey());
ConsensusParticipantConfig part2 = setting.getConsensusParticipant(2); ConsensusParticipantConfig part2 = setting.getConsensusParticipant(2);
@@ -52,4 +54,18 @@ public class LedgerInitSettingTest {
} }
} }


@Test
public void testPubKeyAddress() {
String[] pubKeys = IntegrationBase.PUB_KEYS;
int index = 0;
for (String pubKeyStr : pubKeys) {
System.out.println("[" + index + "][配置] = " + pubKeyStr);
PubKey pubKey = KeyGenCommand.decodePubKey(pubKeyStr);
System.out.println("[" + index + "][公钥Base58] = " + pubKey.toBase58());
System.out.println("[" + index + "][地址] = " + AddressEncoding.generateAddress(pubKey).toBase58());
System.out.println("--------------------------------------------------------------------");
index++;
}
}

} }

+ 2
- 1
source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/initializer/LedgerInitWebTestConfiguration.java View File

@@ -5,13 +5,14 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;


import com.jd.blockchain.tools.initializer.web.InitWebSecurityConfiguration; import com.jd.blockchain.tools.initializer.web.InitWebSecurityConfiguration;
import com.jd.blockchain.tools.initializer.web.InitWebServerConfiguration; import com.jd.blockchain.tools.initializer.web.InitWebServerConfiguration;


@SpringBootApplication @SpringBootApplication
@EnableAutoConfiguration
@Configuration
@EnableConfigurationProperties @EnableConfigurationProperties
@Import(value = { InitWebServerConfiguration.class, InitWebSecurityConfiguration.class }) @Import(value = { InitWebServerConfiguration.class, InitWebSecurityConfiguration.class })
public class LedgerInitWebTestConfiguration { public class LedgerInitWebTestConfiguration {


+ 5
- 5
source/test/test-integration/src/test/resources/bftsmart.config View File

@@ -27,7 +27,7 @@ system.block.maxdelay=500
############################################ ############################################
###### Consensus Participant0 ###### ###### Consensus Participant0 ######
############################################ ############################################
system.server.0.pubkey=3snPdw7i7PapsDoW185c3kfK6p8s6SwiJAdEUzgnfeuUox12nxgzXu
system.server.0.pubkey=3snPdw7i7PjVKiTH2VnXZu5H8QmNaSXpnk4ei533jFpuifyjS5zzH9


system.server.0.network.host=127.0.0.1 system.server.0.network.host=127.0.0.1


@@ -38,7 +38,7 @@ system.server.0.network.secure=false
############################################ ############################################
###### #Consensus Participant1 ###### ###### #Consensus Participant1 ######
############################################ ############################################
system.server.1.pubkey=3snPdw7i7Ph1SYLQt9uqVEqiuvNXjxCdGvEdN6otJsg5rbr7Aze7kf
system.server.1.pubkey=3snPdw7i7PajLB35tEau1kmixc6ZrjLXgxwKbkv5bHhP7nT5dhD9eX


system.server.1.network.host=127.0.0.1 system.server.1.network.host=127.0.0.1


@@ -49,7 +49,7 @@ system.server.1.network.secure=false
############################################ ############################################
###### #Consensus Participant2 ###### ###### #Consensus Participant2 ######
############################################ ############################################
system.server.2.pubkey=3snPdw7i7PezptA6dNBkotPjmKEbTkY8fmusLBnfj8Cf7eFwhWDwKr
system.server.2.pubkey=3snPdw7i7PZi6TStiyc6mzjprnNhgs2atSGNS8wPYzhbKaUWGFJt7x


system.server.2.network.host=127.0.0.1 system.server.2.network.host=127.0.0.1


@@ -60,7 +60,7 @@ system.server.2.network.secure=false
############################################ ############################################
###### Consensus Participant3 ###### ###### Consensus Participant3 ######
############################################ ############################################
system.server.3.pubkey=3snPdw7i7PerZYfRzEB61SAN9tFK4yHm9wUSRtkLSSGXHkQRbB5PkS
system.server.3.pubkey=3snPdw7i7PifPuRX7fu3jBjsb3rJRfDe9GtbDfvFJaJ4V4hHXQfhwk


system.server.3.network.host=127.0.0.1 system.server.3.network.host=127.0.0.1


@@ -94,7 +94,7 @@ system.servers.num = 4
#system.servers.f = 1 #system.servers.f = 1


#Timeout to asking for a client request #Timeout to asking for a client request
system.totalordermulticast.timeout = 2000
system.totalordermulticast.timeout = 5000




#Maximum batch size (in number of messages) #Maximum batch size (in number of messages)


+ 2
- 2
source/test/test-integration/src/test/resources/ledger-binding-mem-0.conf View File

@@ -8,11 +8,11 @@ binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.id=0
#账本的当前共识参与方的私钥文件的保存路径; #账本的当前共识参与方的私钥文件的保存路径;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path= binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path=
#账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性; #账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gjsj5PHeCpbAtJE7qnbmhuZMHAEKuMsd45zHkv8F8AWBvTBbff8yRKdCyT3kwrmAjSnY
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gjzHTznYdPgWqZrH43W3yp37onm74wYXT4v9FukpCHBrhRysBBZh7Pzdo5AMRyQGJD7x
#账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入; #账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY
#账本的当前共识参与方地址 #账本的当前共识参与方地址
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=5SmFzgFtHtpbJwMCsmWTwjNGTk6SeMKU1522
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=LdeP3fY7jJbNwL8CiL2wU21AF9unDWQjVEW5w
#账本的存储数据库的连接字符串; #账本的存储数据库的连接字符串;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=memory://local/0 binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=memory://local/0
#账本的存储数据库的连接口令; #账本的存储数据库的连接口令;

+ 2
- 2
source/test/test-integration/src/test/resources/ledger-binding-mem-1.conf View File

@@ -8,11 +8,11 @@ binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.id=1
#账本的当前共识参与方的私钥文件的保存路径; #账本的当前共识参与方的私钥文件的保存路径;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path= binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path=
#账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性; #账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gjw9u84WtuCsK8u2WeH4nWqzgEoJWY7jJF9AU6XwLHSosrcNX3H6SSBsfvR53HgX7KR2
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gju9p5zrNdHJVEQnEEKF4ZjDDYmAXyfG84V5RPGVc5xFfmtwnHA7j51nyNLUFffzz5UT
#账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入; #账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY
#账本的当前共识参与方地址 #账本的当前共识参与方地址
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=5SmA98VknTbZ1Z7fmbNPHBuN2pbD89ogy8Ha
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=LdeNnz88dH6CA6PwkVdn3nFRibUKP3sFT2byG
#账本的存储数据库的连接字符串; #账本的存储数据库的连接字符串;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=memory://local/1 binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=memory://local/1
#账本的存储数据库的连接口令; #账本的存储数据库的连接口令;

+ 2
- 2
source/test/test-integration/src/test/resources/ledger-binding-mem-2.conf View File

@@ -8,11 +8,11 @@ binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.id=2
#账本的当前共识参与方的私钥文件的保存路径; #账本的当前共识参与方的私钥文件的保存路径;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path= binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path=
#账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性; #账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gk2FpjufgEon92mf2oRRFXDBZkRy8SkFci7Jxc5pApZEJz3oeCoxieWatDD3Xg7i1QEN
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gjtwLgmSx5v1hFb46ijh7L9kdbKUpJYqdKVf9afiEmAuLgo8Rck9yu5UuUcHknWJuWaF
#账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入; #账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY
#账本的当前共识参与方地址 #账本的当前共识参与方地址
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=5SmMWsqV2kbgrRMjyQFtSq1wvYuPzeRVepHG
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=LdeNmdpT4DiTwLUP9jRQhwdRBRiXeHno456vy
#账本的存储数据库的连接字符串; #账本的存储数据库的连接字符串;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=memory://local/2 binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=memory://local/2
#账本的存储数据库的连接口令; #账本的存储数据库的连接口令;

+ 2
- 2
source/test/test-integration/src/test/resources/ledger-binding-mem-3.conf View File

@@ -8,11 +8,11 @@ binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.id=3
#账本的当前共识参与方的私钥文件的保存路径; #账本的当前共识参与方的私钥文件的保存路径;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path= binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path=
#账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性; #账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gjvv7qvfCAXroFezSn23UFXLVLFofKS3y6DXkJ2DwVWS4LcRNtxRgiqWmQEeWNz4KQ3J
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gk1pudweTq5zgJTh8y3ENCTwtSFsKyX7YnpuKPo7rKgCkCBXVXh5z2syaTCPEMbuWRns
#账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入; #账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY
#账本的当前共识参与方地址 #账本的当前共识参与方地址
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=5Sm5QFyvN1dVB4GHFxWhDCp8vsJbNkdx31Ds
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=LdeNekdXMHqyz9Qxc2jDSBnkvvZLbty6pRDdP
#账本的存储数据库的连接字符串; #账本的存储数据库的连接字符串;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=memory://local/3 binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=memory://local/3
#账本的存储数据库的连接口令; #账本的存储数据库的连接口令;

+ 2
- 2
source/test/test-integration/src/test/resources/ledger-binding-redis-0.conf View File

@@ -8,11 +8,11 @@ binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.id=0
#账本的当前共识参与方的私钥文件的保存路径; #账本的当前共识参与方的私钥文件的保存路径;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path= binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path=
#账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性; #账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gjsj5PHeCpbAtJE7qnbmhuZMHAEKuMsd45zHkv8F8AWBvTBbff8yRKdCyT3kwrmAjSnY
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gjzHTznYdPgWqZrH43W3yp37onm74wYXT4v9FukpCHBrhRysBBZh7Pzdo5AMRyQGJD7x
#账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入; #账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY
#账本的当前共识参与方地址 #账本的当前共识参与方地址
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=5SmFzgFtHtpbJwMCsmWTwjNGTk6SeMKU1522
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=LdeP3fY7jJbNwL8CiL2wU21AF9unDWQjVEW5w
#账本的存储数据库的连接字符串; #账本的存储数据库的连接字符串;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=redis://192.168.54.112:6379 binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=redis://192.168.54.112:6379
#账本的存储数据库的连接口令; #账本的存储数据库的连接口令;

+ 2
- 2
source/test/test-integration/src/test/resources/ledger-binding-redis-1.conf View File

@@ -8,11 +8,11 @@ binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.id=1
#账本的当前共识参与方的私钥文件的保存路径; #账本的当前共识参与方的私钥文件的保存路径;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path= binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path=
#账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性; #账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gjw9u84WtuCsK8u2WeH4nWqzgEoJWY7jJF9AU6XwLHSosrcNX3H6SSBsfvR53HgX7KR2
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gju9p5zrNdHJVEQnEEKF4ZjDDYmAXyfG84V5RPGVc5xFfmtwnHA7j51nyNLUFffzz5UT
#账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入; #账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY
#账本的当前共识参与方地址 #账本的当前共识参与方地址
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=5SmA98VknTbZ1Z7fmbNPHBuN2pbD89ogy8Ha
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=LdeNnz88dH6CA6PwkVdn3nFRibUKP3sFT2byG
#账本的存储数据库的连接字符串; #账本的存储数据库的连接字符串;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=redis://192.168.54.112:6379/1 binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=redis://192.168.54.112:6379/1
#账本的存储数据库的连接口令; #账本的存储数据库的连接口令;

+ 2
- 2
source/test/test-integration/src/test/resources/ledger-binding-redis-2.conf View File

@@ -8,11 +8,11 @@ binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.id=2
#账本的当前共识参与方的私钥文件的保存路径; #账本的当前共识参与方的私钥文件的保存路径;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path= binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path=
#账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性; #账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gk2FpjufgEon92mf2oRRFXDBZkRy8SkFci7Jxc5pApZEJz3oeCoxieWatDD3Xg7i1QEN
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gjtwLgmSx5v1hFb46ijh7L9kdbKUpJYqdKVf9afiEmAuLgo8Rck9yu5UuUcHknWJuWaF
#账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入; #账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY
#账本的当前共识参与方地址 #账本的当前共识参与方地址
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=5SmMWsqV2kbgrRMjyQFtSq1wvYuPzeRVepHG
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=LdeNmdpT4DiTwLUP9jRQhwdRBRiXeHno456vy
#账本的存储数据库的连接字符串; #账本的存储数据库的连接字符串;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=redis://192.168.54.112:6379/2 binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=redis://192.168.54.112:6379/2
#账本的存储数据库的连接口令; #账本的存储数据库的连接口令;

+ 2
- 2
source/test/test-integration/src/test/resources/ledger-binding-redis-3.conf View File

@@ -8,11 +8,11 @@ binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.id=3
#账本的当前共识参与方的私钥文件的保存路径; #账本的当前共识参与方的私钥文件的保存路径;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path= binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path=
#账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性; #账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gjvv7qvfCAXroFezSn23UFXLVLFofKS3y6DXkJ2DwVWS4LcRNtxRgiqWmQEeWNz4KQ3J
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gk1pudweTq5zgJTh8y3ENCTwtSFsKyX7YnpuKPo7rKgCkCBXVXh5z2syaTCPEMbuWRns
#账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入; #账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY
#账本的当前共识参与方地址 #账本的当前共识参与方地址
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=5Sm5QFyvN1dVB4GHFxWhDCp8vsJbNkdx31Ds
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=LdeNekdXMHqyz9Qxc2jDSBnkvvZLbty6pRDdP
#账本的存储数据库的连接字符串; #账本的存储数据库的连接字符串;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=redis://192.168.54.112:6379/3 binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=redis://192.168.54.112:6379/3
#账本的存储数据库的连接口令; #账本的存储数据库的连接口令;

+ 2
- 2
source/test/test-integration/src/test/resources/ledger-binding-rocksdb-0.conf View File

@@ -8,11 +8,11 @@ binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.id=0
#账本的当前共识参与方的私钥文件的保存路径; #账本的当前共识参与方的私钥文件的保存路径;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path= binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path=
#账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性; #账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gjsj5PHeCpbAtJE7qnbmhuZMHAEKuMsd45zHkv8F8AWBvTBbff8yRKdCyT3kwrmAjSnY
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gjzHTznYdPgWqZrH43W3yp37onm74wYXT4v9FukpCHBrhRysBBZh7Pzdo5AMRyQGJD7x
#账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入; #账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY
#账本的当前共识参与方地址 #账本的当前共识参与方地址
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=5SmFzgFtHtpbJwMCsmWTwjNGTk6SeMKU1522
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=LdeP3fY7jJbNwL8CiL2wU21AF9unDWQjVEW5w
#账本的存储数据库的连接字符串; #账本的存储数据库的连接字符串;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=rocksdb binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=rocksdb
#账本的存储数据库的连接口令; #账本的存储数据库的连接口令;

+ 2
- 2
source/test/test-integration/src/test/resources/ledger-binding-rocksdb-1.conf View File

@@ -8,11 +8,11 @@ binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.id=1
#账本的当前共识参与方的私钥文件的保存路径; #账本的当前共识参与方的私钥文件的保存路径;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path= binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path=
#账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性; #账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gjw9u84WtuCsK8u2WeH4nWqzgEoJWY7jJF9AU6XwLHSosrcNX3H6SSBsfvR53HgX7KR2
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gju9p5zrNdHJVEQnEEKF4ZjDDYmAXyfG84V5RPGVc5xFfmtwnHA7j51nyNLUFffzz5UT
#账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入; #账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY
#账本的当前共识参与方地址 #账本的当前共识参与方地址
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=5SmA98VknTbZ1Z7fmbNPHBuN2pbD89ogy8Ha
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=LdeNnz88dH6CA6PwkVdn3nFRibUKP3sFT2byG
#账本的存储数据库的连接字符串; #账本的存储数据库的连接字符串;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=rocksdb binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=rocksdb
#账本的存储数据库的连接口令; #账本的存储数据库的连接口令;

+ 2
- 2
source/test/test-integration/src/test/resources/ledger-binding-rocksdb-2.conf View File

@@ -8,11 +8,11 @@ binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.id=2
#账本的当前共识参与方的私钥文件的保存路径; #账本的当前共识参与方的私钥文件的保存路径;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path= binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path=
#账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性; #账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gk2FpjufgEon92mf2oRRFXDBZkRy8SkFci7Jxc5pApZEJz3oeCoxieWatDD3Xg7i1QEN
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gjtwLgmSx5v1hFb46ijh7L9kdbKUpJYqdKVf9afiEmAuLgo8Rck9yu5UuUcHknWJuWaF
#账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入; #账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY
#账本的当前共识参与方地址 #账本的当前共识参与方地址
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=5SmMWsqV2kbgrRMjyQFtSq1wvYuPzeRVepHG
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=LdeNmdpT4DiTwLUP9jRQhwdRBRiXeHno456vy
#账本的存储数据库的连接字符串; #账本的存储数据库的连接字符串;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=rocksdb binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=rocksdb
#账本的存储数据库的连接口令; #账本的存储数据库的连接口令;

+ 2
- 2
source/test/test-integration/src/test/resources/ledger-binding-rocksdb-3.conf View File

@@ -8,11 +8,11 @@ binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.id=3
#账本的当前共识参与方的私钥文件的保存路径; #账本的当前共识参与方的私钥文件的保存路径;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path= binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk-path=
#账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性; #账本的当前共识参与方的私钥内容(Base58编码);如果指定了,优先选用此属性,其次是 pk-path 属性;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gjvv7qvfCAXroFezSn23UFXLVLFofKS3y6DXkJ2DwVWS4LcRNtxRgiqWmQEeWNz4KQ3J
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pk=177gk1pudweTq5zgJTh8y3ENCTwtSFsKyX7YnpuKPo7rKgCkCBXVXh5z2syaTCPEMbuWRns
#账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入; #账本的当前共识参与方的私钥文件的读取口令;可为空;如果为空时,节点的启动过程中需要手动从控制台输入;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.pwd=DYu3G8aGTMBW1WrTw76zxQJQU4DHLw9MLyy7peG4LKkY
#账本的当前共识参与方地址 #账本的当前共识参与方地址
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=5Sm5QFyvN1dVB4GHFxWhDCp8vsJbNkdx31Ds
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.parti.address=LdeNekdXMHqyz9Qxc2jDSBnkvvZLbty6pRDdP
#账本的存储数据库的连接字符串; #账本的存储数据库的连接字符串;
binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=rocksdb binding.6BCg5vgU57ykY6g2CpyUnt5ZMgdxfD1b3qXxQrRyfiXTQ.db.uri=rocksdb
#账本的存储数据库的连接口令; #账本的存储数据库的连接口令;

+ 3
- 3
source/test/test-integration/src/test/resources/ledger.init View File

@@ -13,7 +13,7 @@ cons_parti.0.name=jd.com
#第0个参与方的公钥文件路径; #第0个参与方的公钥文件路径;
cons_parti.0.pubkey-path=keys/jd-com.pub cons_parti.0.pubkey-path=keys/jd-com.pub
#第0个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; #第0个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数;
cons_parti.0.pubkey=3snPdw7i7PapsDoW185c3kfK6p8s6SwiJAdEUzgnfeuUox12nxgzXu
cons_parti.0.pubkey=3snPdw7i7PjVKiTH2VnXZu5H8QmNaSXpnk4ei533jFpuifyjS5zzH9
#第0个参与方的共识服务的主机地址; #第0个参与方的共识服务的主机地址;
cons_parti.0.consensus.host=127.0.0.1 cons_parti.0.consensus.host=127.0.0.1
#第0个参与方的共识服务的端口; #第0个参与方的共识服务的端口;
@@ -32,7 +32,7 @@ cons_parti.1.name=at.com
#第1个参与方的公钥文件路径; #第1个参与方的公钥文件路径;
cons_parti.1.pubkey-path=keys/at-com.pub cons_parti.1.pubkey-path=keys/at-com.pub
#第1个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; #第1个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数;
cons_parti.1.pubkey=3snPdw7i7Ph1SYLQt9uqVEqiuvNXjxCdGvEdN6otJsg5rbr7Aze7kf
cons_parti.1.pubkey=3snPdw7i7PajLB35tEau1kmixc6ZrjLXgxwKbkv5bHhP7nT5dhD9eX
#第1个参与方的共识服务的主机地址; #第1个参与方的共识服务的主机地址;
cons_parti.1.consensus.host=127.0.0.1 cons_parti.1.consensus.host=127.0.0.1
#第1个参与方的共识服务的端口; #第1个参与方的共识服务的端口;
@@ -70,7 +70,7 @@ cons_parti.3.name=xt.com
#第3个参与方的公钥文件路径; #第3个参与方的公钥文件路径;
cons_parti.3.pubkey-path=keys/xt-com.pub cons_parti.3.pubkey-path=keys/xt-com.pub
#第3个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; #第3个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数;
cons_parti.3.pubkey=3snPdw7i7PerZYfRzEB61SAN9tFK4yHm9wUSRtkLSSGXHkQRbB5PkS
cons_parti.3.pubkey=3snPdw7i7PifPuRX7fu3jBjsb3rJRfDe9GtbDfvFJaJ4V4hHXQfhwk
#第3个参与方的共识服务的主机地址; #第3个参与方的共识服务的主机地址;
cons_parti.3.consensus.host=127.0.0.1 cons_parti.3.consensus.host=127.0.0.1
#第3个参与方的共识服务的端口; #第3个参与方的共识服务的端口;


+ 4
- 4
source/test/test-integration/src/test/resources/ledger_init_test.init View File

@@ -13,7 +13,7 @@ cons_parti.0.name=jd.com
#第0个参与方的公钥文件路径; #第0个参与方的公钥文件路径;
cons_parti.0.pubkey-path=keys/jd-com.pub cons_parti.0.pubkey-path=keys/jd-com.pub
#第0个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; #第0个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数;
cons_parti.0.pubkey=3snPdw7i7PapsDoW185c3kfK6p8s6SwiJAdEUzgnfeuUox12nxgzXu
cons_parti.0.pubkey=3snPdw7i7PjVKiTH2VnXZu5H8QmNaSXpnk4ei533jFpuifyjS5zzH9
#第0个参与方的共识服务的主机地址; #第0个参与方的共识服务的主机地址;
cons_parti.0.consensus.host=127.0.0.1 cons_parti.0.consensus.host=127.0.0.1
#第0个参与方的共识服务的端口; #第0个参与方的共识服务的端口;
@@ -32,7 +32,7 @@ cons_parti.1.name=at.com
#第1个参与方的公钥文件路径; #第1个参与方的公钥文件路径;
cons_parti.1.pubkey-path=keys/at-com.pub cons_parti.1.pubkey-path=keys/at-com.pub
#第1个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; #第1个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数;
cons_parti.1.pubkey=3snPdw7i7Ph1SYLQt9uqVEqiuvNXjxCdGvEdN6otJsg5rbr7Aze7kf
cons_parti.1.pubkey=3snPdw7i7PajLB35tEau1kmixc6ZrjLXgxwKbkv5bHhP7nT5dhD9eX
#第1个参与方的共识服务的主机地址; #第1个参与方的共识服务的主机地址;
cons_parti.1.consensus.host=127.0.0.1 cons_parti.1.consensus.host=127.0.0.1
#第1个参与方的共识服务的端口; #第1个参与方的共识服务的端口;
@@ -51,7 +51,7 @@ cons_parti.2.name=bt.com
#第2个参与方的公钥文件路径; #第2个参与方的公钥文件路径;
cons_parti.2.pubkey-path=keys/bt-com.pub cons_parti.2.pubkey-path=keys/bt-com.pub
#第2个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; #第2个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数;
cons_parti.2.pubkey=3snPdw7i7PezptA6dNBkotPjmKEbTkY8fmusLBnfj8Cf7eFwhWDwKr
cons_parti.2.pubkey=3snPdw7i7PZi6TStiyc6mzjprnNhgs2atSGNS8wPYzhbKaUWGFJt7x
#第2个参与方的共识服务的主机地址; #第2个参与方的共识服务的主机地址;
cons_parti.2.consensus.host=127.0.0.1 cons_parti.2.consensus.host=127.0.0.1
#第2个参与方的共识服务的端口; #第2个参与方的共识服务的端口;
@@ -70,7 +70,7 @@ cons_parti.3.name=xt.com
#第3个参与方的公钥文件路径; #第3个参与方的公钥文件路径;
cons_parti.3.pubkey-path=keys/xt-com.pub cons_parti.3.pubkey-path=keys/xt-com.pub
#第3个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; #第3个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数;
cons_parti.3.pubkey=3snPdw7i7PerZYfRzEB61SAN9tFK4yHm9wUSRtkLSSGXHkQRbB5PkS
cons_parti.3.pubkey=3snPdw7i7PifPuRX7fu3jBjsb3rJRfDe9GtbDfvFJaJ4V4hHXQfhwk
#第3个参与方的共识服务的主机地址; #第3个参与方的共识服务的主机地址;
cons_parti.3.consensus.host=127.0.0.1 cons_parti.3.consensus.host=127.0.0.1
#第3个参与方的共识服务的端口; #第3个参与方的共识服务的端口;


+ 4
- 4
source/test/test-integration/src/test/resources/ledger_init_test_integration.init View File

@@ -13,7 +13,7 @@ cons_parti.0.name=jd.com
#第0个参与方的公钥文件路径; #第0个参与方的公钥文件路径;
cons_parti.0.pubkey-path=keys/jd-com.pub cons_parti.0.pubkey-path=keys/jd-com.pub
#第0个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; #第0个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数;
cons_parti.0.pubkey=3snPdw7i7PapsDoW185c3kfK6p8s6SwiJAdEUzgnfeuUox12nxgzXu
cons_parti.0.pubkey=3snPdw7i7PjVKiTH2VnXZu5H8QmNaSXpnk4ei533jFpuifyjS5zzH9
#第0个参与方的共识服务的主机地址; #第0个参与方的共识服务的主机地址;
cons_parti.0.consensus.host=127.0.0.1 cons_parti.0.consensus.host=127.0.0.1
#第0个参与方的共识服务的端口; #第0个参与方的共识服务的端口;
@@ -32,7 +32,7 @@ cons_parti.1.name=at.com
#第1个参与方的公钥文件路径; #第1个参与方的公钥文件路径;
cons_parti.1.pubkey-path=keys/at-com.pub cons_parti.1.pubkey-path=keys/at-com.pub
#第1个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; #第1个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数;
cons_parti.1.pubkey=3snPdw7i7Ph1SYLQt9uqVEqiuvNXjxCdGvEdN6otJsg5rbr7Aze7kf
cons_parti.1.pubkey=3snPdw7i7PajLB35tEau1kmixc6ZrjLXgxwKbkv5bHhP7nT5dhD9eX
#第1个参与方的共识服务的主机地址; #第1个参与方的共识服务的主机地址;
cons_parti.1.consensus.host=127.0.0.1 cons_parti.1.consensus.host=127.0.0.1
#第1个参与方的共识服务的端口; #第1个参与方的共识服务的端口;
@@ -51,7 +51,7 @@ cons_parti.2.name=bt.com
#第2个参与方的公钥文件路径; #第2个参与方的公钥文件路径;
cons_parti.2.pubkey-path=keys/bt-com.pub cons_parti.2.pubkey-path=keys/bt-com.pub
#第2个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; #第2个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数;
cons_parti.2.pubkey=3snPdw7i7PezptA6dNBkotPjmKEbTkY8fmusLBnfj8Cf7eFwhWDwKr
cons_parti.2.pubkey=3snPdw7i7PZi6TStiyc6mzjprnNhgs2atSGNS8wPYzhbKaUWGFJt7x
#第2个参与方的共识服务的主机地址; #第2个参与方的共识服务的主机地址;
cons_parti.2.consensus.host=127.0.0.1 cons_parti.2.consensus.host=127.0.0.1
#第2个参与方的共识服务的端口; #第2个参与方的共识服务的端口;
@@ -70,7 +70,7 @@ cons_parti.3.name=xt.com
#第3个参与方的公钥文件路径; #第3个参与方的公钥文件路径;
cons_parti.3.pubkey-path=keys/xt-com.pub cons_parti.3.pubkey-path=keys/xt-com.pub
#第3个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; #第3个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数;
cons_parti.3.pubkey=3snPdw7i7PerZYfRzEB61SAN9tFK4yHm9wUSRtkLSSGXHkQRbB5PkS
cons_parti.3.pubkey=3snPdw7i7PifPuRX7fu3jBjsb3rJRfDe9GtbDfvFJaJ4V4hHXQfhwk
#第3个参与方的共识服务的主机地址; #第3个参与方的共识服务的主机地址;
cons_parti.3.consensus.host=127.0.0.1 cons_parti.3.consensus.host=127.0.0.1
#第3个参与方的共识服务的端口; #第3个参与方的共识服务的端口;


+ 4
- 4
source/test/test-integration/src/test/resources/ledger_init_test_web1.init View File

@@ -13,7 +13,7 @@ cons_parti.0.name=jd.com
#第0个参与方的公钥文件路径; #第0个参与方的公钥文件路径;
cons_parti.0.pubkey-path=keys/jd-com.pub cons_parti.0.pubkey-path=keys/jd-com.pub
#第0个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; #第0个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数;
cons_parti.0.pubkey=3snPdw7i7PapsDoW185c3kfK6p8s6SwiJAdEUzgnfeuUox12nxgzXu
cons_parti.0.pubkey=3snPdw7i7PjVKiTH2VnXZu5H8QmNaSXpnk4ei533jFpuifyjS5zzH9
#第0个参与方的共识服务的主机地址; #第0个参与方的共识服务的主机地址;
cons_parti.0.consensus.host=127.0.0.1 cons_parti.0.consensus.host=127.0.0.1
#第0个参与方的共识服务的端口; #第0个参与方的共识服务的端口;
@@ -32,7 +32,7 @@ cons_parti.1.name=at.com
#第1个参与方的公钥文件路径; #第1个参与方的公钥文件路径;
cons_parti.1.pubkey-path=keys/at-com.pub cons_parti.1.pubkey-path=keys/at-com.pub
#第1个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; #第1个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数;
cons_parti.1.pubkey=3snPdw7i7Ph1SYLQt9uqVEqiuvNXjxCdGvEdN6otJsg5rbr7Aze7kf
cons_parti.1.pubkey=3snPdw7i7PajLB35tEau1kmixc6ZrjLXgxwKbkv5bHhP7nT5dhD9eX
#第1个参与方的共识服务的主机地址; #第1个参与方的共识服务的主机地址;
cons_parti.1.consensus.host=127.0.0.1 cons_parti.1.consensus.host=127.0.0.1
#第1个参与方的共识服务的端口; #第1个参与方的共识服务的端口;
@@ -51,7 +51,7 @@ cons_parti.2.name=bt.com
#第2个参与方的公钥文件路径; #第2个参与方的公钥文件路径;
cons_parti.2.pubkey-path=keys/bt-com.pub cons_parti.2.pubkey-path=keys/bt-com.pub
#第2个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; #第2个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数;
cons_parti.2.pubkey=3snPdw7i7PezptA6dNBkotPjmKEbTkY8fmusLBnfj8Cf7eFwhWDwKr
cons_parti.2.pubkey=3snPdw7i7PZi6TStiyc6mzjprnNhgs2atSGNS8wPYzhbKaUWGFJt7x
#第2个参与方的共识服务的主机地址; #第2个参与方的共识服务的主机地址;
cons_parti.2.consensus.host=127.0.0.1 cons_parti.2.consensus.host=127.0.0.1
#第2个参与方的共识服务的端口; #第2个参与方的共识服务的端口;
@@ -70,7 +70,7 @@ cons_parti.3.name=xt.com
#第3个参与方的公钥文件路径; #第3个参与方的公钥文件路径;
cons_parti.3.pubkey-path=keys/xt-com.pub cons_parti.3.pubkey-path=keys/xt-com.pub
#第3个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; #第3个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数;
cons_parti.3.pubkey=3snPdw7i7PerZYfRzEB61SAN9tFK4yHm9wUSRtkLSSGXHkQRbB5PkS
cons_parti.3.pubkey=3snPdw7i7PifPuRX7fu3jBjsb3rJRfDe9GtbDfvFJaJ4V4hHXQfhwk
#第3个参与方的共识服务的主机地址; #第3个参与方的共识服务的主机地址;
cons_parti.3.consensus.host=127.0.0.1 cons_parti.3.consensus.host=127.0.0.1
#第3个参与方的共识服务的端口; #第3个参与方的共识服务的端口;


+ 4
- 4
source/test/test-integration/src/test/resources/ledger_init_test_web2.init View File

@@ -13,7 +13,7 @@ cons_parti.0.name=jd.com
#第0个参与方的公钥文件路径; #第0个参与方的公钥文件路径;
cons_parti.0.pubkey-path=keys/jd-com.pub cons_parti.0.pubkey-path=keys/jd-com.pub
#第0个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; #第0个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数;
cons_parti.0.pubkey=3snPdw7i7PapsDoW185c3kfK6p8s6SwiJAdEUzgnfeuUox12nxgzXu
cons_parti.0.pubkey=3snPdw7i7PjVKiTH2VnXZu5H8QmNaSXpnk4ei533jFpuifyjS5zzH9
#第0个参与方的账本初始服务的主机; #第0个参与方的账本初始服务的主机;
cons_parti.0.initializer.host=127.0.0.1 cons_parti.0.initializer.host=127.0.0.1
#第0个参与方的账本初始服务的端口; #第0个参与方的账本初始服务的端口;
@@ -26,7 +26,7 @@ cons_parti.1.name=at.com
#第1个参与方的公钥文件路径; #第1个参与方的公钥文件路径;
cons_parti.1.pubkey-path=keys/at-com.pub cons_parti.1.pubkey-path=keys/at-com.pub
#第1个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; #第1个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数;
cons_parti.1.pubkey=3snPdw7i7Ph1SYLQt9uqVEqiuvNXjxCdGvEdN6otJsg5rbr7Aze7kf
cons_parti.1.pubkey=3snPdw7i7PajLB35tEau1kmixc6ZrjLXgxwKbkv5bHhP7nT5dhD9eX
#第1个参与方的账本初始服务的主机; #第1个参与方的账本初始服务的主机;
cons_parti.1.initializer.host=127.0.0.1 cons_parti.1.initializer.host=127.0.0.1
#第1个参与方的账本初始服务的端口; #第1个参与方的账本初始服务的端口;
@@ -39,7 +39,7 @@ cons_parti.2.name=bt.com
#第2个参与方的公钥文件路径; #第2个参与方的公钥文件路径;
cons_parti.2.pubkey-path=keys/bt-com.pub cons_parti.2.pubkey-path=keys/bt-com.pub
#第2个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; #第2个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数;
cons_parti.2.pubkey=3snPdw7i7PezptA6dNBkotPjmKEbTkY8fmusLBnfj8Cf7eFwhWDwKr
cons_parti.2.pubkey=3snPdw7i7PZi6TStiyc6mzjprnNhgs2atSGNS8wPYzhbKaUWGFJt7x
#第2个参与方的账本初始服务的主机; #第2个参与方的账本初始服务的主机;
cons_parti.2.initializer.host=127.0.0.1 cons_parti.2.initializer.host=127.0.0.1
#第2个参与方的账本初始服务的端口; #第2个参与方的账本初始服务的端口;
@@ -52,7 +52,7 @@ cons_parti.3.name=xt.com
#第3个参与方的公钥文件路径; #第3个参与方的公钥文件路径;
cons_parti.3.pubkey-path=keys/xt-com.pub cons_parti.3.pubkey-path=keys/xt-com.pub
#第3个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; #第3个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数;
cons_parti.3.pubkey=3snPdw7i7PerZYfRzEB61SAN9tFK4yHm9wUSRtkLSSGXHkQRbB5PkS
cons_parti.3.pubkey=3snPdw7i7PifPuRX7fu3jBjsb3rJRfDe9GtbDfvFJaJ4V4hHXQfhwk
#第3个参与方的账本初始服务的主机; #第3个参与方的账本初始服务的主机;
cons_parti.3.initializer.host=127.0.0.1 cons_parti.3.initializer.host=127.0.0.1
#第3个参与方的账本初始服务的端口; #第3个参与方的账本初始服务的端口;


Loading…
Cancel
Save