Browse Source

bug modify for regist participant

tags/1.1.0
zhangshuang 5 years ago
parent
commit
712e273662
6 changed files with 48 additions and 13 deletions
  1. +7
    -7
      source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartConsensusSettingsBuilder.java
  2. +3
    -3
      source/consensus/consensus-mq/src/main/java/com/jd/blockchain/consensus/mq/MsgQueueConsensusSettingsBuilder.java
  3. +0
    -2
      source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/impl/handles/ParticipantRegisterOperationHandle.java
  4. +19
    -0
      source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest4Bftsmart.java
  5. +18
    -0
      source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest4MQ.java
  6. +1
    -1
      source/tools/tools-initializer/src/main/java/com/jd/blockchain/tools/initializer/LedgerInitProperties.java

+ 7
- 7
source/consensus/consensus-bftsmart/src/main/java/com/jd/blockchain/consensus/bftsmart/BftsmartConsensusSettingsBuilder.java View File

@@ -185,13 +185,13 @@ public class BftsmartConsensusSettingsBuilder implements ConsensusSettingsBuilde

BftsmartConsensusConfig bftsmartConsensusConfig = new BftsmartConsensusConfig(nodeSettings, systemConfigs);

for(int i = 0 ;i < bftsmartConsensusConfig.getNodes().length; i++) {
System.out.printf("id = %d, host = %s, port = %d\r\n", bftsmartConsensusConfig.getNodes()[i].getId(), bftsmartConsensusConfig.getNodes()[i].getNetworkAddress().getHost(), bftsmartConsensusConfig.getNodes()[i].getNetworkAddress().getPort());
}
for(int i = 0 ;i < bftsmartConsensusConfig.getSystemConfigs().length; i++) {
System.out.printf("property name = %s, property value = %s\r\n",bftsmartConsensusConfig.getSystemConfigs()[i].getName(), bftsmartConsensusConfig.getSystemConfigs()[i].getValue());
}
// for(int i = 0 ;i < bftsmartConsensusConfig.getNodes().length; i++) {
// System.out.printf("id = %d, host = %s, port = %d\r\n", bftsmartConsensusConfig.getNodes()[i].getId(), bftsmartConsensusConfig.getNodes()[i].getNetworkAddress().getHost(), bftsmartConsensusConfig.getNodes()[i].getNetworkAddress().getPort());
// }
//
// for(int i = 0 ;i < bftsmartConsensusConfig.getSystemConfigs().length; i++) {
// System.out.printf("property name = %s, property value = %s\r\n",bftsmartConsensusConfig.getSystemConfigs()[i].getName(), bftsmartConsensusConfig.getSystemConfigs()[i].getValue());
// }

return new Bytes(ConsensusProviders.getProvider(BFTSMART_PROVIDER).getSettingsFactory().getConsensusSettingsEncoder().encode(bftsmartConsensusConfig));



+ 3
- 3
source/consensus/consensus-mq/src/main/java/com/jd/blockchain/consensus/mq/MsgQueueConsensusSettingsBuilder.java View File

@@ -184,9 +184,9 @@ public class MsgQueueConsensusSettingsBuilder implements ConsensusSettingsBuilde
msgQueueConsensusConfig.setNetworkSettings(consensusSettings.getNetworkSettings());


for(int i = 0 ;i < msgQueueConsensusConfig.getNodes().length; i++) {
System.out.printf("node addr = %s\r\n", msgQueueConsensusConfig.getNodes()[i].getAddress());
}
// for(int i = 0 ;i < msgQueueConsensusConfig.getNodes().length; i++) {
// System.out.printf("node addr = %s\r\n", msgQueueConsensusConfig.getNodes()[i].getAddress());
// }

return new Bytes(consensusEncoder.encode(msgQueueConsensusConfig));



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

@@ -16,8 +16,6 @@ public class ParticipantRegisterOperationHandle implements OperationHandle {

ParticipantRegisterOperation participantRegOp = (ParticipantRegisterOperation) op;

System.out.println("ParticipantRegisterOperationHandle start\r\n");

LedgerAdminAccount adminAccount = dataset.getAdminAccount();

ParticipantInfo participantInfo = participantRegOp.getParticipantInfo();


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

@@ -30,6 +30,8 @@ public class IntegrationTest4Bftsmart {

private static final boolean isRegisterDataAccount = true;

private static final boolean isRegisterParticipant = true;

private static final boolean isWriteKv = true;

private static final String DB_TYPE_MEM = "mem";
@@ -140,6 +142,23 @@ public class IntegrationTest4Bftsmart {
}
}

long participantCount = ledgerRepository.getAdminAccount(ledgerRepository.retrieveLatestBlock()).getParticipantCount();

long userCount = ledgerRepository.getUserAccountSet(ledgerRepository.retrieveLatestBlock()).getTotalCount();

System.out.printf("before add participant: participantCount = %d, userCount = %d\r\n", (int)participantCount, (int)userCount);

if (isRegisterParticipant) {
IntegrationBase.KeyPairResponse participantResponse = IntegrationBase.testSDK_RegisterParticipant(adminKey, ledgerHash, blockchainService);
}

participantCount = ledgerRepository.getAdminAccount(ledgerRepository.retrieveLatestBlock()).getParticipantCount();

userCount = ledgerRepository.getUserAccountSet(ledgerRepository.retrieveLatestBlock()).getTotalCount();

System.out.printf("after add participant: participantCount = %d, userCount = %d\r\n", (int)participantCount, (int)userCount);


try {
System.out.println("----------------- Init Completed -----------------");
Thread.sleep(Integer.MAX_VALUE);


+ 18
- 0
source/test/test-integration/src/test/java/test/com/jd/blockchain/intgr/IntegrationTest4MQ.java View File

@@ -30,6 +30,8 @@ public class IntegrationTest4MQ {

private static final boolean isRegisterDataAccount = true;

private static final boolean isRegisterParticipant = true;

private static final boolean isWriteKv = true;
private static final boolean isContract = false;

@@ -138,6 +140,22 @@ public class IntegrationTest4MQ {
integrationBase.testSDK_Contract(adminKey, ledgerHash, blockchainService,ledgerRepository);
}

long participantCount = ledgerRepository.getAdminAccount(ledgerRepository.retrieveLatestBlock()).getParticipantCount();

long userCount = ledgerRepository.getUserAccountSet(ledgerRepository.retrieveLatestBlock()).getTotalCount();

System.out.printf("before add participant: participantCount = %d, userCount = %d\r\n", (int)participantCount, (int)userCount);

if (isRegisterParticipant) {
IntegrationBase.KeyPairResponse participantResponse = IntegrationBase.testSDK_RegisterParticipant(adminKey, ledgerHash, blockchainService);
}

participantCount = ledgerRepository.getAdminAccount(ledgerRepository.retrieveLatestBlock()).getParticipantCount();

userCount = ledgerRepository.getUserAccountSet(ledgerRepository.retrieveLatestBlock()).getTotalCount();

System.out.printf("after add participant: participantCount = %d, userCount = %d\r\n", (int)participantCount, (int)userCount);

IntegrationBase.testConsistencyAmongNodes(ledgers);

if(isOnline){


+ 1
- 1
source/tools/tools-initializer/src/main/java/com/jd/blockchain/tools/initializer/LedgerInitProperties.java View File

@@ -242,7 +242,7 @@ public class LedgerInitProperties {
.parseBoolean(PropertiesUtils.getRequiredProperty(props, initializerSecureKey));
NetworkAddress initializerAddress = new NetworkAddress(initializerHost, initializerPort, initializerSecure);
parti.setInitializerAddress(initializerAddress);
parti.setParticipantNodeState(ParticipantNodeState.CONSENSUSED);
initProps.addConsensusParticipant(parti);
}



Loading…
Cancel
Save