From 194ddb4e75074d192e1433ccd37797f61047e713 Mon Sep 17 00:00:00 2001 From: zhangshuang Date: Thu, 12 Nov 2020 16:38:32 +0800 Subject: [PATCH] add auto node shell --- core | 2 +- deploy/deploy-peer/pom.xml | 18 ++++++++ .../main/resources/scripts/active-parti.sh | 10 +++++ .../main/resources/scripts/deactive-parti.sh | 10 +++++ .../src/main/resources/scripts/reg-parti.sh | 10 +++++ .../SDK_Update_ConsensusSettings_Demo.java | 42 +++++++++++++++++++ 6 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 deploy/deploy-peer/src/main/resources/scripts/active-parti.sh create mode 100644 deploy/deploy-peer/src/main/resources/scripts/deactive-parti.sh create mode 100644 deploy/deploy-peer/src/main/resources/scripts/reg-parti.sh create mode 100644 samples/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDK_Update_ConsensusSettings_Demo.java diff --git a/core b/core index 22a63e4f..b5a9bd91 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 22a63e4fe85398a090f7e4abf99cd212549be70f +Subproject commit b5a9bd9155034260d8babebb6d8701c3627c226b diff --git a/deploy/deploy-peer/pom.xml b/deploy/deploy-peer/pom.xml index b9edadbe..a31a5614 100644 --- a/deploy/deploy-peer/pom.xml +++ b/deploy/deploy-peer/pom.xml @@ -58,6 +58,24 @@ ${core.version} + + com.jd.blockchain + tools-regparti-booter + ${core.version} + + + + com.jd.blockchain + tools-activeparti-booter + ${core.version} + + + + com.jd.blockchain + tools-deactiveparti-booter + ${core.version} + + diff --git a/deploy/deploy-peer/src/main/resources/scripts/active-parti.sh b/deploy/deploy-peer/src/main/resources/scripts/active-parti.sh new file mode 100644 index 00000000..df895210 --- /dev/null +++ b/deploy/deploy-peer/src/main/resources/scripts/active-parti.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +OME=$(cd `dirname $0`;cd ../; pwd) +boot_file=$(ls ../libs | grep tools-activeparti-booter-) +if [ ! -n "$boot_file" ]; then + echo "tools-activeparti-booter is null" +else + echo "active participant" + java -jar $HOME/libs/$boot_file $* +fi \ No newline at end of file diff --git a/deploy/deploy-peer/src/main/resources/scripts/deactive-parti.sh b/deploy/deploy-peer/src/main/resources/scripts/deactive-parti.sh new file mode 100644 index 00000000..0dc00080 --- /dev/null +++ b/deploy/deploy-peer/src/main/resources/scripts/deactive-parti.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +OME=$(cd `dirname $0`;cd ../; pwd) +boot_file=$(ls ../libs | grep tools-deactiveparti-booter-) +if [ ! -n "$boot_file" ]; then + echo "tools-deactiveparti-booter is null" +else + echo "deactive participant" + java -jar $HOME/libs/$boot_file $* +fi \ No newline at end of file diff --git a/deploy/deploy-peer/src/main/resources/scripts/reg-parti.sh b/deploy/deploy-peer/src/main/resources/scripts/reg-parti.sh new file mode 100644 index 00000000..cd31b360 --- /dev/null +++ b/deploy/deploy-peer/src/main/resources/scripts/reg-parti.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +HOME=$(cd `dirname $0`;cd ../; pwd) + boot_file=$(ls ../libs | grep tools-regparti-booter-) + if [ ! -n "$boot_file" ]; then + echo "tools-regparti-booter is null" + else + echo "register new participant" + java -jar $HOME/libs/$boot_file $* + fi \ No newline at end of file diff --git a/samples/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDK_Update_ConsensusSettings_Demo.java b/samples/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDK_Update_ConsensusSettings_Demo.java new file mode 100644 index 00000000..de875c32 --- /dev/null +++ b/samples/sdk-samples/src/main/java/com/jd/blockchain/sdk/samples/SDK_Update_ConsensusSettings_Demo.java @@ -0,0 +1,42 @@ +package com.jd.blockchain.sdk.samples; + +import com.jd.blockchain.ledger.PreparedTransaction; +import com.jd.blockchain.ledger.TransactionResponse; +import com.jd.blockchain.ledger.TransactionTemplate; +import com.jd.blockchain.utils.Property; + +import java.util.ArrayList; +import java.util.List; + +public class SDK_Update_ConsensusSettings_Demo extends SDK_Base_Demo { + + public static void main(String[] args) { + new SDK_Update_ConsensusSettings_Demo().updateSettings(); + } + + public void updateSettings() { + + List properties = new ArrayList(); + + // 修改bftsmart.conf配置文件中的选项; + properties.add(new Property("system.communication.useSenderThread", "false")); + + Property[] propertiesArray = properties.toArray(new Property[properties.size()]); + + TransactionTemplate txTpl = blockchainService.newTransaction(ledgerHash); + + txTpl.settings().update(propertiesArray); + + // TX 准备就绪; + PreparedTransaction prepTx = txTpl.prepare(); + + // 使用私钥进行签名; + prepTx.sign(adminKey); + + // 提交交易; + TransactionResponse transactionResponse = prepTx.commit(); + + System.out.println(transactionResponse.isSuccess()); + + } +}