├── scripts ├── start.sh ├── stop.sh ├── sync-to-remote.sh ├── compile-latest.sh └── sync-to-all.sh ├── deploy ├── deploy-peer │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ ├── scripts │ │ │ │ ├── jdchain-cli.sh │ │ │ │ ├── ledger-init.sh │ │ │ │ ├── peer-shutdown.sh │ │ │ │ └── peer-startup.sh │ │ │ ├── config │ │ │ │ ├── init │ │ │ │ │ ├── mq │ │ │ │ │ │ └── mq.config │ │ │ │ │ ├── local.conf │ │ │ │ │ ├── raft │ │ │ │ │ │ └── raft.config │ │ │ │ │ ├── ledger.init │ │ │ │ │ └── bftsmart │ │ │ │ │ │ └── bftsmart.config │ │ │ │ ├── application-peer.properties │ │ │ │ └── log4j2-peer.xml │ │ │ └── assembly.xml │ │ │ └── java │ │ │ └── com │ │ │ └── jd │ │ │ └── blockchain │ │ │ └── boot │ │ │ └── peer │ │ │ └── PeerBooter.java │ └── pom.xml ├── deploy-gateway │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── jd │ │ │ │ └── blockchain │ │ │ │ └── gateway │ │ │ │ └── boot │ │ │ │ └── GatewayBooter.java │ │ │ └── resources │ │ │ ├── config │ │ │ ├── application-gw.properties │ │ │ ├── gateway.conf │ │ │ └── log4j2-gw.xml │ │ │ ├── scripts │ │ │ ├── shutdown.sh │ │ │ └── startup.sh │ │ │ └── assembly.xml │ └── pom.xml └── pom.xml ├── pom.xml ├── .gitmodules ├── .gitignore ├── README.md └── LICENSE /scripts/start.sh: -------------------------------------------------------------------------------- 1 | 2 | NAME=$1 3 | 4 | java -jar peer-0.0.1-SNAPSHOT.jar --spring.config.location=file:config/application.properties --name=$NAME 5 | 6 | -------------------------------------------------------------------------------- /scripts/stop.sh: -------------------------------------------------------------------------------- 1 | 2 | FILTER=$1 3 | 4 | PID=`ps -ef | grep "name=$FILTER" | grep -v grep | awk '{print $2}'` 5 | 6 | PROC_PATH=`ps -ef | grep "name=$FILTER" | grep -v grep | awk '{print $8}'` 7 | echo "Stopping peer[$PID][$FILTER] ......" 8 | kill -9 $PID 9 | 10 | echo "Peer[$PID][$FILTER] stopped!" 11 | -------------------------------------------------------------------------------- /deploy/deploy-peer/src/main/resources/scripts/jdchain-cli.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | HOME=$(cd `dirname $0`;cd ../; pwd) 4 | boot_file=$(ls $HOME/libs | grep jdchain-cli-) 5 | if [ ! -n "$boot_file" ]; then 6 | echo "can not find jdchain-cli in libs" 7 | else 8 | java -jar $HOME/libs/$boot_file $* 9 | fi 10 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.jd.blockchain 7 | jdchain-root 8 | 1.6.5.RELEASE 9 | pom 10 | jdchain root project 11 | 12 | 13 | project 14 | framework 15 | core 16 | deploy 17 | test 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /deploy/deploy-gateway/src/main/java/com/jd/blockchain/gateway/boot/GatewayBooter.java: -------------------------------------------------------------------------------- 1 | package com.jd.blockchain.gateway.boot; 2 | 3 | import com.jd.blockchain.gateway.GatewayServerBooter; 4 | import utils.ConsoleUtils; 5 | 6 | import java.io.File; 7 | import java.io.FileOutputStream; 8 | import java.lang.management.ManagementFactory; 9 | import java.net.URL; 10 | import java.nio.charset.StandardCharsets; 11 | import java.util.ArrayList; 12 | import java.util.Date; 13 | import java.util.List; 14 | 15 | public class GatewayBooter { 16 | 17 | public static void main(String[] args) { 18 | try { 19 | GatewayServerBooter.main(args); 20 | } catch (Exception e) { 21 | ConsoleUtils.error("Gateway start error!", e); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /scripts/sync-to-remote.sh: -------------------------------------------------------------------------------- 1 | 2 | #Require Eironment Variable: FROM_DIR, REMOTE, PROC_DIR 3 | 4 | FROM_DIR=$1 5 | REMOTE=$2 6 | PROC_DIR=$3 7 | 8 | echo "FROM_DIR="$FROM_DIR 9 | echo "REMOTE="$REMOTE 10 | echo "PROC_DIR="$PROC_DIR 11 | 12 | REMOTE_DIR=@$REMOTE:$PROC_DIR 13 | 14 | echo "=========================================" 15 | echo "Begin synchronizing to [$REMOTE_DIR]" 16 | echo "=========================================" 17 | 18 | ssh $REMOTE "cd $PROC_DIR; sh $PROC_DIR/stop.sh; rm -rf $PROC_DIR/*" 19 | scp -r $FROM_DIR/* $REMOTE_DIR 20 | ssh $REMOTE "cd $PROC_DIR; chmod +x $PROC_DIR/*.sh; sh $PROC_DIR/start.sh" 21 | 22 | ssh $REMOTE< /dev/null 2>&1 & 26 | exit 27 | 28 | -------------------------------------------------------------------------------- /deploy/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.jd.blockchain 7 | jdchain-parent 8 | 1.1.9.RELEASE 9 | ../project/parent 10 | 11 | deploy-root 12 | 1.6.5.RELEASE 13 | pom 14 | 15 | 16 | 1.6.5.RELEASE 17 | 18 | 19 | 20 | ../core 21 | deploy-gateway 22 | deploy-peer 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /deploy/deploy-peer/src/main/resources/config/init/mq/mq.config: -------------------------------------------------------------------------------- 1 | # MQ服务URI,格式:{MQ类型前缀}://{MQ URI},当前支持 RabbitMQ(固定第0个节点出块)和ActiveMQ(动态节点出块),前缀分别为:rabbitmq和activemq 2 | system.msg.queue.server=activemq://failover:(tcp://localhost:61616)?initialReconnectDelay=1000&maxReconnectDelay=30000 3 | 4 | # 当前账本交易发送队列主题(不同账本需不同主题) 5 | system.msg.queue.topic.tx=tx 6 | 7 | # 当前账本结块消息应答队列主题 8 | system.msg.queue.topic.tx-result=tx-result 9 | 10 | # 当前账本普通消息主题 11 | system.msg.queue.topic.msg=msg 12 | 13 | # 当前账本普通消息主题 14 | system.msg.queue.topic.msg-result=msg-result 15 | 16 | # 当前账本区块信息主题 17 | system.msg.queue.topic.block=block 18 | 19 | # 当前账本结块最大交易数 20 | system.msg.queue.block.txsize=1000 21 | 22 | # 当前账本结块最大时长(单位:毫秒),小于等于0时将由system.msg.queue.block.txsize决定出块频率 23 | system.msg.queue.block.maxdelay=10 24 | 25 | # 当前账本节点总数 26 | system.servers.num=1 27 | 28 | # 当前账本对应节点的公钥信息列表 29 | system.server.0.pubkey= 30 | -------------------------------------------------------------------------------- /deploy/deploy-peer/src/main/resources/scripts/ledger-init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | HOME=$(cd `dirname $0`;cd ../; pwd) 4 | boot_file=$(ls $HOME/libs | grep tools-initializer-booter-) 5 | JDK_VERSION=$(java -version 2>&1 | sed '1!d' | sed -e 's/"//g' | awk '{print $3}') 6 | if [[ $JDK_VERSION == 1.8.* ]]; then 7 | opens="" 8 | else 9 | opens="--add-opens java.base/java.lang=ALL-UNNAMED" 10 | opens=$opens" --add-opens java.base/java.util=ALL-UNNAMED" 11 | opens=$opens" --add-opens java.base/java.net=ALL-UNNAMED" 12 | opens=$opens" --add-opens java.base/sun.security.x509=ALL-UNNAMED" 13 | opens=$opens" --add-opens java.base/sun.security.util=ALL-UNNAMED" 14 | fi 15 | if [ ! -n "$boot_file" ]; then 16 | echo "tools-initializer-booter is null" 17 | else 18 | java -jar -server $opens -Djdchain.log=$HOME/logs $HOME/libs/$boot_file -l $HOME/config/init/local.conf -i $HOME/config/init/ledger.init $* 19 | fi -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "explorer"] 2 | path = explorer 3 | url = git@github.com:blockchain-jd-com/explorer.git 4 | [submodule "libs/bft-smart"] 5 | path = libs/bft-smart 6 | url = git@github.com:blockchain-jd-com/bftsmart.git 7 | [submodule "project"] 8 | path = project 9 | url = git@github.com:blockchain-jd-com/jdchain-project.git 10 | [submodule "framework"] 11 | path = framework 12 | url = git@github.com:blockchain-jd-com/jdchain-framework.git 13 | branch = 1b8f848 14 | [submodule "core"] 15 | path = core 16 | url = git@github.com:blockchain-jd-com/jdchain-core.git 17 | [submodule "test"] 18 | path = test 19 | url = git@github.com:blockchain-jd-com/jdchain-test.git 20 | [submodule "libs/kvdb"] 21 | path = libs/kvdb 22 | url = git@github.com:blockchain-jd-com/jdchain-kvdb.git 23 | 24 | [submodule "libs/binary-proto"] 25 | path = libs/binary-proto 26 | url = git@github.com:blockchain-jd-com/binary-proto.git 27 | [submodule "libs/utils"] 28 | path = libs/utils 29 | url = git@github.com:blockchain-jd-com/utils.git 30 | [submodule "libs/httpservice"] 31 | path = libs/httpservice 32 | url = git@github.com:blockchain-jd-com/httpservice.git 33 | -------------------------------------------------------------------------------- /deploy/deploy-peer/src/main/resources/config/init/local.conf: -------------------------------------------------------------------------------- 1 | #当前参与方的 id,与ledger.init文件中cons_parti.id一致,默认从0开始 2 | local.parti.id=0 3 | 4 | #当前参与方的公钥,用于非证书模式 5 | local.parti.pubkey= 6 | #当前参与方的证书信息,用于证书模式 7 | local.parti.ca-path= 8 | 9 | #当前参与方的私钥(密文编码) 10 | local.parti.privkey= 11 | #当前参与方的私钥文件,PEM格式,用于证书模式 12 | local.parti.privkey-path= 13 | 14 | #当前参与方的私钥解密密钥(原始口令的一次哈希,Base58格式),如果不设置,则启动过程中需要从控制台输入; 15 | local.parti.pwd= 16 | 17 | #当前参与方的共识服务TLS配置 18 | local.parti.ssl.protocol= 19 | local.parti.ssl.enabled-protocols= 20 | local.parti.ssl.ciphers= 21 | local.parti.ssl.key-store= 22 | local.parti.ssl.key-store-type= 23 | local.parti.ssl.key-alias= 24 | local.parti.ssl.key-store-password= 25 | local.parti.ssl.trust-store= 26 | local.parti.ssl.trust-store-password= 27 | local.parti.ssl.trust-store-type= 28 | 29 | #账本初始化完成后生成的"账本绑定配置文件"的输出目录 30 | #推荐使用绝对路径,相对路径以当前文件(local.conf)所在目录为基准 31 | ledger.binding.out=../ 32 | 33 | #账本数据库的连接字符 34 | #rocksdb数据库连接格式:rocksdb://{path},例如:rocksdb:///export/App08/peer/rocks.db/rocksdb0.db 35 | #redis数据库连接格式:redis://{ip}:{prot}/{db},例如:redis://127.0.0.1:6379/0 36 | #kvdb数据库连接格式:kvdb://{ip}:{prot}/{db},例如:kvdb://127.0.0.1:7078/test 37 | ledger.db.uri= 38 | 39 | #账本数据库的连接口令 40 | ledger.db.pwd= -------------------------------------------------------------------------------- /scripts/compile-latest.sh: -------------------------------------------------------------------------------- 1 | 2 | DIST_BASE_DIR=/usr/local/blockchain/prototype/dist/peer 3 | 4 | cd /usr/local/blockchain/prototype/source/prototype.git/source/ 5 | 6 | 7 | 8 | echo "=========================================" 9 | echo "Begin updating source code" 10 | echo "=========================================" 11 | 12 | git checkout develop 13 | git pull origin develop 14 | 15 | echo "=========================================" 16 | echo "Source code was updated to latest!" 17 | echo "=========================================" 18 | 19 | 20 | echo "=========================================" 21 | echo "Begin compiling" 22 | echo "=========================================" 23 | 24 | mvn clean package -T 2C 25 | 26 | echo "=========================================" 27 | echo "Begin copy artifacts to local dist dir!" 28 | echo "=========================================" 29 | 30 | rm -rf $DIST_BASE_DIR/* 31 | 32 | cp peer/target/peer-*.jar $DIST_BASE_DIR 33 | 34 | cp -r peer/config $DIST_BASE_DIR 35 | cp peer/target/classes/application.properties $DIST_BASE_DIR/config 36 | 37 | cp -r peer/shell/* $DIST_BASE_DIR 38 | 39 | 40 | echo "=========================================" 41 | echo "congratulation! Well done!" 42 | echo "=========================================" 43 | -------------------------------------------------------------------------------- /deploy/deploy-peer/src/main/resources/config/application-peer.properties: -------------------------------------------------------------------------------- 1 | # gzip 2 | server.compression.enabled=true 3 | server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain 4 | 5 | # TLS 6 | #server.ssl.enabled=true 7 | #server.ssl.client-auth=need 8 | #server.ssl.key-store= 9 | #server.ssl.key-store-type=PKCS12 10 | #server.ssl.key-alias= 11 | #server.ssl.key-store-password=123456 12 | #server.ssl.protocol=TLS 13 | #server.ssl.enabled-protocols=TLSv1.2 14 | #server.ssl.trust-store= 15 | #server.ssl.trust-store-password= 16 | #server.ssl.trust-store-type=JKS 17 | #server.ssl.hostNameVerifier=NO-OP 18 | 19 | # GMTLS 20 | #server.ssl.enabled=true 21 | #server.ssl.client-auth=need 22 | #server.ssl.key-store= 23 | #server.ssl.key-store-type=PKCS12 24 | #server.ssl.key-alias= 25 | #server.ssl.key-store-password= 26 | #server.ssl.protocol=GMTLS 27 | #server.ssl.enabled-protocols=GMTLS,TLSv1.2 28 | #server.ssl.ciphers=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,ECC_SM4_CBC_SM3,ECDHE_SM4_GCM_SM3,ECDHE_SM4_CBC_SM3 29 | #server.ssl.trust-store= 30 | #server.ssl.trust-store-password= 31 | #server.ssl.trust-store-type=JKS 32 | #server.ssl.hostNameVerifier=NO-OP 33 | 34 | management.endpoints.web.exposure.include=prometheus 35 | management.metrics.tags.application=peer 36 | 37 | -------------------------------------------------------------------------------- /deploy/deploy-gateway/src/main/resources/config/application-gw.properties: -------------------------------------------------------------------------------- 1 | # gzip 2 | server.compression.enabled=true 3 | server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain 4 | 5 | # TLS 6 | #server.ssl.key-store= 7 | #server.ssl.key-store-type=PKCS12 8 | #server.ssl.key-alias= 9 | #server.ssl.key-store-password=123456 10 | #server.ssl.protocol=TLS 11 | #server.ssl.enabled-protocols=TLSv1.2 12 | #server.ssl.trust-store= 13 | #server.ssl.trust-store-password= 14 | #server.ssl.trust-store-type=JKS 15 | #server.ssl.hostNameVerifier=NO-OP 16 | 17 | # GMTLS 18 | #server.ssl.key-store= 19 | #server.ssl.key-store-type=PKCS12 20 | #server.ssl.key-alias= 21 | #server.ssl.key-store-password= 22 | #server.ssl.protocol=GMTLS 23 | #server.ssl.enabled-protocols=GMTLS,TLSv1.2 24 | #server.ssl.ciphers=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,ECC_SM4_CBC_SM3,ECDHE_SM4_GCM_SM3,ECDHE_SM4_CBC_SM3 25 | #server.ssl.trust-store= 26 | #server.ssl.trust-store-password= 27 | #server.ssl.trust-store-type=JKS 28 | #server.ssl.hostNameVerifier=NO-OP 29 | 30 | # 浏览器鉴权,设置用户名/密码,若没有配置则区块链浏览器完全开放 31 | spring.security.user.name=jdchain 32 | spring.security.user.password=jdchain 33 | # 免鉴权接口 34 | # 提交交易必须开放的接口:账本列表(/ledgers)+秘钥算法配置(/ledgers/*/settings/crypto)+提交交易接口(/rpc/tx) 35 | # 1.6.5默认配置:完全放开网关交易提交和数据查询接口。如有需要请自行修改,修改后重启网关生效。 36 | spring.security.ignored=/ledgers/**,/rpc/tx 37 | -------------------------------------------------------------------------------- /deploy/deploy-peer/src/main/resources/config/init/raft/raft.config: -------------------------------------------------------------------------------- 1 | system.server.0.network.host=127.0.0.1 2 | system.server.0.network.port=16000 3 | system.server.0.network.secure=false 4 | 5 | system.server.1.network.host=127.0.0.1 6 | system.server.1.network.port=16010 7 | system.server.1.network.secure=false 8 | 9 | system.server.2.network.host=127.0.0.1 10 | system.server.2.network.port=16020 11 | system.server.2.network.secure=false 12 | 13 | system.server.3.network.host=127.0.0.1 14 | system.server.3.network.port=16030 15 | system.server.3.network.secure=false 16 | 17 | system.server.block.max.num=100 18 | system.server.block.max.bytes=4194304 19 | 20 | system.server.election.timeout=5000 21 | system.server.snapshot.interval=1800 22 | 23 | system.client.configuration.refresh.interval=60000 24 | 25 | system.server.rpc.connect.timeout=10000 26 | system.server.rpc.default.timeout=10000 27 | system.server.rpc.snapshot.timeout=300000 28 | system.server.rpc.request.timeout=120000 29 | 30 | system.raft.maxByteCountPerRpc=131072 31 | system.raft.maxEntriesSize=1024 32 | system.raft.maxBodySize=524288 33 | system.raft.maxAppendBufferSize=262144 34 | system.raft.maxElectionDelayMs=1000 35 | system.raft.electionHeartbeatFactor=5 36 | system.raft.applyBatch=32 37 | system.raft.sync=true 38 | system.raft.syncMeta=false 39 | system.raft.disruptorBufferSize=16384 40 | system.raft.replicatorPipeline=true 41 | system.raft.maxReplicatorInflightMsgs=256 -------------------------------------------------------------------------------- /scripts/sync-to-all.sh: -------------------------------------------------------------------------------- 1 | 2 | CUR_DIR=`pwd` 3 | 4 | FROM_DIR=/usr/local/blockchain/prototype/dist/peer 5 | PROC_DIR=/usr/local/blockchain/prototype/peer 6 | 7 | REMOTE1=192.168.151.39 8 | REMOTE2=192.168.151.40 9 | REMOTE3=192.168.151.41 10 | 11 | 12 | echo "Begin synchronizing ......" 13 | cd $PROC_DIR 14 | sh $PROC_DIR/stop.sh 15 | 16 | cp -r $FROM_DIR/* $PROC_DIR 17 | 18 | cd $PROC_DIR 19 | chmod +x start.sh stop.sh 20 | sh $PROC_DIR/start.sh 21 | 22 | cd $CUR_DIR 23 | 24 | echo "=========================================" 25 | echo "Success synchronizing local peer!" 26 | echo "=========================================" 27 | 28 | ./sync-to-remote.sh $FROM_DIR $REMOTE1 $PROC_DIR 29 | cd $CUR_DIR 30 | 31 | echo "=========================================" 32 | echo "Success synchronizing REMOTE peer[$REMOTE1]!" 33 | echo "=========================================" 34 | 35 | ./sync-to-remote.sh $FROM_DIR $REMOTE2 $PROC_DIR 36 | cd $CUR_DIR 37 | 38 | echo "=========================================" 39 | echo "Success synchronizing REMOTE peer[$REMOTE2]!" 40 | echo "=========================================" 41 | 42 | #./sync-to-remote.sh $FROM_DIR $REMOTE3 $PROC_DIR 43 | 44 | #echo "=========================================" 45 | #echo "Success synchronizing REMOTE peer[$REMOTE3]!" 46 | #echo "=========================================" 47 | 48 | 49 | echo "=========================================" 50 | echo "Congratulations! All well done!" 51 | echo "=========================================" 52 | -------------------------------------------------------------------------------- /deploy/deploy-gateway/src/main/resources/scripts/shutdown.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #定义程序启动的Jar包前缀 4 | APP_JAR=deploy-gateway- 5 | 6 | #获取当前的根目录 7 | APP_HOME=$(cd `dirname $0`;cd ../; pwd) 8 | 9 | #System路径 10 | APP_LIB_PATH=$APP_HOME/lib 11 | 12 | #APP_JAR的具体路径 13 | APP_JAR_PATH=$APP_LIB_PATH/$APP_JAR 14 | 15 | ################################### 16 | #(函数)判断程序是否已启动 17 | # 18 | #说明: 19 | #使用awk,分割出pid ($1部分),及Java程序名称($2部分) 20 | ################################### 21 | #初始化psid变量(全局) 22 | psid=0 23 | 24 | checkpid() { 25 | psid=`ps -ef | grep $APP_JAR_PATH | grep -v grep | awk '{print $2}'` 26 | } 27 | 28 | ################################### 29 | #(函数)停止程序 30 | # 31 | #说明: 32 | #1. 首先调用checkpid函数,刷新$psid全局变量 33 | #2. 如果程序已经启动($psid不等于0),则开始执行停止,否则,提示程序未运行 34 | #3. 使用kill -9 pid命令进行强制杀死进程 35 | #4. 执行kill命令行紧接其后,马上查看上一句命令的返回值: $? 36 | #5. 如果步骤4的结果$?等于0,则打印[OK],否则打印[Failed] 37 | #注意:echo -n 表示打印字符后,不换行 38 | #注意: 在shell编程中,"$?" 表示上一句命令或者一个函数的返回值 39 | ################################### 40 | stop() { 41 | checkpid 42 | if [[ $psid -ne 0 ]]; then 43 | echo "Stopping Gateway (PID = $psid) ......" 44 | kill $psid 45 | while kill -0 $psid 2>/dev/null; do sleep 1; done 46 | echo "================================" 47 | echo "Success" 48 | echo "================================" 49 | else 50 | echo "================================" 51 | echo "WARN: Gateway is not running" 52 | echo "================================" 53 | fi 54 | } 55 | 56 | 57 | #真正停止的处理流程 58 | stop -------------------------------------------------------------------------------- /deploy/deploy-peer/src/main/resources/scripts/peer-shutdown.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #定义程序启动的Jar包前缀 4 | APP_JAR=deploy-peer- 5 | 6 | #获取当前的根目录 7 | APP_HOME=$(cd `dirname $0`;cd ../; pwd) 8 | 9 | #System路径 10 | APP_SYSTEM_PATH=$APP_HOME/system 11 | 12 | #APP_JAR的具体路径 13 | APP_JAR_PATH=$APP_SYSTEM_PATH/$APP_JAR 14 | 15 | ################################### 16 | #(函数)判断程序是否已启动 17 | # 18 | #说明: 19 | #使用awk,分割出pid ($1部分),及Java程序名称($2部分) 20 | ################################### 21 | #初始化psid变量(全局) 22 | psid=0 23 | 24 | checkpid() { 25 | psid=`ps -ef | grep $APP_JAR_PATH | grep -v grep | awk '{print $2}'` 26 | } 27 | 28 | ################################### 29 | #(函数)停止程序 30 | # 31 | #说明: 32 | #1. 首先调用checkpid函数,刷新$psid全局变量 33 | #2. 如果程序已经启动($psid不等于0),则开始执行停止,否则,提示程序未运行 34 | #3. 使用kill -9 pid命令进行强制杀死进程 35 | #4. 执行kill命令行紧接其后,马上查看上一句命令的返回值: $? 36 | #5. 如果步骤4的结果$?等于0,则打印[OK],否则打印[Failed] 37 | #注意:echo -n 表示打印字符后,不换行 38 | #注意: 在shell编程中,"$?" 表示上一句命令或者一个函数的返回值 39 | ################################### 40 | stop() { 41 | checkpid 42 | if [[ $psid -ne 0 ]]; then 43 | echo "Stopping Peer (PID = $psid) ......" 44 | kill $psid 45 | while kill -0 $psid 2>/dev/null; do sleep 1; done 46 | echo "================================" 47 | echo "Success" 48 | echo "================================" 49 | else 50 | echo "================================" 51 | echo "WARN: Peer is not running" 52 | echo "================================" 53 | fi 54 | } 55 | 56 | 57 | #真正停止的处理流程 58 | stop -------------------------------------------------------------------------------- /deploy/deploy-gateway/src/main/resources/config/gateway.conf: -------------------------------------------------------------------------------- 1 | #网关的HTTP服务地址; 2 | http.host=0.0.0.0 3 | #网关的HTTP服务端口; 4 | http.port=8080 5 | #网关服务是否启用安全证书; 6 | http.secure=false 7 | #网关服务SSL客户端认证模式 8 | https.client-auth=none 9 | #网关的HTTP服务上下文路径,可选; 10 | #http.context-path= 11 | 12 | #共识节点的管理服务地址(与该网关节点连接的Peer节点的IP地址); 13 | peer.host=127.0.0.1 14 | #共识节点的管理服务端口(与该网关节点连接的Peer节点的端口,即在Peer节点的peer-startup.sh中定义的端口); 15 | peer.port=7080 16 | #共识节点的管理服务是否启用安全证书; 17 | peer.secure=false 18 | 19 | #共识节点的共识服务是否启用安全证书; 20 | peer.consensus.secure=false 21 | 22 | #账本节点拓扑信息落盘,默认false 23 | topology.store=false 24 | 25 | #是否开启共识节点自动感知,默认true 26 | topology.aware=true 27 | 28 | #共识节点自动感知间隔(毫秒),0及负值表示仅感知一次。对于不存在节点变更的场景感知一次即可 29 | topology.aware.interval=0 30 | 31 | #节点连接心跳(毫秒),及时感知连接有效性,0及负值表示关闭 32 | peer.connection.ping=3000 33 | 34 | #节点连接认证(毫秒),及时感知连接合法性,0及负值表示关闭。对于不存在账本数量变更、权限变更的场景可关闭 35 | peer.connection.auth=0 36 | 37 | #共识节点的服务提供解析器 38 | #BftSmart共识Provider:com.jd.blockchain.consensus.bftsmart.BftsmartConsensusProvider 39 | #简单消息共识Provider:com.jd.blockchain.consensus.mq.MsgQueueConsensusProvider 40 | peer.providers=com.jd.blockchain.consensus.bftsmart.BftsmartConsensusProvider 41 | 42 | #数据检索服务对应URL,格式:http://{ip}:{port},例如:http://127.0.0.1:10001 43 | #若该值不配置或配置不正确,则浏览器模糊查询部分无法正常显示 44 | data.retrieval.url= 45 | schema.retrieval.url= 46 | 47 | #默认公钥的内容(Base58编码数据),非CA模式下必填; 48 | keys.default.pubkey= 49 | #默认网关证书路径(X509,PEM),CA模式下必填; 50 | keys.default.ca-path= 51 | #默认私钥的路径;在 pk-path 和 pk 之间必须设置其一; 52 | keys.default.privkey-path= 53 | #默认私钥的内容;在 pk-path 和 pk 之间必须设置其一; 54 | keys.default.privkey= 55 | #默认私钥的解码密码; 56 | keys.default.privkey-password= 57 | -------------------------------------------------------------------------------- /deploy/deploy-gateway/src/main/resources/assembly.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | ${project.version} 7 | 8 | zip 9 | 10 | false 11 | 12 | 13 | src/main/resources/scripts 14 | bin 15 | unix 16 | 17 | 18 | src/main/resources/config 19 | config 20 | unix 21 | 22 | 23 | ../../docs 24 | docs 25 | unix 26 | 27 | 28 | 29 | 30 | 31 | false 32 | true 33 | lib 34 | 35 | com.jd.blockchain:deploy-gateway 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **.classpath 2 | **.project 3 | **/bin/ 4 | **.class 5 | 6 | target/ 7 | 8 | build/local.sh 9 | 10 | *.bak 11 | bin/ 12 | *.iml 13 | *.ipr 14 | *.iws 15 | .idea 16 | .classpath 17 | .project 18 | .settings/ 19 | .DS_Store 20 | .springBeans 21 | .externalToolBuilders/ 22 | 23 | *.versionsBackup 24 | .factorypath 25 | source/**/config/currentView 26 | source/gateway/data/ 27 | source/peer/data/ 28 | *.orig 29 | source/peer/config/view/current.view 30 | source/contract/contract-jar/src/main/java/com/jd/blockchain/contract/*.contract 31 | source/contract/contract-jar/src/main/java/com/jd/blockchain/contract/contract.properties 32 | source/contract/logs 33 | source/contract/tmp 34 | source/contract/contract-model/src/main/resources/contractCoreLib/ 35 | *.db 36 | *.log 37 | source/test/test-integration/txs 38 | contract-libs/coreLib/contract-model-0.6.0-SNAPSHOT.jar 39 | contract-libs/coreLib/crypto-framework-0.6.0-SNAPSHOT.jar 40 | contract-libs/coreLib/ledger-model-0.6.0-SNAPSHOT.jar 41 | contract-libs/coreLib/sdk-base-0.6.0-SNAPSHOT.jar 42 | contract-libs/coreLib/utils-common-1.6.1-SNAPSHOT.jar 43 | source/tools/tools-initializer/bftsmart.config 44 | test/test-integration/runtime/ 45 | deploy/docker/docker-demo/docker/zip/docker-sdk-1.4.0.RELEASE.jar 46 | deploy/docker/docker-demo/docker/zip/jdchain-gateway-1.4.0.RELEASE.zip 47 | deploy/docker/docker-demo/docker/zip/jdchain-peer-1.4.0.RELEASE.zip 48 | deploy/docker/docker-demo/src/main/docker/zip/docker-sdk-1.4.0.RELEASE.jar 49 | deploy/docker/docker-demo/src/main/docker/zip/jdchain-gateway-1.4.0.RELEASE.zip 50 | deploy/docker/docker-demo/src/main/docker/zip/jdchain-peer-1.4.0.RELEASE.zip 51 | docker-sdk-1.4.1.RELEASE.jar 52 | jdchain-gateway-1.4.1.RELEASE.zip 53 | jdchain-peer-1.4.1.RELEASE.zip 54 | deploy/docker/docker-demo/src/main/docker/zip 55 | runtime 56 | .run 57 | -------------------------------------------------------------------------------- /deploy/deploy-gateway/src/main/resources/config/log4j2-gw.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /deploy/deploy-peer/src/main/java/com/jd/blockchain/boot/peer/PeerBooter.java: -------------------------------------------------------------------------------- 1 | package com.jd.blockchain.boot.peer; 2 | 3 | import com.jd.blockchain.runtime.boot.HomeBooter; 4 | import com.jd.blockchain.runtime.boot.HomeContext; 5 | 6 | import java.io.File; 7 | import java.io.FileOutputStream; 8 | import java.io.IOException; 9 | import java.lang.management.ManagementFactory; 10 | import java.lang.reflect.InvocationTargetException; 11 | import java.lang.reflect.Method; 12 | import java.nio.charset.StandardCharsets; 13 | import java.util.ArrayList; 14 | import java.util.Arrays; 15 | import java.util.Date; 16 | import java.util.List; 17 | 18 | /** 19 | * Peer 启动器; 20 | * 21 | * @author huanghaiquan 22 | * 23 | */ 24 | public class PeerBooter { 25 | 26 | public static final String MODULAR_FACTORY_CLASS = "com.jd.blockchain.runtime.modular.ModularFactory"; 27 | 28 | public static final String MODULAR_FACTORY_METHOD = "startSystem"; 29 | 30 | public static final Class[] MODULAR_FACTORY_METHOD_ARG_TYPES = { String.class, String.class, boolean.class, ClassLoader.class, 31 | String.class, ClassLoader.class, String[].class }; 32 | 33 | public static final String SYSTEM_MAIN_CLASS = "com.jd.blockchain.peer.PeerServerBooter"; 34 | 35 | public static void main(String[] args) { 36 | try { 37 | HomeContext homeContext = HomeBooter.createHomeContext(args); 38 | startPeer(homeContext); 39 | } catch (Exception e) { 40 | e.printStackTrace(); 41 | } 42 | } 43 | 44 | public static void startPeer(HomeContext home) throws IOException, ClassNotFoundException, NoSuchMethodException, 45 | SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { 46 | 47 | // start system; 48 | Class modularFactoryClass = home.getSystemClassLoader().loadClass(MODULAR_FACTORY_CLASS); 49 | Method modularFactoryMethod = modularFactoryClass.getMethod(MODULAR_FACTORY_METHOD, 50 | MODULAR_FACTORY_METHOD_ARG_TYPES); 51 | 52 | Object[] systemStartingArgs = { home.getRuntimeDir(), home.getLibsDir(), home.isProductMode(), home.getLibsClassLoader(), 53 | SYSTEM_MAIN_CLASS, home.getSystemClassLoader(), home.getStartingArgs() }; 54 | modularFactoryMethod.invoke(null, systemStartingArgs); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /deploy/deploy-peer/src/main/resources/config/log4j2-peer.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![logo](http://storage.jd.com/jd.block.chain/jdt-jdchain.png) 2 | 3 | [![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) 4 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.jd.blockchain/sdk/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.jd.blockchain/sdk/) 5 | [![Build Status](https://travis-ci.com/blockchain-jd-com/jdchain.svg?branch=master)](https://travis-ci.org/blockchain-jd-com/jdchain) 6 | 7 | 一个面向企业应用场景的通用区块链框架系统,能够作为企业级基础设施,为业务创新提供高效、灵活和安全的解决方案。 8 | 9 | ## 源码构建 10 | 11 | `JD Chain`源码通过`git`及`git submodule`进行管理,如下操作可快速构建: 12 | 13 | ```bash 14 | $ git clone https://github.com/blockchain-jd-com/jdchain.git jdchain 15 | 16 | $ cd jdchain 17 | 18 | # 此处仅以 master 分支为例,正常情况下 master 分支可无障碍构建成功 19 | # 不推荐使用 develop 分支,submodule 代码可能未对齐 20 | # 推荐切换到具体已发布的版本分支 21 | $ git checkout master 22 | 23 | $ chmod +x build/*.sh 24 | 25 | # 执行完整的构建,包括执行”集成测试“和”打包“两部分;提供两个参数: 26 | # --skipTests :跳过集成测试部分; 27 | # --update :从远程仓库更新子模块。注意,采用此参数会导致子模块本地仓库丢失尚未 commit 的代码。 28 | # 不附带此参数的情况下不会更新子模块仓库。 29 | $ build/build.sh --update 30 | 31 | # 跳过子模块代码更新和集成测试,直接编译和打包; 32 | $ build/build.sh --skipTests 33 | 34 | # 首次代码拉取,跳过集成测试和编译打包可执行: 35 | $ build/build.sh --update --skipTests 36 | ``` 37 | 38 | 构建完成后会在`deploy`模块,`deploy-gateway`和`deploy-peer`目录`target`中生成网关安装部署包(`jdchain-gateway-*.zip`)和共识节点安装部署包(`jdchain-peer-*.zip`)。 39 | 40 | 41 | ## 部署使用 42 | 43 | ### 快速部署 44 | 45 | 使用[源码构建](#源码构建)生成的部署安装包,或者下载[官方部署安装包](https://blockchain-jd-com.github.io/#/download) 参照[快速部署文档](https://blockchain-jd-com.github.io/#/install/testnet?id=%e5%91%bd%e4%bb%a4%e8%a1%8c%e6%96%b9%e5%bc%8f%e3%80%90%e6%8e%a8%e8%8d%90%e3%80%91)可快速部署运行`JD Chain`网络。 46 | 47 | ### 数据上链 48 | 49 | 1. 命令行工具 50 | 51 | `JD Chain` 命令行工具集,即[jdchain-cli](https://blockchain-jd-com.github.io/#/cli/tx),可快速执行数据上链和链上数据查询。 52 | 53 | 2. SDK 54 | 55 | `JD Chain`提供了`Java`和`Go`版本的`SDK`。实际项目开发中`Java`可参照[示例代码](https://github.com/blockchain-jd-com/jdchain-samples),`Go`语言`SDK`参照[framework-go](https://github.com/blockchain-jd-com/framework-go/blob/master/sdk/test/tx_test.go)。 56 | 57 | ### 更多 58 | 59 | `JD Chain`功能开发,使用问题等欢迎`issue`中探讨,也欢迎广大开发者积极参与`JD Chain`社区活动及代码开发~ 60 | 61 | - 文档:[docs](https://ledger.jd.com/doc/) 62 | - `JD Chain`官网:https://ledger.jd.com/ 63 | - 京东智臻链官网:https://blockchain.jd.com/ 64 | - 服务邮箱:jdchain-support@jd.com 65 | -------------------------------------------------------------------------------- /deploy/deploy-gateway/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.jd.blockchain 7 | deploy-root 8 | 1.6.5.RELEASE 9 | 10 | deploy-gateway 11 | 12 | 13 | 14 | 15 | com.jd.blockchain 16 | gateway 17 | ${core.version} 18 | 19 | 20 | com.jd.blockchain 21 | consensus-bftsmart 22 | ${core.version} 23 | 24 | 25 | 26 | com.jd.blockchain 27 | consensus-mq 28 | ${core.version} 29 | 30 | 31 | 41 | 42 | 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-maven-plugin 48 | 49 | true 50 | 51 | 53 | 54 | 55 | org.apache.maven.plugins 56 | maven-assembly-plugin 57 | 58 | 59 | make-assembly 60 | package 61 | 62 | single 63 | 64 | 65 | jdchain-gateway 66 | 67 | src/main/resources/assembly.xml 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | net.nicoulaj.maven.plugins 77 | checksum-maven-plugin 78 | 1.8 79 | 80 | 81 | 82 | artifacts 83 | 84 | 85 | 86 | 87 | 88 | SHA-256 89 | 90 | ${project.basedir}/target/deployment-peer-${project.version}.zip 91 | true 92 | ${project.basedir}/target/SHA-256.xml 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /deploy/deploy-gateway/src/main/resources/scripts/startup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #设置Java命令 4 | JAVA_BIN=java 5 | 6 | #定义程序启动的Jar包前缀 7 | APP_JAR_PREFIX=deploy-gateway- 8 | 9 | #检查Java环境变量 10 | if [ ! -n "$JAVA_HOME" ]; then 11 | echo "UnFound environment variable[JAVA_HOME], will use command[java]..." 12 | else 13 | JAVA_BIN=$JAVA_HOME/bin/java 14 | fi 15 | 16 | #获取当前的根目录 17 | APP_HOME=$(cd `dirname $0`;cd ../; pwd) 18 | 19 | #Lib目录 20 | APP_LIB_PATH=$APP_HOME/lib 21 | 22 | #nohup输出日志路径 23 | LOG_OUT=$APP_HOME/bin/gw.out 24 | 25 | #获取Peer节点的启动Jar包 26 | APP_JAR=$(ls $APP_LIB_PATH | grep $APP_JAR_PREFIX) 27 | 28 | #Config配置路径 29 | CONFIG_PATH=$APP_HOME/config 30 | 31 | #gateway.conf完整路径 32 | GATEWAY_CONFIG=$CONFIG_PATH/gateway.conf 33 | 34 | #application-gw.properties完整路径 35 | SPRING_CONFIG=$CONFIG_PATH/application-gw.properties 36 | 37 | JDK_VERSION=$(java -version 2>&1 | sed '1!d' | sed -e 's/"//g' | awk '{print $3}') 38 | if [[ $JDK_VERSION == 1.8.* ]]; then 39 | opens="" 40 | else 41 | opens="--add-opens java.base/java.lang=ALL-UNNAMED" 42 | opens=$opens" --add-opens java.base/java.util=ALL-UNNAMED" 43 | opens=$opens" --add-opens java.base/java.net=ALL-UNNAMED" 44 | opens=$opens" --add-opens java.base/sun.security.x509=ALL-UNNAMED" 45 | opens=$opens" --add-opens java.base/sun.security.util=ALL-UNNAMED" 46 | fi 47 | 48 | #定义程序启动的参数 49 | JAVA_OPTS="-jar -server -Xms1024m -Xmx1024m $opens -Djdchain.log=$APP_HOME/logs -Dlog4j.configurationFile=file:$APP_HOME/config/log4j2-gw.xml" 50 | 51 | #APP具体相关命令 52 | APP_CMD=$APP_LIB_PATH/$APP_JAR" -c "$GATEWAY_CONFIG" -sp "$SPRING_CONFIG 53 | 54 | #APP_JAR的具体路径 55 | APP_JAR_PATH=$APP_LIB_PATH/$APP_JAR 56 | 57 | #JAVA_CMD具体命令 58 | JAVA_CMD="$JAVA_BIN $JAVA_OPTS $APP_CMD" 59 | 60 | ################################### 61 | #(函数)判断程序是否已启动 62 | # 63 | #说明: 64 | #使用awk,分割出pid ($1部分),及Java程序名称($2部分) 65 | ################################### 66 | #初始化psid变量(全局) 67 | psid=0 68 | 69 | checkpid() { 70 | javaps=`ps -ef | grep $APP_JAR_PATH | grep -v grep | awk '{print $2}'` 71 | 72 | if [[ -n "$javaps" ]]; then 73 | psid=$javaps 74 | else 75 | psid=0 76 | fi 77 | } 78 | 79 | ################################### 80 | #(函数)打印系统环境参数 81 | ################################### 82 | info() { 83 | echo "System Information:" 84 | echo "****************************" 85 | echo `uname -a` 86 | echo 87 | echo `$JAVA_BIN -version` 88 | echo 89 | echo "APP_HOME=$APP_HOME" 90 | echo "APP_JAR=$APP_JAR" 91 | echo "CONFIG_PATH=$CONFIG_PATH" 92 | echo "APP_JAR_PATH=$APP_JAR_PATH" 93 | echo 94 | echo "JAVA_CMD=$JAVA_CMD" 95 | echo "****************************" 96 | } 97 | 98 | #真正启动的处理流程 99 | checkpid 100 | 101 | if [[ $psid -ne 0 ]]; then 102 | echo "================================" 103 | echo "warn: Gateway already started! (pid=$psid)" 104 | echo "================================" 105 | else 106 | echo "Starting Gateway ......" 107 | nohup $JAVA_BIN $JAVA_OPTS $APP_CMD $* >$LOG_OUT 2>&1 & 108 | JAVA_CMD="$JAVA_BIN $JAVA_OPTS $APP_CMD $*" 109 | sleep 1 110 | checkpid 111 | if [[ $psid -ne 0 ]]; then 112 | echo "(pid=$psid) [OK]" 113 | info 114 | else 115 | echo "[Failed]" 116 | fi 117 | fi -------------------------------------------------------------------------------- /deploy/deploy-peer/src/main/resources/scripts/peer-startup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #设置Java命令 4 | JAVA_BIN=java 5 | 6 | #定义程序启动的Jar包前缀 7 | APP_JAR_PREFIX=deploy-peer- 8 | 9 | #Peer节点Web端口 10 | #请运维根据实际环境进行调整或通过-p参数传入 11 | WEB_PORT=7080 12 | #端口配置参数 13 | IS_CONFIG=false 14 | for i in "$@"; do 15 | if [ $i = "-p" ];then 16 | IS_CONFIG=true 17 | fi 18 | done 19 | 20 | #检查Java环境变量 21 | if [ ! -n "$JAVA_HOME" ]; then 22 | echo "UnFound environment variable[JAVA_HOME], will use command[java]..." 23 | else 24 | JAVA_BIN=$JAVA_HOME/bin/java 25 | fi 26 | 27 | #获取当前的根目录 28 | APP_HOME=$(cd `dirname $0`;cd ../; pwd) 29 | 30 | #System目录 31 | APP_SYSTEM_PATH=$APP_HOME/system 32 | 33 | #nohup输出日志路径 34 | LOG_OUT=$APP_HOME/bin/peer.out 35 | 36 | #获取Peer节点的启动Jar包 37 | APP_JAR=$(ls $APP_SYSTEM_PATH | grep $APP_JAR_PREFIX) 38 | 39 | #Config配置路径 40 | CONFIG_PATH=$APP_HOME/config 41 | 42 | #ledger-binding.conf完整路径 43 | LEDGER_BINDING_CONFIG=$CONFIG_PATH/ledger-binding.conf 44 | 45 | #application-peer.properties完整路径 46 | SPRING_CONFIG=$CONFIG_PATH/application-peer.properties 47 | 48 | JDK_VERSION=$(java -version 2>&1 | sed '1!d' | sed -e 's/"//g' | awk '{print $3}') 49 | if [[ $JDK_VERSION == 1.8.* ]]; then 50 | opens="" 51 | else 52 | opens="--add-opens java.base/java.lang=ALL-UNNAMED" 53 | opens=$opens" --add-opens java.base/java.util=ALL-UNNAMED" 54 | opens=$opens" --add-opens java.base/java.net=ALL-UNNAMED" 55 | opens=$opens" --add-opens java.base/sun.security.x509=ALL-UNNAMED" 56 | opens=$opens" --add-opens java.base/sun.security.util=ALL-UNNAMED" 57 | fi 58 | 59 | #定义程序启动的参数 60 | JAVA_OPTS="-jar -server -Xms2048m -Xmx2048m $opens -Djdchain.log=$APP_HOME/logs -Dlog4j.configurationFile=file:$APP_HOME/config/log4j2-peer.xml -Dpolyglot.engine.WarnInterpreterOnly=false" 61 | 62 | #APP具体相关命令 63 | APP_CMD=$APP_SYSTEM_PATH/$APP_JAR" -home="$APP_HOME" -c "$LEDGER_BINDING_CONFIG" -p "$WEB_PORT" -sp "$SPRING_CONFIG 64 | if [ $IS_CONFIG = true ];then 65 | APP_CMD=$APP_SYSTEM_PATH/$APP_JAR" -home="$APP_HOME" -c "$LEDGER_BINDING_CONFIG" -sp "$SPRING_CONFIG 66 | fi 67 | 68 | #APP_JAR的具体路径 69 | APP_JAR_PATH=$APP_SYSTEM_PATH/$APP_JAR 70 | 71 | #JAVA_CMD具体命令 72 | JAVA_CMD="$JAVA_BIN $JAVA_OPTS $APP_CMD" 73 | 74 | ################################### 75 | #(函数)判断程序是否已启动 76 | # 77 | #说明: 78 | #使用awk,分割出pid ($1部分),及Java程序名称($2部分) 79 | ################################### 80 | #初始化psid变量(全局) 81 | psid=0 82 | 83 | checkpid() { 84 | javaps=`ps -ef | grep $APP_JAR_PATH | grep -v grep | awk '{print $2}'` 85 | 86 | if [[ -n "$javaps" ]]; then 87 | psid=$javaps 88 | else 89 | psid=0 90 | fi 91 | } 92 | 93 | ################################### 94 | #(函数)打印系统环境参数 95 | ################################### 96 | info() { 97 | echo "System Information:" 98 | echo "****************************" 99 | echo `uname -a` 100 | echo 101 | echo `$JAVA_BIN -version` 102 | echo 103 | echo "APP_HOME=$APP_HOME" 104 | echo "APP_JAR=$APP_JAR" 105 | echo "CONFIG_PATH=$CONFIG_PATH" 106 | echo "APP_JAR_PATH=$APP_JAR_PATH" 107 | echo 108 | echo "JAVA_CMD=$JAVA_CMD" 109 | echo "****************************" 110 | } 111 | 112 | #真正启动的处理流程 113 | checkpid 114 | 115 | if [[ $psid -ne 0 ]]; then 116 | echo "================================" 117 | echo "warn: Peer already started! (pid=$psid)" 118 | echo "================================" 119 | else 120 | echo "Starting Peer ......" 121 | nohup $JAVA_BIN $JAVA_OPTS $APP_CMD $* >$LOG_OUT 2>&1 & 122 | JAVA_CMD="$JAVA_BIN $JAVA_OPTS $APP_CMD $*" 123 | sleep 1 124 | checkpid 125 | if [[ $psid -ne 0 ]]; then 126 | echo "(pid=$psid) [OK]" 127 | info 128 | else 129 | echo "[Failed]" 130 | fi 131 | fi -------------------------------------------------------------------------------- /deploy/deploy-peer/src/main/resources/assembly.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | ${project.version} 7 | 8 | zip 9 | 10 | false 11 | 12 | 13 | src/main/resources/scripts 14 | bin 15 | unix 16 | 17 | 18 | src/main/resources/config 19 | config 20 | unix 21 | 22 | 23 | ../../docs 24 | docs 25 | unix 26 | 27 | 28 | ${basedir}/../../libs/utils/utils-crypto-sm/lib 29 | libs 30 | 31 | 32 | ${basedir}/../../core/consensus/consensus-raft/lib 33 | libs 34 | 35 | 36 | ${basedir}/../../core/contract/contract-jvm/lib 37 | libs 38 | 39 | 40 | 41 | 42 | false 43 | true 44 | system 45 | 46 | com.jd.blockchain:ledger-core 47 | 48 | com.jd.blockchain:storage-rocksdb 49 | com.jd.blockchain:storage-redis 50 | com.jd.blockchain:storage-kvdb 51 | com.jd.blockchain:storage-composite 52 | com.jd.blockchain:runtime-modular 53 | com.jd.blockchain:runtime-modular-booter 54 | com.jd.blockchain:peer 55 | com.jd.blockchain:deploy-peer 56 | 57 | 58 | 59 | false 60 | true 61 | libs 62 | 63 | com.jd.blockchain:ledger-core 64 | 65 | com.jd.blockchain:storage-rocksdb 66 | com.jd.blockchain:storage-redis 67 | com.jd.blockchain:storage-kvdb 68 | com.jd.blockchain:storage-composite 69 | com.jd.blockchain:runtime-modular 70 | com.jd.blockchain:runtime-modular-booter 71 | com.jd.blockchain:peer 72 | com.jd.blockchain:deployment-peer 73 | 74 | 75 | 76 | 84 | 85 | 86 | 87 | 88 | 89 | true 90 | 91 | com.jd.blockchain:tools-initializer-booter 92 | com.jd.blockchain:tools-keygen-booter 93 | 94 | 95 | libs 96 | false 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /deploy/deploy-peer/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.jd.blockchain 7 | deploy-root 8 | 1.6.5.RELEASE 9 | 10 | deploy-peer 11 | 12 | 13 | 14 | com.jd.blockchain 15 | peer 16 | ${core.version} 17 | 18 | 19 | com.jd.blockchain 20 | runtime-modular 21 | ${core.version} 22 | 23 | 24 | com.jd.blockchain 25 | runtime-modular-booter 26 | ${core.version} 27 | 28 | 29 | com.jd.blockchain 30 | storage-redis 31 | ${core.version} 32 | 33 | 34 | com.jd.blockchain 35 | storage-rocksdb 36 | ${core.version} 37 | 38 | 39 | com.jd.blockchain 40 | storage-kvdb 41 | ${core.version} 42 | 43 | 44 | 45 | com.jd.blockchain 46 | tools-initializer-booter 47 | ${core.version} 48 | 49 | 50 | 51 | com.jd.blockchain 52 | tools-keygen-booter 53 | ${core.version} 54 | 55 | 56 | 57 | com.jd.blockchain 58 | jdchain-cli 59 | ${core.version} 60 | 61 | 62 | 63 | 64 | 65 | 66 | 74 | 75 | 76 | org.apache.maven.plugins 77 | maven-jar-plugin 78 | 79 | 80 | 81 | com.jd.blockchain.boot.peer.PeerBooter 82 | true 83 | . 84 | false 85 | 86 | 87 | 88 | 89 | 90 | org.apache.maven.plugins 91 | maven-assembly-plugin 92 | 93 | 94 | make-assembly 95 | package 96 | 97 | single 98 | 99 | 100 | jdchain-peer 101 | 102 | src/main/resources/assembly.xml 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | net.nicoulaj.maven.plugins 112 | checksum-maven-plugin 113 | 1.8 114 | 115 | 116 | 117 | artifacts 118 | 119 | 120 | 121 | 122 | 123 | SHA-256 124 | 125 | ${project.basedir}/target/deployment-peer-${project.version}.zip 126 | true 127 | ${project.basedir}/target/SHA-256.xml 128 | 129 | 130 | 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /deploy/deploy-peer/src/main/resources/config/init/ledger.init: -------------------------------------------------------------------------------- 1 | #账本的种子;一段16进制字符,最长可以包含64个字符;可以用字符“-”分隔,以便更容易读取; 2 | ledger.seed=932dfe23-fe23232f-283f32fa-dd32aa76-8322ca2f-56236cda-7136b322-cb323ffe 3 | 4 | #账本的描述名称;此属性不参与共识,仅仅在当前参与方的本地节点用于描述用途; 5 | ledger.name= 6 | 7 | #身份认证模式:KEYPAIR/CA,默认KEYPAIR即公私钥对模式 8 | identity-mode=KEYPAIR 9 | 10 | #账本根证书路径,identity-mode 为 CA 时,此选项不能为空,支持多个,半角逗号相隔 11 | root-ca-path= 12 | 13 | #声明的账本创建时间;格式为 “yyyy-MM-dd HH:mm:ss.SSSZ”,表示”年-月-日 时:分:秒:毫秒时区“;例如:“2019-08-01 14:26:58.069+0800”,其中,+0800 表示时区是东8区 14 | created-time=2019-08-01 14:26:58.069+0800 15 | 16 | #账本数据底层结构,分为:MERKLE_TREE, KV两种,默认MERKLE_TREE 17 | ledger.data.structure=MERKLE_TREE 18 | 19 | #合约运行超时时间,单位:毫秒,默认1分钟 20 | contract.timeout=60000 21 | 22 | #----------------------------------------------- 23 | # 初始的角色名称列表;可选项; 24 | # 角色名称不区分大小写,最长不超过20个字符;多个角色名称之间用半角的逗点“,”分隔; 25 | # 系统会预置一个默认角色“DEFAULT”,所有未指定角色的用户都以赋予该角色的权限;若初始化时未配置默认角色的权限,则为默认角色分配所有权限; 26 | # 27 | # 注:如果声明了角色,但未声明角色对应的权限清单,这会忽略该角色的初始化; 28 | # 29 | #security.roles=DEFAULT, ADMIN, MANAGER, GUEST 30 | 31 | # 赋予角色的账本权限清单;可选项; 32 | # 可选的权限如下; 33 | # AUTHORIZE_ROLES, SET_CONSENSUS, SET_CRYPTO, REGISTER_PARTICIPANT, 34 | # REGISTER_USER, REGISTER_DATA_ACCOUNT, REGISTER_CONTRACT, UPGRADE_CONTRACT, 35 | # SET_USER_ATTRIBUTES, WRITE_DATA_ACCOUNT, 36 | # APPROVE_TX, CONSENSUS_TX 37 | # 多项权限之间用逗点“,”分隔; 38 | # 39 | #security.role.DEFAULT.ledger-privileges=REGISTER_USER, REGISTER_DATA_ACCOUNT 40 | 41 | # 赋予角色的交易权限清单;可选项; 42 | # 可选的权限如下; 43 | # DIRECT_OPERATION, CONTRACT_OPERATION 44 | # 多项权限之间用逗点“,”分隔; 45 | # 46 | #security.role.DEFAULT.tx-privileges=DIRECT_OPERATION, CONTRACT_OPERATION 47 | 48 | # 其它角色的配置示例; 49 | # 系统管理员角色:只能操作全局性的参数配置和用户注册,只能执行直接操作指令; 50 | #security.role.ADMIN.ledger-privileges=CONFIGURE_ROLES, AUTHORIZE_USER_ROLES, SET_CONSENSUS, SET_CRYPTO, REGISTER_PARTICIPANT, REGISTER_USER 51 | #security.role.ADMIN.tx-privileges=DIRECT_OPERATION 52 | 53 | # 业务主管角色:只能够执行账本数据相关的操作,包括注册用户、注册数据账户、注册合约、升级合约、写入数据等;能够执行直接操作指令和调用合约; 54 | #security.role.MANAGER.ledger-privileges=CONFIGURE_ROLES, AUTHORIZE_USER_ROLES, REGISTER_USER, REGISTER_DATA_ACCOUNT, REGISTER_CONTRACT, UPGRADE_CONTRACT, SET_USER_ATTRIBUTES, WRITE_DATA_ACCOUNT, 55 | #security.role.MANAGER.tx-privileges=DIRECT_OPERATION, CONTRACT_OPERATION 56 | 57 | # 访客角色:不具备任何的账本权限,只有数据读取的操作;也只能够通过调用合约来读取数据; 58 | #security.role.GUEST.ledger-privileges= 59 | #security.role.GUEST.tx-privileges=CONTRACT_OPERATION 60 | 61 | #----------------------------------------------- 62 | #共识服务提供者;必须; 63 | #consensus.service-provider 64 | #共识服务的参数配置;推荐使用绝对路径;必须; 65 | #consensus.conf 66 | 67 | # BFT共识配置 68 | consensus.service-provider=com.jd.blockchain.consensus.bftsmart.BftsmartConsensusProvider 69 | consensus.conf=bftsmart/bftsmart.config 70 | 71 | # RAFT共识配置 72 | #consensus.service-provider=com.jd.blockchain.consensus.raft.RaftConsensusProvider 73 | #consensus.conf=raft/raft.config 74 | 75 | # MQ共识配置 76 | #consensus.service-provider=com.jd.blockchain.consensus.mq.MsgQueueConsensusProvider 77 | #consensus.conf=mq/mq.config 78 | 79 | #------------------------------------------------ 80 | 81 | #密码服务提供者列表,以英文逗点“,”分隔;必须; 82 | crypto.service-providers=com.jd.blockchain.crypto.service.classic.ClassicCryptoService, \ 83 | com.jd.blockchain.crypto.service.sm.SMCryptoService, \ 84 | com.jd.blockchain.crypto.service.adv.AdvCryptoService 85 | 86 | #从存储中加载账本数据时,是否校验哈希;可选; 87 | crypto.verify-hash=true 88 | 89 | #哈希算法; 90 | crypto.hash-algorithm=SHA256 91 | 92 | 93 | #参与方的个数,后续以 cons_parti.id 分别标识每一个参与方的配置; 94 | cons_parti.count=4 95 | 96 | #--------------------- 97 | #第0个参与方的名称; 98 | cons_parti.0.name= 99 | #第0个参与方的公钥文件路径; 100 | cons_parti.0.pubkey-path= 101 | #第0个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; 102 | cons_parti.0.pubkey= 103 | #第0个参与方的证书路径,identity-mode 为 CA 时,此选项不能为空 104 | cons_parti.0.ca-path= 105 | 106 | #第0个参与方的角色清单;可选项; 107 | #cons_parti.0.roles=ADMIN, MANAGER 108 | #第0个参与方的角色权限策略,可选值有:UNION(并集),INTERSECT(交集);可选项; 109 | #cons_parti.0.roles-policy=UNION 110 | 111 | #第0个参与方的账本初始服务的主机; 112 | cons_parti.0.initializer.host=127.0.0.1 113 | #第0个参与方的账本初始服务的端口; 114 | cons_parti.0.initializer.port=8800 115 | #第0个参与方的账本初始服务是否开启安全连接; 116 | cons_parti.0.initializer.secure=false 117 | 118 | #--------------------- 119 | #第1个参与方的名称; 120 | cons_parti.1.name= 121 | #第1个参与方的公钥文件路径; 122 | cons_parti.1.pubkey-path= 123 | #第1个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; 124 | cons_parti.1.pubkey= 125 | #第1个参与方的证书路径,identity-mode 为 CA 时,此选项不能为空 126 | cons_parti.1.ca-path= 127 | 128 | #第1个参与方的角色清单;可选项; 129 | #cons_parti.1.roles=MANAGER 130 | #第1个参与方的角色权限策略,可选值有:UNION(并集),INTERSECT(交集);可选项; 131 | #cons_parti.1.roles-policy=UNION 132 | 133 | #第1个参与方的账本初始服务的主机; 134 | cons_parti.1.initializer.host=127.0.0.1 135 | #第1个参与方的账本初始服务的端口; 136 | cons_parti.1.initializer.port=8810 137 | #第1个参与方的账本初始服务是否开启安全连接; 138 | cons_parti.1.initializer.secure=false 139 | 140 | #--------------------- 141 | #第2个参与方的名称; 142 | cons_parti.2.name= 143 | #第2个参与方的公钥文件路径; 144 | cons_parti.2.pubkey-path= 145 | #第2个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; 146 | cons_parti.2.pubkey= 147 | #第2个参与方的证书路径,identity-mode 为 CA 时,此选项不能为空 148 | cons_parti.2.ca-path= 149 | 150 | #第2个参与方的角色清单;可选项; 151 | #cons_parti.2.roles=MANAGER 152 | #第2个参与方的角色权限策略,可选值有:UNION(并集),INTERSECT(交集);可选项; 153 | #cons_parti.2.roles-policy=UNION 154 | 155 | #第2个参与方的账本初始服务的主机; 156 | cons_parti.2.initializer.host=127.0.0.1 157 | #第2个参与方的账本初始服务的端口; 158 | cons_parti.2.initializer.port=8820 159 | #第2个参与方的账本初始服务是否开启安全连接; 160 | cons_parti.2.initializer.secure=false 161 | 162 | #--------------------- 163 | #第3个参与方的名称; 164 | cons_parti.3.name= 165 | #第3个参与方的公钥文件路径; 166 | cons_parti.3.pubkey-path= 167 | #第3个参与方的公钥内容(由keygen工具生成);此参数优先于 pubkey-path 参数; 168 | cons_parti.3.pubkey= 169 | #第1个参与方的证书路径,identity-mode 为 CA 时,此选项不能为空 170 | cons_parti.3.ca-path= 171 | 172 | #第3个参与方的角色清单;可选项; 173 | #cons_parti.3.roles=GUEST 174 | #第3个参与方的角色权限策略,可选值有:UNION(并集),INTERSECT(交集);可选项; 175 | #cons_parti.3.roles-policy=INTERSECT 176 | 177 | #第3个参与方的账本初始服务的主机; 178 | cons_parti.3.initializer.host=127.0.0.1 179 | #第3个参与方的账本初始服务的端口; 180 | cons_parti.3.initializer.port=8830 181 | #第3个参与方的账本初始服务是否开启安全连接; 182 | cons_parti.3.initializer.secure=false -------------------------------------------------------------------------------- /deploy/deploy-peer/src/main/resources/config/init/bftsmart/bftsmart.config: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | ############################################ 17 | ###### #Consensus Participant0 ###### 18 | ############################################ 19 | 20 | system.server.0.network.host=127.0.0.1 21 | system.server.0.network.port=16000 22 | system.server.0.network.secure=false 23 | 24 | ############################################ 25 | ###### #Consensus Participant1 ###### 26 | ############################################ 27 | 28 | system.server.1.network.host=127.0.0.1 29 | system.server.1.network.port=16010 30 | system.server.1.network.secure=false 31 | 32 | ############################################ 33 | ###### #Consensus Participant2 ###### 34 | ############################################ 35 | 36 | system.server.2.network.host=127.0.0.1 37 | system.server.2.network.port=16020 38 | system.server.2.network.secure=false 39 | 40 | ############################################ 41 | ###### #Consensus Participant3 ###### 42 | ############################################ 43 | 44 | system.server.3.network.host=127.0.0.1 45 | system.server.3.network.port=16030 46 | system.server.3.network.secure=false 47 | 48 | 49 | ############################################ 50 | ####### Communication Configurations ####### 51 | ############################################ 52 | 53 | #HMAC algorithm used to authenticate messages between processes (HmacMD5 is the default value) 54 | #This parameter is not currently being used 55 | #system.authentication.hmacAlgorithm = HmacSHA1 56 | 57 | #Specify if the communication system should use a thread to send data (true or false) 58 | #system.communication.useSenderThread = true //unused property; 59 | 60 | #Force all processes to use the same public/private keys pair and secret key. This is useful when deploying experiments 61 | #and benchmarks, but must not be used in production systems. 62 | system.communication.defaultkeys = true 63 | 64 | ############################################ 65 | ### Replication Algorithm Configurations ### 66 | ############################################ 67 | 68 | #Number of servers in the group 69 | system.servers.num = 4 70 | 71 | #Maximum number of faulty replicas 72 | system.servers.f = 1 73 | 74 | #Timeout to asking for a client request 75 | #system.totalordermulticast.timeout = 60000 76 | 77 | #Allowable time tolerance range(millisecond) 78 | system.totalordermulticast.timeTolerance = 3000000 79 | 80 | #Maximum batch size (in number of messages) 81 | system.totalordermulticast.maxbatchsize = 2000 82 | 83 | #Number of nonces (for non-determinism actions) generated 84 | system.totalordermulticast.nonces = 10 85 | 86 | #if verification of leader-generated timestamps are increasing 87 | #it can only be used on systems in which the network clocks 88 | #are synchronized 89 | system.totalordermulticast.verifyTimestamps = false 90 | 91 | #Quantity of messages that can be stored in the receive queue of the communication system 92 | system.communication.inQueueSize = 500000 93 | 94 | # Quantity of messages that can be stored in the send queue of each replica 95 | system.communication.outQueueSize = 500000 96 | 97 | #The time interval for retrying to send message after connection failure. In milliseconds; 98 | system.communication.send.retryInterval=2000 99 | 100 | #The number of retries to send message after connection failure. 101 | system.communication.send.retryCount=100 102 | 103 | #Set to 1 if SMaRt should use signatures, set to 0 if otherwise 104 | system.communication.useSignatures = 0 105 | 106 | #Set to 1 if SMaRt should use MAC's, set to 0 if otherwise 107 | system.communication.useMACs = 0 108 | 109 | #Set to 1 if SMaRt should use the standard output to display debug messages, set to 0 if otherwise 110 | system.debug = 0 111 | 112 | #Print information about the replica when it is shutdown 113 | system.shutdownhook = true 114 | 115 | ############################################ 116 | ###### State Transfer Configurations ####### 117 | ############################################ 118 | 119 | #Activate the state transfer protocol ('true' to activate, 'false' to de-activate) 120 | system.totalordermulticast.state_transfer = true 121 | 122 | #Maximum ahead-of-time message not discarded 123 | system.totalordermulticast.highMark = 50 124 | 125 | #Maximum ahead-of-time message not discarded when the replica is still on EID 0 (after which the state transfer is triggered) 126 | system.totalordermulticast.revival_highMark = 10 127 | 128 | #Number of ahead-of-time messages necessary to trigger the state transfer after a request timeout occurs 129 | system.totalordermulticast.timeout_highMark = 200 130 | 131 | ############################################ 132 | ###### Log and Checkpoint Configurations ### 133 | ############################################ 134 | 135 | system.totalordermulticast.log = true 136 | system.totalordermulticast.log_parallel = false 137 | system.totalordermulticast.log_to_disk = false 138 | system.totalordermulticast.sync_log = false 139 | 140 | #Period at which BFT-SMaRt requests the state to the application (for the state transfer state protocol) 141 | system.totalordermulticast.checkpoint_period = 1000 142 | system.totalordermulticast.global_checkpoint_period = 120000 143 | 144 | system.totalordermulticast.checkpoint_to_disk = false 145 | system.totalordermulticast.sync_ckp = false 146 | 147 | 148 | ############################################ 149 | ###### Reconfiguration Configurations ###### 150 | ############################################ 151 | 152 | #Replicas ID for the initial view, separated by a comma. 153 | # The number of replicas in this parameter should be equal to that specified in 'system.servers.num' 154 | system.initial.view = 0,1,2,3 155 | 156 | #The ID of the trust third party (TTP) 157 | system.ttp.id = 2001 158 | 159 | #This sets if the system will function in Byzantine or crash-only mode. Set to "true" to support Byzantine faults 160 | system.bft = true 161 | 162 | #Custom View Storage; 163 | #view.storage.handler=bftsmart.reconfiguration.views.DefaultViewStorage 164 | 165 | #block delay; 166 | system.epoch.delay=50 167 | 168 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2019 Jingdong Digits Technology Holding Co., Ltd. 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | ------------------------------------------------------------------------------- 204 | 205 | The MIT License (MIT) 206 | 207 | Copyright (c) 2014 Hendrik Kunert 208 | 209 | Permission is hereby granted, free of charge, to any person obtaining a copy 210 | of this software and associated documentation files (the "Software"), to deal 211 | in the Software without restriction, including without limitation the rights 212 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 213 | copies of the Software, and to permit persons to whom the Software is 214 | furnished to do so, subject to the following conditions: 215 | 216 | The above copyright notice and this permission notice shall be included in 217 | all copies or substantial portions of the Software. 218 | 219 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 220 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 221 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 222 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 223 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 224 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 225 | THE SOFTWARE. 226 | --------------------------------------------------------------------------------