mirror of
https://gitee.com/BTAJL/repchain.git
synced 2024-11-30 02:38:24 +08:00
修改目标:共识抽象,达到共识切换。
此次提交:完成模块管理抽象。
This commit is contained in:
parent
af836e1c66
commit
37e8acd8ed
@ -1,177 +1,177 @@
|
||||
/*
|
||||
* Copyright 2019 Blockchain Technology and Application Joint Lab, Linkel Technology Co., Ltd, Beijing, Fintech Research Center of ISCAS.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BA SIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
syntax = "proto3";
|
||||
package rep.protos;
|
||||
option java_package = "rep.protos";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
/*
|
||||
*/
|
||||
//Event 用于图形展示的事件
|
||||
message Event {
|
||||
//来源addr
|
||||
string from = 1;
|
||||
//发送addr,如果是广播(需要定义一个)
|
||||
string to = 2;
|
||||
//event事件
|
||||
enum Action {
|
||||
SUBSCRIBE_TOPIC = 0;
|
||||
TRANSACTION = 1;
|
||||
BLOCK_NEW = 2;
|
||||
BLOCK_ENDORSEMENT = 3;
|
||||
ENDORSEMENT = 4;
|
||||
MEMBER_UP = 5;
|
||||
MEMBER_DOWN = 6;
|
||||
CANDIDATOR = 7;
|
||||
GENESIS_BLOCK = 8;
|
||||
BLOCK_SYNC = 9;
|
||||
BLOCK_SYNC_DATA = 10;
|
||||
BLOCK_SYNC_SUC = 11;
|
||||
}
|
||||
Action action = 3;
|
||||
Block blk = 4;
|
||||
}
|
||||
|
||||
//账户
|
||||
message Signer{
|
||||
string name = 1; //姓名或机构名, 用于填充合约文本
|
||||
string credit_code = 2; //社会信用代码, 与个人或机构唯一绑定
|
||||
string mobile = 3; // 手机号码,用于接收通知
|
||||
repeated string cert_names = 4;//存放用户所有证书的名称,用户具体的证书单独存放,方便证书的操作,用户在增加证书的时候,在这个列表中增加证书的名称。
|
||||
//map<string, Certificate> certs = 4; //签名者证书标识,可用于下载证书
|
||||
}
|
||||
|
||||
//账户证书标示
|
||||
message CertId {
|
||||
string credit_code = 1;
|
||||
string cert_name = 2;//当前用户注册证书的名称
|
||||
}
|
||||
|
||||
//账户证书标示
|
||||
message Certificate {
|
||||
string certificate = 1; //内含签发机构
|
||||
string alg_type = 2;//直接填写具体算法,如:ECDSA下的SHA1withECDSA,SHA512withECDSA等
|
||||
bool cert_valid = 3;//证书是否有效,true 有效;false 无效;protobuf默认该值为false
|
||||
google.protobuf.Timestamp reg_Time = 4; //注册时间
|
||||
google.protobuf.Timestamp unreg_Time = 5; //注销时间
|
||||
}
|
||||
|
||||
//背书,可用于Transaction和Block
|
||||
message Signature {
|
||||
//证书标识
|
||||
CertId cert_id = 1;
|
||||
google.protobuf.Timestamp tm_local = 2; //签名时间
|
||||
//签名
|
||||
bytes signature = 3;
|
||||
}
|
||||
|
||||
//合约方法调用及实际参数
|
||||
message ChaincodeInput {
|
||||
string function = 1;
|
||||
repeated string args = 2;
|
||||
}
|
||||
//指定合约名称和版本,确定唯一的合约代码
|
||||
message ChaincodeId {
|
||||
string chaincodeName = 1;
|
||||
int32 version = 2;
|
||||
}
|
||||
// 合约定义,部署/升级
|
||||
message ChaincodeDeploy {
|
||||
//Type only support javascript
|
||||
int32 timeout = 1;
|
||||
//完整的代码内容
|
||||
string code_package = 2;
|
||||
//合约规则的法律描述文本
|
||||
string legal_prose =3;
|
||||
enum CodeType {
|
||||
CODE_UNDEFINED = 0;
|
||||
CODE_JAVASCRIPT = 1;
|
||||
CODE_SCALA = 2;
|
||||
CODE_SCALA_PARALLEL = 3;
|
||||
}
|
||||
CodeType ctype = 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* 交易
|
||||
*/
|
||||
message Transaction {
|
||||
string id = 1;
|
||||
enum Type {
|
||||
UNDEFINED = 0;
|
||||
// deploy a chaincode to the network and call `Init` function
|
||||
CHAINCODE_DEPLOY = 1;
|
||||
// call a chaincode `Invoke` function as a transaction
|
||||
CHAINCODE_INVOKE = 2;
|
||||
CHAINCODE_SET_STATE = 3;
|
||||
}
|
||||
Type type = 2;
|
||||
//store ChaincodeID as bytes so its encrypted value can be stored
|
||||
ChaincodeId cid = 3;
|
||||
oneof para {
|
||||
ChaincodeDeploy spec = 4;
|
||||
ChaincodeInput ipt = 5;
|
||||
bool state = 6;
|
||||
}
|
||||
Signature signature = 7;
|
||||
}
|
||||
|
||||
message Block {
|
||||
// version - 区块数据版本,以便数据格式升级
|
||||
uint32 version = 1;
|
||||
// 区块高度, 从1开始
|
||||
uint64 height = 2;
|
||||
//顺序排列的交易
|
||||
repeated Transaction transactions = 3;
|
||||
//交易执行日志及输出指令
|
||||
repeated TransactionResult transactionResults = 4;
|
||||
//区块的hash。在计算块hash的时候,不包括签名信息;在签名时需要包括块hash。
|
||||
bytes hashOfBlock = 5;
|
||||
// previousBlockHash - The hash of the previous block in the chain.
|
||||
bytes previousBlockHash = 6;
|
||||
//背书签名集合,必须包含出块人签名
|
||||
repeated Signature endorsements=7;
|
||||
bytes stateHash = 8;
|
||||
}
|
||||
|
||||
//交易执行增量日志
|
||||
message OperLog{
|
||||
string key =1;
|
||||
bytes oldValue =2;
|
||||
bytes newValue=3;
|
||||
}
|
||||
message ActionResult{
|
||||
int32 code = 1;
|
||||
string reason = 2;
|
||||
}
|
||||
//交易结果(背书中针对各个交易再进行单独背书)
|
||||
//背书请求的应答(针对block中的各个交易)
|
||||
message TransactionResult {
|
||||
//唯一标识一个Transaction
|
||||
string txId = 1;
|
||||
repeated OperLog ol = 2;
|
||||
ActionResult result = 3;
|
||||
}
|
||||
|
||||
|
||||
message BlockchainInfo {
|
||||
uint64 height = 1;
|
||||
uint64 totalTransactions = 2;
|
||||
bytes currentBlockHash = 3;
|
||||
bytes previousBlockHash = 4;
|
||||
bytes currentStateHash = 5;
|
||||
}
|
||||
|
||||
/*
|
||||
* Copyright 2019 Blockchain Technology and Application Joint Lab, Linkel Technology Co., Ltd, Beijing, Fintech Research Center of ISCAS.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BA SIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
syntax = "proto3";
|
||||
package rep.protos;
|
||||
option java_package = "rep.protos";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
/*
|
||||
*/
|
||||
//Event 用于图形展示的事件
|
||||
message Event {
|
||||
//来源addr
|
||||
string from = 1;
|
||||
//发送addr,如果是广播(需要定义一个)
|
||||
string to = 2;
|
||||
//event事件
|
||||
enum Action {
|
||||
SUBSCRIBE_TOPIC = 0;
|
||||
TRANSACTION = 1;
|
||||
BLOCK_NEW = 2;
|
||||
BLOCK_ENDORSEMENT = 3;
|
||||
ENDORSEMENT = 4;
|
||||
MEMBER_UP = 5;
|
||||
MEMBER_DOWN = 6;
|
||||
CANDIDATOR = 7;
|
||||
GENESIS_BLOCK = 8;
|
||||
BLOCK_SYNC = 9;
|
||||
BLOCK_SYNC_DATA = 10;
|
||||
BLOCK_SYNC_SUC = 11;
|
||||
}
|
||||
Action action = 3;
|
||||
Block blk = 4;
|
||||
}
|
||||
|
||||
//账户
|
||||
message Signer{
|
||||
string name = 1; //姓名或机构名, 用于填充合约文本
|
||||
string credit_code = 2; //社会信用代码, 与个人或机构唯一绑定
|
||||
string mobile = 3; // 手机号码,用于接收通知
|
||||
repeated string cert_names = 4;//存放用户所有证书的名称,用户具体的证书单独存放,方便证书的操作,用户在增加证书的时候,在这个列表中增加证书的名称。
|
||||
//map<string, Certificate> certs = 4; //签名者证书标识,可用于下载证书
|
||||
}
|
||||
|
||||
//账户证书标示
|
||||
message CertId {
|
||||
string credit_code = 1;
|
||||
string cert_name = 2;//当前用户注册证书的名称
|
||||
}
|
||||
|
||||
//账户证书标示
|
||||
message Certificate {
|
||||
string certificate = 1; //内含签发机构
|
||||
string alg_type = 2;//直接填写具体算法,如:ECDSA下的SHA1withECDSA,SHA512withECDSA等
|
||||
bool cert_valid = 3;//证书是否有效,true 有效;false 无效;protobuf默认该值为false
|
||||
google.protobuf.Timestamp reg_Time = 4; //注册时间
|
||||
google.protobuf.Timestamp unreg_Time = 5; //注销时间
|
||||
}
|
||||
|
||||
//背书,可用于Transaction和Block
|
||||
message Signature {
|
||||
//证书标识
|
||||
CertId cert_id = 1;
|
||||
google.protobuf.Timestamp tm_local = 2; //签名时间
|
||||
//签名
|
||||
bytes signature = 3;
|
||||
}
|
||||
|
||||
//合约方法调用及实际参数
|
||||
message ChaincodeInput {
|
||||
string function = 1;
|
||||
repeated string args = 2;
|
||||
}
|
||||
//指定合约名称和版本,确定唯一的合约代码
|
||||
message ChaincodeId {
|
||||
string chaincodeName = 1;
|
||||
int32 version = 2;
|
||||
}
|
||||
// 合约定义,部署/升级
|
||||
message ChaincodeDeploy {
|
||||
//Type only support javascript
|
||||
int32 timeout = 1;
|
||||
//完整的代码内容
|
||||
string code_package = 2;
|
||||
//合约规则的法律描述文本
|
||||
string legal_prose =3;
|
||||
enum CodeType {
|
||||
CODE_UNDEFINED = 0;
|
||||
CODE_JAVASCRIPT = 1;
|
||||
CODE_SCALA = 2;
|
||||
CODE_SCALA_PARALLEL = 3;
|
||||
}
|
||||
CodeType ctype = 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* 交易
|
||||
*/
|
||||
message Transaction {
|
||||
string id = 1;
|
||||
enum Type {
|
||||
UNDEFINED = 0;
|
||||
// deploy a chaincode to the network and call `Init` function
|
||||
CHAINCODE_DEPLOY = 1;
|
||||
// call a chaincode `Invoke` function as a transaction
|
||||
CHAINCODE_INVOKE = 2;
|
||||
CHAINCODE_SET_STATE = 3;
|
||||
}
|
||||
Type type = 2;
|
||||
//store ChaincodeID as bytes so its encrypted value can be stored
|
||||
ChaincodeId cid = 3;
|
||||
oneof para {
|
||||
ChaincodeDeploy spec = 4;
|
||||
ChaincodeInput ipt = 5;
|
||||
bool state = 6;
|
||||
}
|
||||
Signature signature = 7;
|
||||
}
|
||||
|
||||
message Block {
|
||||
// version - 区块数据版本,以便数据格式升级
|
||||
uint32 version = 1;
|
||||
// 区块高度, 从1开始
|
||||
uint64 height = 2;
|
||||
//顺序排列的交易
|
||||
repeated Transaction transactions = 3;
|
||||
//交易执行日志及输出指令
|
||||
repeated TransactionResult transactionResults = 4;
|
||||
//区块的hash。在计算块hash的时候,不包括签名信息;在签名时需要包括块hash。
|
||||
bytes hashOfBlock = 5;
|
||||
// previousBlockHash - The hash of the previous block in the chain.
|
||||
bytes previousBlockHash = 6;
|
||||
//背书签名集合,必须包含出块人签名
|
||||
repeated Signature endorsements=7;
|
||||
bytes stateHash = 8;
|
||||
}
|
||||
|
||||
//交易执行增量日志
|
||||
message OperLog{
|
||||
string key =1;
|
||||
bytes oldValue =2;
|
||||
bytes newValue=3;
|
||||
}
|
||||
message ActionResult{
|
||||
int32 code = 1;
|
||||
string reason = 2;
|
||||
}
|
||||
//交易结果(背书中针对各个交易再进行单独背书)
|
||||
//背书请求的应答(针对block中的各个交易)
|
||||
message TransactionResult {
|
||||
//唯一标识一个Transaction
|
||||
string txId = 1;
|
||||
repeated OperLog ol = 2;
|
||||
ActionResult result = 3;
|
||||
}
|
||||
|
||||
|
||||
message BlockchainInfo {
|
||||
uint64 height = 1;
|
||||
uint64 totalTransactions = 2;
|
||||
bytes currentBlockHash = 3;
|
||||
bytes previousBlockHash = 4;
|
||||
bytes currentStateHash = 5;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
package rep.api.rest
|
||||
|
||||
import akka.actor.Actor
|
||||
|
||||
import akka.util.Timeout
|
||||
import rep.network._
|
||||
|
||||
@ -28,7 +27,7 @@ import scala.concurrent._
|
||||
import rep.protos.peer._
|
||||
import rep.crypto._
|
||||
import rep.sc.Shim._
|
||||
import rep.network.PeerHelper._
|
||||
import rep.network.autotransaction.PeerHelper._
|
||||
import rep.storage._
|
||||
import spray.json._
|
||||
import scalapb.json4s.JsonFormat
|
||||
@ -37,12 +36,13 @@ import org.json4s._
|
||||
import org.json4s.jackson.JsonMethods
|
||||
import rep.network.tools.PeerExtension
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.utils.GlobalUtils.ActorType
|
||||
import rep.network.module.ModuleActorType
|
||||
import akka.actor.Props
|
||||
import rep.crypto.cert.SignTool
|
||||
import rep.protos.peer.ActionResult
|
||||
import rep.app.conf.SystemProfile
|
||||
import rep.log.RepLogger
|
||||
import rep.network.autotransaction.PeerHelper
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.sc.TypeOfSender
|
||||
import rep.sc.SandboxDispatcher.DoTransaction
|
||||
@ -170,7 +170,7 @@ class RestActor(moduleName: String) extends ModuleBase(moduleName) {
|
||||
} else {
|
||||
if (SignTool.verify(sig, tOutSig.toByteArray, certId, pe.getSysTag)) {
|
||||
// RepLogger.info(RepLogger.Business_Logger, s"验证签名成功,txid: ${t.id},creditCode: ${t.signature.get.getCertId.creditCode}, certName: ${t.signature.get.getCertId.certName}")
|
||||
val future = pe.getActorRef(ActorType.transactiondispatcher) ? DoTransaction(t, "api_" + t.id, TypeOfSender.FromAPI)
|
||||
val future = pe.getActorRef(ModuleActorType.ActorType.transactiondispatcher) ? DoTransaction(t, "api_" + t.id, TypeOfSender.FromAPI)
|
||||
val result = Await.result(future, timeout.duration).asInstanceOf[DoTransactionResult]
|
||||
val rv = result
|
||||
// 释放存储实例
|
||||
@ -178,7 +178,7 @@ class RestActor(moduleName: String) extends ModuleBase(moduleName) {
|
||||
rv.err match {
|
||||
case None =>
|
||||
//预执行正常,提交并广播交易
|
||||
pe.getActorRef(ActorType.transactionpool) ! t // 给交易池发送消息 !=》告知(getActorRef)
|
||||
pe.getActorRef(ModuleActorType.ActorType.transactionpool) ! t // 给交易池发送消息 !=》告知(getActorRef)
|
||||
if (rv.r == null)
|
||||
sender ! PostResult(t.id, None, None)
|
||||
else
|
||||
@ -192,7 +192,7 @@ class RestActor(moduleName: String) extends ModuleBase(moduleName) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pe.getActorRef(ActorType.transactionpool) ! t // 给交易池发送消息 !=》告知(getActorRef)
|
||||
pe.getActorRef(ModuleActorType.ActorType.transactionpool) ! t // 给交易池发送消息 !=》告知(getActorRef)
|
||||
sender ! PostResult(t.id, None, None)
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ import scala.concurrent.{Await, Future}
|
||||
import akka.remote.transport.Transport._
|
||||
import rep.network._
|
||||
import rep.network.cluster.MemberListener
|
||||
import rep.network.module.{ModuleManager}
|
||||
import rep.network.module.IModuleManager
|
||||
import rep.ui.web.EventServer
|
||||
|
||||
import scala.collection.mutable._
|
||||
@ -53,7 +53,7 @@ object TestMain {
|
||||
nd_system.actorOf(Props[MemberListener], name_MemberListener)
|
||||
//等待网络稳定
|
||||
Thread.sleep(5000)
|
||||
nd_system.actorOf(Props[ModuleManager], name_PeerManager + i.toString)
|
||||
nd_system.actorOf(Props[IModuleManager], name_PeerManager + i.toString)
|
||||
m += i -> nd_system
|
||||
ma += i -> Cluster(nd_system).selfAddress
|
||||
}
|
||||
@ -113,7 +113,7 @@ object TestMain {
|
||||
system0.actorOf(Props[MemberListener], name_MemberListener)
|
||||
//等待网络稳定
|
||||
Thread.sleep(5000)
|
||||
val nd0 = system0.actorOf(Props[ModuleManager], name_PeerManager + "0")
|
||||
val nd0 = system0.actorOf(Props[IModuleManager], name_PeerManager + "0")
|
||||
val ws0 = system0.actorOf(Props[EventServer], "ws")
|
||||
}
|
||||
}
|
||||
|
@ -1,310 +1,320 @@
|
||||
/*
|
||||
* Copyright 2019 Blockchain Technology and Application Joint Lab, Linkel Technology Co., Ltd, Beijing, Fintech Research Center of ISCAS.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BA SIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package rep.app.conf
|
||||
|
||||
import com.typesafe.config.Config
|
||||
//import collection.JavaConversions._
|
||||
//import scala.collection.immutable._
|
||||
import java.util.List
|
||||
import java.util.ArrayList
|
||||
|
||||
/**
|
||||
* 系统配置信息缓存对象
|
||||
* @author shidianyue
|
||||
* @version 0.7
|
||||
* @update 2018-05 jiangbuyun
|
||||
* */
|
||||
object SystemProfile {
|
||||
|
||||
/**
|
||||
* 交易创建类型
|
||||
*/
|
||||
case object Trans_Create_Type_Enum {
|
||||
val MANUAL = 0 //API创建
|
||||
val AUTO = 1 //自动创建
|
||||
}
|
||||
|
||||
private[this] var _LIMIT_BLOCK_TRANS_NUM: Int = 0//块内最多交易数
|
||||
private[this] var _MIN_BLOCK_TRANS_NUM: Int = 0//块内最少交易数
|
||||
private[this] var _VOTE_NOTE_MIN: Int = 0//投票最少参与人数
|
||||
private[this] var _TRAN_CREATE_DUR: Int = 0//交易创建时间间隔-针对自动创建
|
||||
private[this] var _TRANS_CREATE_TYPE: Int = 0//交易创建类型
|
||||
private[this] var _RETRY_TIME: Int = 0//投票重试次数限制
|
||||
private[this] var _MAX_CATCH_TRANS_NUM: Int = 0//交易最多缓存数量
|
||||
private[this] var _DISKSPACE_ALARM_NUM:Long=0//磁盘剩余空间预警 单位=M
|
||||
private[this] var _SERVERPORT:Int=8081//http服务的端口,默认为8081
|
||||
private[this] var _CHECKCERTVALIDATE:Int=0//是否检查证书的有效性,0不检查,1检查
|
||||
private[this] var _CONTRACTOPERATIONMODE = 0//设置合约的运行方式,0=debug方式,1=deploy,默认为debug方式,如果发布部署,必须使用deploy方式。
|
||||
private[this] var _VOTENODELIST : List[String] = new ArrayList[String]
|
||||
private[this] var _ACCOUNTCHAINCODENAEM : String = "ACCOUNTCHAINCODENAME"
|
||||
private[this] var _ACCOUNTCHAINCODEVERSION: Int = 1
|
||||
private[this] var _CertStatusChangeFunction : String = "UpdateCertStatus"
|
||||
private[this] var _GENESISNODENAME:String = ""
|
||||
private[this] var _BLOCK_LENGTH: Int = 120000//区块的最大长度
|
||||
private[this] var _NUMBER_OF_TRANSPROCESSOR = 100 //
|
||||
private[this] var _HAS_PRELOAD_TRANS_OF_API = true
|
||||
private[this] var _IS_VERIFY_OF_ENDORSEMENT = true//is_verify_of_endorsement
|
||||
private[this] var _NUMBER_OF_ENDORSEMENT: Int = 2
|
||||
|
||||
private[this] var _BLOCKNUMBER_OF_RAFT: Int = 100
|
||||
|
||||
private[this] var _DBPATH:String = "" //leveldb数据库文件路径
|
||||
private[this] var _BLOCKPATH:String = ""//区块文件的路径
|
||||
private[this] var _FILEMAX: Int = 200000000//区块文件的最大长度
|
||||
|
||||
|
||||
//实时图的事件是否发送,如果不发送,前端实时图将收不到任何消息。
|
||||
private[this] var _REALTIMEGRAPH_ENABLE = 1 ////0 unable;1 enable; default 1
|
||||
|
||||
|
||||
|
||||
|
||||
private def SERVERPORT :Int = _SERVERPORT
|
||||
private def CHECKCERTVALIDATE:Int = _CHECKCERTVALIDATE
|
||||
private def DISKSPACE_ALARM_NUM :Long = _DISKSPACE_ALARM_NUM
|
||||
private def CONTRACTOPERATIONMODE:Int=_CONTRACTOPERATIONMODE
|
||||
private def GENESISNODENAME:String = _GENESISNODENAME
|
||||
|
||||
private def VOTENODELIST : List[String] = _VOTENODELIST
|
||||
private def ACCOUNTCHAINCODENAEM = _ACCOUNTCHAINCODENAEM
|
||||
private def ACCOUNTCHAINCODVERSION = _ACCOUNTCHAINCODEVERSION
|
||||
private def CertStatusChangeFunction = _CertStatusChangeFunction
|
||||
|
||||
private def NUMBER_OF_TRANSPROCESSOR = _NUMBER_OF_TRANSPROCESSOR
|
||||
|
||||
private def HAS_PRELOAD_TRANS_OF_API = _HAS_PRELOAD_TRANS_OF_API
|
||||
|
||||
private def IS_VERIFY_OF_ENDORSEMENT = _IS_VERIFY_OF_ENDORSEMENT
|
||||
|
||||
private def NUMBER_OF_ENDORSEMENT = _NUMBER_OF_ENDORSEMENT
|
||||
private def BLOCKNUMBER_OF_RAFT = _BLOCKNUMBER_OF_RAFT
|
||||
|
||||
private def REALTIMEGRAPH_ENABLE = _REALTIMEGRAPH_ENABLE
|
||||
|
||||
private def DBPATH:String = _DBPATH
|
||||
private def BLOCKPATH:String = _BLOCKPATH
|
||||
private def FILEMAX: Int = _FILEMAX
|
||||
|
||||
private def DBPATH_=(value:String):Unit={
|
||||
_DBPATH = value
|
||||
}
|
||||
|
||||
private def REALTIMEGRAPH_ENABLE_=(value:Int):Unit={
|
||||
_REALTIMEGRAPH_ENABLE = value
|
||||
}
|
||||
|
||||
private def BLOCKPATH_=(value:String):Unit={
|
||||
_BLOCKPATH = value
|
||||
}
|
||||
|
||||
private def FILEMAX_=(value:Int):Unit={
|
||||
_FILEMAX = value
|
||||
}
|
||||
|
||||
private def GENESISNODENAME_=(value:String):Unit={
|
||||
_GENESISNODENAME = value
|
||||
}
|
||||
|
||||
private def NUMBER_OF_TRANSPROCESSOR_=(value:Int):Unit={
|
||||
_NUMBER_OF_TRANSPROCESSOR = value
|
||||
}
|
||||
|
||||
private def HAS_PRELOAD_TRANS_OF_API_=(value:Boolean):Unit={
|
||||
_HAS_PRELOAD_TRANS_OF_API = value
|
||||
}
|
||||
|
||||
private def IS_VERIFY_OF_ENDORSEMENT_=(value:Boolean):Unit={
|
||||
_IS_VERIFY_OF_ENDORSEMENT = value
|
||||
}
|
||||
|
||||
private def NUMBER_OF_ENDORSEMENT_=(value:Int):Unit={
|
||||
_NUMBER_OF_ENDORSEMENT = value
|
||||
}
|
||||
|
||||
private def BLOCKNUMBER_OF_RAFT_=(value:Int):Unit={
|
||||
_BLOCKNUMBER_OF_RAFT = value
|
||||
}
|
||||
|
||||
private def VOTENODELIST_=(value: List[String]): Unit = {
|
||||
_VOTENODELIST = value
|
||||
}
|
||||
|
||||
private def ACCOUNTCHAINCODENAEM_=(value:String):Unit={
|
||||
_ACCOUNTCHAINCODENAEM = value
|
||||
}
|
||||
|
||||
private def CertStatusChangeFunction_=(value:String):Unit={
|
||||
_CertStatusChangeFunction = value
|
||||
}
|
||||
|
||||
private def ACCOUNTCHAINCODEVERSION_=(value:Int):Unit={
|
||||
_ACCOUNTCHAINCODEVERSION = value
|
||||
}
|
||||
|
||||
private def SERVERPORT_=(value: Int): Unit = {
|
||||
_SERVERPORT = value
|
||||
}
|
||||
|
||||
private def CHECKCERTVALIDATE_=(value: Int): Unit = {
|
||||
_CHECKCERTVALIDATE = value
|
||||
}
|
||||
|
||||
private def CONTRACTOPERATIONMODE_=(value: Int): Unit = {
|
||||
_CONTRACTOPERATIONMODE = value
|
||||
}
|
||||
|
||||
private def DISKSPACE_ALARM_NUM_=(value: Long): Unit = {
|
||||
_DISKSPACE_ALARM_NUM = value
|
||||
}
|
||||
|
||||
private def MAX_CATCH_TRANS_NUM: Int = _MAX_CATCH_TRANS_NUM
|
||||
|
||||
private def MAX_CATCH_TRANS_NUM_=(value: Int): Unit = {
|
||||
_MAX_CATCH_TRANS_NUM = value
|
||||
}
|
||||
|
||||
private def RETRY_TIME: Int = _RETRY_TIME
|
||||
|
||||
|
||||
private def RETRY_TIME_=(value: Int): Unit = {
|
||||
_RETRY_TIME = value
|
||||
}
|
||||
|
||||
|
||||
private def TRANS_CREATE_TYPE: Int = _TRANS_CREATE_TYPE
|
||||
|
||||
private def TRANS_CREATE_TYPE_=(value: Int): Unit = {
|
||||
_TRANS_CREATE_TYPE = value
|
||||
}
|
||||
|
||||
private def TRAN_CREATE_DUR: Int = _TRAN_CREATE_DUR
|
||||
|
||||
private def TRAN_CREATE_DUR_=(value: Int): Unit = {
|
||||
_TRAN_CREATE_DUR = value
|
||||
}
|
||||
|
||||
private def VOTE_NOTE_MIN: Int = _VOTE_NOTE_MIN
|
||||
|
||||
private def VOTE_NOTE_MIN_=(value: Int): Unit = {
|
||||
_VOTE_NOTE_MIN = value
|
||||
}
|
||||
|
||||
private def MIN_BLOCK_TRANS_NUM: Int = _MIN_BLOCK_TRANS_NUM
|
||||
|
||||
private def MIN_BLOCK_TRANS_NUM_=(value: Int): Unit = {
|
||||
_MIN_BLOCK_TRANS_NUM = value
|
||||
}
|
||||
|
||||
private def LIMIT_BLOCK_TRANS_NUM: Int = _LIMIT_BLOCK_TRANS_NUM
|
||||
|
||||
private def LIMIT_BLOCK_TRANS_NUM_=(value: Int): Unit = {
|
||||
_LIMIT_BLOCK_TRANS_NUM = value
|
||||
}
|
||||
|
||||
private def BLOCK_LENGTH : Int = _BLOCK_LENGTH
|
||||
|
||||
private def BLOCK_LENGTH_=(value: Int): Unit = {
|
||||
_BLOCK_LENGTH = value
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化配饰信息
|
||||
* @param config
|
||||
*/
|
||||
def initConfigSystem(config:Config): Unit ={
|
||||
LIMIT_BLOCK_TRANS_NUM_=(config.getInt("system.block.trans_num_limit"))
|
||||
BLOCK_LENGTH_=(config.getInt("system.block.block_length"))
|
||||
MIN_BLOCK_TRANS_NUM_=(config.getInt("system.block.trans_num_min"))
|
||||
RETRY_TIME_=(config.getInt("system.block.retry_time"))
|
||||
VOTE_NOTE_MIN_=(config.getInt("system.vote.vote_note_min"))
|
||||
VOTENODELIST_=(config.getStringList("system.vote.vote_node_list"))
|
||||
TRAN_CREATE_DUR_=(config.getInt("system.transaction.tran_create_dur"))
|
||||
MAX_CATCH_TRANS_NUM_=(config.getInt("system.transaction.max_cache_num"))
|
||||
TRANS_CREATE_TYPE_=(config.getInt("system.trans_create_type"))
|
||||
DISKSPACE_ALARM_NUM_=(config.getInt("system.diskspaceManager.diskspacealarm"))
|
||||
SERVERPORT_=(config.getInt("system.httpServicePort"))
|
||||
CHECKCERTVALIDATE_=(config.getInt("system.checkCertValidate"))
|
||||
CONTRACTOPERATIONMODE_=(config.getInt("system.contractOperationMode"))
|
||||
ACCOUNTCHAINCODENAEM_= (config.getString("system.account.chaincodename"))
|
||||
ACCOUNTCHAINCODEVERSION_=(config.getInt("system.account.chaincodeversion"))
|
||||
CertStatusChangeFunction_= (config.getString("system.account.CertStatusChangeFunction"))
|
||||
|
||||
GENESISNODENAME_=(config.getString("system.genesis_node_name"))
|
||||
NUMBER_OF_TRANSPROCESSOR_=(config.getInt("system.number_of_transProcessor"))
|
||||
HAS_PRELOAD_TRANS_OF_API_=(config.getBoolean("system.has_preload_trans_of_api"))
|
||||
IS_VERIFY_OF_ENDORSEMENT_=(config.getBoolean("system.is_verify_of_endorsement"))
|
||||
NUMBER_OF_ENDORSEMENT_=(config.getInt("system.number_of_endorsement"))
|
||||
BLOCKNUMBER_OF_RAFT_=(config.getInt("system.consensus.blocknumberofraft"))
|
||||
|
||||
DBPATH_= (config.getString("system.storage.dbpath"))
|
||||
BLOCKPATH_= (config.getString("system.storage.blockpath"))
|
||||
FILEMAX_=(config.getInt("system.storage.filemax"))
|
||||
REALTIMEGRAPH_ENABLE_=(config.getInt("system.realtimegraph_enable"))
|
||||
}
|
||||
|
||||
def getRealtimeGraph = REALTIMEGRAPH_ENABLE
|
||||
|
||||
def getDBPath = DBPATH
|
||||
|
||||
def getBlockPath = BLOCKPATH
|
||||
|
||||
def getFileMax = FILEMAX
|
||||
|
||||
def getLimitBlockTransNum = LIMIT_BLOCK_TRANS_NUM
|
||||
|
||||
def getNumberOfTransProcessor = NUMBER_OF_TRANSPROCESSOR
|
||||
|
||||
def getBlockNumberOfRaft = BLOCKNUMBER_OF_RAFT
|
||||
|
||||
def getHasPreloadTransOfApi = HAS_PRELOAD_TRANS_OF_API
|
||||
|
||||
def getIsVerifyOfEndorsement = IS_VERIFY_OF_ENDORSEMENT
|
||||
|
||||
def getNumberOfEndorsement = NUMBER_OF_ENDORSEMENT
|
||||
|
||||
def getBlockLength = BLOCK_LENGTH
|
||||
|
||||
def getMinBlockTransNum = MIN_BLOCK_TRANS_NUM
|
||||
|
||||
def getVoteNoteMin = VOTE_NOTE_MIN
|
||||
|
||||
def getTranCreateDur = TRAN_CREATE_DUR
|
||||
|
||||
def getMaxCacheTransNum = MAX_CATCH_TRANS_NUM
|
||||
|
||||
def getTransCreateType = TRANS_CREATE_TYPE
|
||||
|
||||
def getRetryTime = RETRY_TIME
|
||||
|
||||
def getDiskSpaceAlarm = DISKSPACE_ALARM_NUM
|
||||
|
||||
def getHttpServicePort = SERVERPORT
|
||||
|
||||
def getCheckCertValidate = CHECKCERTVALIDATE
|
||||
|
||||
def getContractOperationMode = CONTRACTOPERATIONMODE
|
||||
|
||||
def getVoteNodeList = VOTENODELIST
|
||||
|
||||
def getAccountChaincodeName = ACCOUNTCHAINCODENAEM
|
||||
|
||||
def getCertStatusChangeFunction = CertStatusChangeFunction
|
||||
|
||||
def getAccountChaincodeVersion = ACCOUNTCHAINCODVERSION
|
||||
|
||||
def getGenesisNodeName = GENESISNODENAME
|
||||
}
|
||||
/*
|
||||
* Copyright 2019 Blockchain Technology and Application Joint Lab, Linkel Technology Co., Ltd, Beijing, Fintech Research Center of ISCAS.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BA SIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package rep.app.conf
|
||||
|
||||
import com.typesafe.config.Config
|
||||
//import collection.JavaConversions._
|
||||
//import scala.collection.immutable._
|
||||
import java.util.List
|
||||
import java.util.ArrayList
|
||||
|
||||
/**
|
||||
* 系统配置信息缓存对象
|
||||
* @author shidianyue
|
||||
* @version 0.7
|
||||
* @update 2018-05 jiangbuyun
|
||||
* */
|
||||
object SystemProfile {
|
||||
|
||||
/**
|
||||
* 交易创建类型
|
||||
*/
|
||||
case object Trans_Create_Type_Enum {
|
||||
val MANUAL = 0 //API创建
|
||||
val AUTO = 1 //自动创建
|
||||
}
|
||||
|
||||
private[this] var _LIMIT_BLOCK_TRANS_NUM: Int = 0//块内最多交易数
|
||||
private[this] var _MIN_BLOCK_TRANS_NUM: Int = 0//块内最少交易数
|
||||
private[this] var _VOTE_NOTE_MIN: Int = 0//投票最少参与人数
|
||||
private[this] var _TRAN_CREATE_DUR: Int = 0//交易创建时间间隔-针对自动创建
|
||||
private[this] var _TRANS_CREATE_TYPE: Int = 0//交易创建类型
|
||||
private[this] var _RETRY_TIME: Int = 0//投票重试次数限制
|
||||
private[this] var _MAX_CATCH_TRANS_NUM: Int = 0//交易最多缓存数量
|
||||
private[this] var _DISKSPACE_ALARM_NUM:Long=0//磁盘剩余空间预警 单位=M
|
||||
private[this] var _SERVERPORT:Int=8081//http服务的端口,默认为8081
|
||||
private[this] var _CHECKCERTVALIDATE:Int=0//是否检查证书的有效性,0不检查,1检查
|
||||
private[this] var _CONTRACTOPERATIONMODE = 0//设置合约的运行方式,0=debug方式,1=deploy,默认为debug方式,如果发布部署,必须使用deploy方式。
|
||||
private[this] var _VOTENODELIST : List[String] = new ArrayList[String]
|
||||
private[this] var _ACCOUNTCHAINCODENAEM : String = "ACCOUNTCHAINCODENAME"
|
||||
private[this] var _ACCOUNTCHAINCODEVERSION: Int = 1
|
||||
private[this] var _CertStatusChangeFunction : String = "UpdateCertStatus"
|
||||
private[this] var _GENESISNODENAME:String = ""
|
||||
private[this] var _BLOCK_LENGTH: Int = 120000//区块的最大长度
|
||||
private[this] var _NUMBER_OF_TRANSPROCESSOR = 100 //
|
||||
private[this] var _HAS_PRELOAD_TRANS_OF_API = true
|
||||
private[this] var _IS_VERIFY_OF_ENDORSEMENT = true//is_verify_of_endorsement
|
||||
private[this] var _NUMBER_OF_ENDORSEMENT: Int = 2
|
||||
private[this] var _TYPE_OF_CONSENSUS:String = "CFRD"
|
||||
|
||||
private[this] var _BLOCKNUMBER_OF_RAFT: Int = 100
|
||||
|
||||
private[this] var _DBPATH:String = "" //leveldb数据库文件路径
|
||||
private[this] var _BLOCKPATH:String = ""//区块文件的路径
|
||||
private[this] var _FILEMAX: Int = 200000000//区块文件的最大长度
|
||||
|
||||
|
||||
//实时图的事件是否发送,如果不发送,前端实时图将收不到任何消息。
|
||||
private[this] var _REALTIMEGRAPH_ENABLE = 1 ////0 unable;1 enable; default 1
|
||||
|
||||
|
||||
|
||||
|
||||
private def SERVERPORT :Int = _SERVERPORT
|
||||
private def CHECKCERTVALIDATE:Int = _CHECKCERTVALIDATE
|
||||
private def DISKSPACE_ALARM_NUM :Long = _DISKSPACE_ALARM_NUM
|
||||
private def CONTRACTOPERATIONMODE:Int=_CONTRACTOPERATIONMODE
|
||||
private def GENESISNODENAME:String = _GENESISNODENAME
|
||||
|
||||
private def VOTENODELIST : List[String] = _VOTENODELIST
|
||||
private def ACCOUNTCHAINCODENAEM = _ACCOUNTCHAINCODENAEM
|
||||
private def ACCOUNTCHAINCODVERSION = _ACCOUNTCHAINCODEVERSION
|
||||
private def CertStatusChangeFunction = _CertStatusChangeFunction
|
||||
|
||||
private def NUMBER_OF_TRANSPROCESSOR = _NUMBER_OF_TRANSPROCESSOR
|
||||
|
||||
private def HAS_PRELOAD_TRANS_OF_API = _HAS_PRELOAD_TRANS_OF_API
|
||||
|
||||
private def IS_VERIFY_OF_ENDORSEMENT = _IS_VERIFY_OF_ENDORSEMENT
|
||||
|
||||
private def NUMBER_OF_ENDORSEMENT = _NUMBER_OF_ENDORSEMENT
|
||||
private def BLOCKNUMBER_OF_RAFT = _BLOCKNUMBER_OF_RAFT
|
||||
|
||||
private def REALTIMEGRAPH_ENABLE = _REALTIMEGRAPH_ENABLE
|
||||
|
||||
private def TYPE_OF_CONSENSUS : String = _TYPE_OF_CONSENSUS
|
||||
|
||||
private def DBPATH:String = _DBPATH
|
||||
private def BLOCKPATH:String = _BLOCKPATH
|
||||
private def FILEMAX: Int = _FILEMAX
|
||||
|
||||
private def TYPE_OF_CONSENSUS_=(value:String):Unit={
|
||||
_TYPE_OF_CONSENSUS = value
|
||||
}
|
||||
|
||||
private def DBPATH_=(value:String):Unit={
|
||||
_DBPATH = value
|
||||
}
|
||||
|
||||
private def REALTIMEGRAPH_ENABLE_=(value:Int):Unit={
|
||||
_REALTIMEGRAPH_ENABLE = value
|
||||
}
|
||||
|
||||
private def BLOCKPATH_=(value:String):Unit={
|
||||
_BLOCKPATH = value
|
||||
}
|
||||
|
||||
private def FILEMAX_=(value:Int):Unit={
|
||||
_FILEMAX = value
|
||||
}
|
||||
|
||||
private def GENESISNODENAME_=(value:String):Unit={
|
||||
_GENESISNODENAME = value
|
||||
}
|
||||
|
||||
private def NUMBER_OF_TRANSPROCESSOR_=(value:Int):Unit={
|
||||
_NUMBER_OF_TRANSPROCESSOR = value
|
||||
}
|
||||
|
||||
private def HAS_PRELOAD_TRANS_OF_API_=(value:Boolean):Unit={
|
||||
_HAS_PRELOAD_TRANS_OF_API = value
|
||||
}
|
||||
|
||||
private def IS_VERIFY_OF_ENDORSEMENT_=(value:Boolean):Unit={
|
||||
_IS_VERIFY_OF_ENDORSEMENT = value
|
||||
}
|
||||
|
||||
private def NUMBER_OF_ENDORSEMENT_=(value:Int):Unit={
|
||||
_NUMBER_OF_ENDORSEMENT = value
|
||||
}
|
||||
|
||||
private def BLOCKNUMBER_OF_RAFT_=(value:Int):Unit={
|
||||
_BLOCKNUMBER_OF_RAFT = value
|
||||
}
|
||||
|
||||
private def VOTENODELIST_=(value: List[String]): Unit = {
|
||||
_VOTENODELIST = value
|
||||
}
|
||||
|
||||
private def ACCOUNTCHAINCODENAEM_=(value:String):Unit={
|
||||
_ACCOUNTCHAINCODENAEM = value
|
||||
}
|
||||
|
||||
private def CertStatusChangeFunction_=(value:String):Unit={
|
||||
_CertStatusChangeFunction = value
|
||||
}
|
||||
|
||||
private def ACCOUNTCHAINCODEVERSION_=(value:Int):Unit={
|
||||
_ACCOUNTCHAINCODEVERSION = value
|
||||
}
|
||||
|
||||
private def SERVERPORT_=(value: Int): Unit = {
|
||||
_SERVERPORT = value
|
||||
}
|
||||
|
||||
private def CHECKCERTVALIDATE_=(value: Int): Unit = {
|
||||
_CHECKCERTVALIDATE = value
|
||||
}
|
||||
|
||||
private def CONTRACTOPERATIONMODE_=(value: Int): Unit = {
|
||||
_CONTRACTOPERATIONMODE = value
|
||||
}
|
||||
|
||||
private def DISKSPACE_ALARM_NUM_=(value: Long): Unit = {
|
||||
_DISKSPACE_ALARM_NUM = value
|
||||
}
|
||||
|
||||
private def MAX_CATCH_TRANS_NUM: Int = _MAX_CATCH_TRANS_NUM
|
||||
|
||||
private def MAX_CATCH_TRANS_NUM_=(value: Int): Unit = {
|
||||
_MAX_CATCH_TRANS_NUM = value
|
||||
}
|
||||
|
||||
private def RETRY_TIME: Int = _RETRY_TIME
|
||||
|
||||
|
||||
private def RETRY_TIME_=(value: Int): Unit = {
|
||||
_RETRY_TIME = value
|
||||
}
|
||||
|
||||
|
||||
private def TRANS_CREATE_TYPE: Int = _TRANS_CREATE_TYPE
|
||||
|
||||
private def TRANS_CREATE_TYPE_=(value: Int): Unit = {
|
||||
_TRANS_CREATE_TYPE = value
|
||||
}
|
||||
|
||||
private def TRAN_CREATE_DUR: Int = _TRAN_CREATE_DUR
|
||||
|
||||
private def TRAN_CREATE_DUR_=(value: Int): Unit = {
|
||||
_TRAN_CREATE_DUR = value
|
||||
}
|
||||
|
||||
private def VOTE_NOTE_MIN: Int = _VOTE_NOTE_MIN
|
||||
|
||||
private def VOTE_NOTE_MIN_=(value: Int): Unit = {
|
||||
_VOTE_NOTE_MIN = value
|
||||
}
|
||||
|
||||
private def MIN_BLOCK_TRANS_NUM: Int = _MIN_BLOCK_TRANS_NUM
|
||||
|
||||
private def MIN_BLOCK_TRANS_NUM_=(value: Int): Unit = {
|
||||
_MIN_BLOCK_TRANS_NUM = value
|
||||
}
|
||||
|
||||
private def LIMIT_BLOCK_TRANS_NUM: Int = _LIMIT_BLOCK_TRANS_NUM
|
||||
|
||||
private def LIMIT_BLOCK_TRANS_NUM_=(value: Int): Unit = {
|
||||
_LIMIT_BLOCK_TRANS_NUM = value
|
||||
}
|
||||
|
||||
private def BLOCK_LENGTH : Int = _BLOCK_LENGTH
|
||||
|
||||
private def BLOCK_LENGTH_=(value: Int): Unit = {
|
||||
_BLOCK_LENGTH = value
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化配饰信息
|
||||
* @param config
|
||||
*/
|
||||
def initConfigSystem(config:Config): Unit ={
|
||||
LIMIT_BLOCK_TRANS_NUM_=(config.getInt("system.block.trans_num_limit"))
|
||||
BLOCK_LENGTH_=(config.getInt("system.block.block_length"))
|
||||
MIN_BLOCK_TRANS_NUM_=(config.getInt("system.block.trans_num_min"))
|
||||
RETRY_TIME_=(config.getInt("system.block.retry_time"))
|
||||
VOTE_NOTE_MIN_=(config.getInt("system.vote.vote_note_min"))
|
||||
VOTENODELIST_=(config.getStringList("system.vote.vote_node_list"))
|
||||
TRAN_CREATE_DUR_=(config.getInt("system.transaction.tran_create_dur"))
|
||||
MAX_CATCH_TRANS_NUM_=(config.getInt("system.transaction.max_cache_num"))
|
||||
TRANS_CREATE_TYPE_=(config.getInt("system.trans_create_type"))
|
||||
DISKSPACE_ALARM_NUM_=(config.getInt("system.diskspaceManager.diskspacealarm"))
|
||||
SERVERPORT_=(config.getInt("system.httpServicePort"))
|
||||
CHECKCERTVALIDATE_=(config.getInt("system.checkCertValidate"))
|
||||
CONTRACTOPERATIONMODE_=(config.getInt("system.contractOperationMode"))
|
||||
ACCOUNTCHAINCODENAEM_= (config.getString("system.account.chaincodename"))
|
||||
ACCOUNTCHAINCODEVERSION_=(config.getInt("system.account.chaincodeversion"))
|
||||
CertStatusChangeFunction_= (config.getString("system.account.CertStatusChangeFunction"))
|
||||
|
||||
GENESISNODENAME_=(config.getString("system.genesis_node_name"))
|
||||
NUMBER_OF_TRANSPROCESSOR_=(config.getInt("system.number_of_transProcessor"))
|
||||
HAS_PRELOAD_TRANS_OF_API_=(config.getBoolean("system.has_preload_trans_of_api"))
|
||||
IS_VERIFY_OF_ENDORSEMENT_=(config.getBoolean("system.is_verify_of_endorsement"))
|
||||
NUMBER_OF_ENDORSEMENT_=(config.getInt("system.number_of_endorsement"))
|
||||
BLOCKNUMBER_OF_RAFT_=(config.getInt("system.consensus.blocknumberofraft"))
|
||||
TYPE_OF_CONSENSUS_=(config.getString("system.consensus.type"))
|
||||
|
||||
DBPATH_= (config.getString("system.storage.dbpath"))
|
||||
BLOCKPATH_= (config.getString("system.storage.blockpath"))
|
||||
FILEMAX_=(config.getInt("system.storage.filemax"))
|
||||
REALTIMEGRAPH_ENABLE_=(config.getInt("system.realtimegraph_enable"))
|
||||
}
|
||||
|
||||
def getRealtimeGraph = REALTIMEGRAPH_ENABLE
|
||||
|
||||
def getDBPath = DBPATH
|
||||
|
||||
def getBlockPath = BLOCKPATH
|
||||
|
||||
def getFileMax = FILEMAX
|
||||
|
||||
def getLimitBlockTransNum = LIMIT_BLOCK_TRANS_NUM
|
||||
|
||||
def getNumberOfTransProcessor = NUMBER_OF_TRANSPROCESSOR
|
||||
|
||||
def getBlockNumberOfRaft = BLOCKNUMBER_OF_RAFT
|
||||
|
||||
def getTypeOfConsensus : String = TYPE_OF_CONSENSUS
|
||||
|
||||
def getHasPreloadTransOfApi = HAS_PRELOAD_TRANS_OF_API
|
||||
|
||||
def getIsVerifyOfEndorsement = IS_VERIFY_OF_ENDORSEMENT
|
||||
|
||||
def getNumberOfEndorsement = NUMBER_OF_ENDORSEMENT
|
||||
|
||||
def getBlockLength = BLOCK_LENGTH
|
||||
|
||||
def getMinBlockTransNum = MIN_BLOCK_TRANS_NUM
|
||||
|
||||
def getVoteNoteMin = VOTE_NOTE_MIN
|
||||
|
||||
def getTranCreateDur = TRAN_CREATE_DUR
|
||||
|
||||
def getMaxCacheTransNum = MAX_CATCH_TRANS_NUM
|
||||
|
||||
def getTransCreateType = TRANS_CREATE_TYPE
|
||||
|
||||
def getRetryTime = RETRY_TIME
|
||||
|
||||
def getDiskSpaceAlarm = DISKSPACE_ALARM_NUM
|
||||
|
||||
def getHttpServicePort = SERVERPORT
|
||||
|
||||
def getCheckCertValidate = CHECKCERTVALIDATE
|
||||
|
||||
def getContractOperationMode = CONTRACTOPERATIONMODE
|
||||
|
||||
def getVoteNodeList = VOTENODELIST
|
||||
|
||||
def getAccountChaincodeName = ACCOUNTCHAINCODENAEM
|
||||
|
||||
def getCertStatusChangeFunction = CertStatusChangeFunction
|
||||
|
||||
def getAccountChaincodeVersion = ACCOUNTCHAINCODVERSION
|
||||
|
||||
def getGenesisNodeName = GENESISNODENAME
|
||||
}
|
||||
|
@ -24,8 +24,7 @@ import com.typesafe.config.{Config, ConfigFactory}
|
||||
import rep.app.conf.{SystemConf, SystemProfile, TimePolicy}
|
||||
import rep.app.system.ClusterSystem.InitType
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.network.module.ModuleManager
|
||||
import rep.utils.GlobalUtils.ActorType
|
||||
import rep.network.module.cfrd.ModuleManagerOfCFRD
|
||||
import rep.storage.cfg._
|
||||
import java.io.File
|
||||
|
||||
@ -276,7 +275,17 @@ class ClusterSystem(sysTag: String, initType: Int, sysStart: Boolean) {
|
||||
throw new Exception("not enough disk space")
|
||||
}
|
||||
|
||||
moduleManager = sysActor.actorOf(ModuleManager.props("modulemanager", sysTag, enableStatistic, enableWebSocket, true), "modulemanager")
|
||||
val typeConsensus = SystemProfile.getTypeOfConsensus
|
||||
if (typeConsensus == "CRFD") {
|
||||
moduleManager = sysActor.actorOf(ModuleManagerOfCFRD.props("modulemanager", sysTag, enableStatistic, enableWebSocket, true), "modulemanager")
|
||||
}else if(typeConsensus == "RAFT"){
|
||||
|
||||
}else if(typeConsensus == "PBFT"){
|
||||
|
||||
}else{
|
||||
RepLogger.error(RepLogger.System_Logger, sysTag + "~" + "System" + " ~ " + s"ClusterSystem ${sysTag} not startup,unknow consensus" + " ~ ")
|
||||
}
|
||||
|
||||
|
||||
RepLogger.trace(RepLogger.System_Logger, sysTag + "~" + "System" + " ~ " + s"ClusterSystem ${sysTag} start" + " ~ ")
|
||||
}
|
||||
|
@ -16,11 +16,10 @@
|
||||
|
||||
package rep.log
|
||||
|
||||
import rep.network.Topic
|
||||
import rep.protos.peer._
|
||||
import akka.actor.{ Props, Address, Actor, ActorRef, Terminated }
|
||||
import akka.actor.{Actor, ActorRef, Address, Props, Terminated}
|
||||
import akka.cluster.pubsub.DistributedPubSub
|
||||
import akka.cluster.pubsub.DistributedPubSubMediator.{ Publish, Subscribe }
|
||||
import akka.cluster.pubsub.DistributedPubSubMediator.{Publish, Subscribe}
|
||||
import akka.cluster.Cluster
|
||||
import akka.cluster.ClusterEvent._
|
||||
import akka.cluster.MemberStatus
|
||||
@ -28,8 +27,10 @@ import rep.ui.web.EventServer
|
||||
import rep.network.tools.PeerExtension
|
||||
import rep.storage._
|
||||
import akka.stream.Graph
|
||||
import scala.collection.mutable.{ HashSet, Set }
|
||||
import rep.log.RecvEventActor.{ Register }
|
||||
|
||||
import scala.collection.mutable.{HashSet, Set}
|
||||
import rep.log.RecvEventActor.Register
|
||||
import rep.network.autotransaction.Topic
|
||||
import rep.network.util.NodeHelp
|
||||
|
||||
object RecvEventActor {
|
||||
|
@ -14,23 +14,18 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package rep.network
|
||||
package rep.network.autotransaction
|
||||
|
||||
import akka.actor.{ Actor, Address, Props }
|
||||
import akka.actor.Props
|
||||
import com.google.protobuf.ByteString
|
||||
import com.google.protobuf.timestamp.Timestamp
|
||||
import rep.app.conf.SystemProfile
|
||||
import rep.crypto.{ Sha256 }
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.network.cluster.ClusterActor
|
||||
import rep.network.tools.PeerExtension
|
||||
import rep.protos.peer._
|
||||
import rep.utils.GlobalUtils.ActorType
|
||||
import rep.utils.{ IdTool, TimeUtils }
|
||||
import akka.cluster.pubsub.DistributedPubSubMediator.Publish
|
||||
import java.text.SimpleDateFormat
|
||||
import rep.crypto.cert.SignTool
|
||||
import rep.log.RepLogger
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.protos.peer._
|
||||
import rep.utils.{IdTool, TimeUtils}
|
||||
import rep.network.module.ModuleActorType
|
||||
/**
|
||||
*
|
||||
* 代理节点辅助类
|
||||
@ -136,10 +131,11 @@ object PeerHelper {
|
||||
}
|
||||
|
||||
class PeerHelper(name: String) extends ModuleBase(name) {
|
||||
import rep.network.PeerHelper._
|
||||
import scala.concurrent.duration._
|
||||
import PeerHelper._
|
||||
import context.dispatcher
|
||||
|
||||
import scala.concurrent.duration._
|
||||
|
||||
//val si1 = scala.io.Source.fromFile("scripts/example_invoke_" + pe.getSysTag + ".js")
|
||||
//val li1 = try si1.mkString finally si1.close()
|
||||
val si2 = scala.io.Source.fromFile("api_req/json/transfer_" + pe.getSysTag + ".json","UTF-8")
|
||||
@ -176,7 +172,7 @@ class PeerHelper(name: String) extends ModuleBase(name) {
|
||||
val t3 = createTransaction4Invoke(pe.getSysTag, chaincode,
|
||||
"transfer", Seq(li2))
|
||||
|
||||
pe.getActorRef(ActorType.transactionpool) ! t3
|
||||
pe.getActorRef(ModuleActorType.ActorType.transactionpool) ! t3
|
||||
RepLogger.trace(RepLogger.System_Logger,this.getLogMsgPrefix(s"########################create transaction id =${t3.id}"))
|
||||
} catch {
|
||||
case e: RuntimeException => throw e
|
@ -1,110 +1,109 @@
|
||||
/*
|
||||
* Copyright 2019 Blockchain Technology and Application Joint Lab, Linkel Technology Co., Ltd, Beijing, Fintech Research Center of ISCAS.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BA SIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package rep.network.base
|
||||
|
||||
import akka.actor.{Actor, Address, ActorRef}
|
||||
import rep.app.system.ClusterSystem
|
||||
import rep.network.cluster.ClusterActor
|
||||
import rep.network.tools.PeerExtension
|
||||
import rep.crypto.Sha256
|
||||
import scala.collection.mutable
|
||||
import org.slf4j.LoggerFactory
|
||||
import rep.log.RepTimeTracer
|
||||
import rep.log.RepLogger
|
||||
import rep.utils.GlobalUtils.{ActorType}
|
||||
|
||||
|
||||
/**
|
||||
* 模块基础类伴生对象
|
||||
*
|
||||
* @author shidianyue
|
||||
* @version 1.0
|
||||
*
|
||||
* @update 2018-05 jiangbuyun
|
||||
**/
|
||||
object ModuleBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统模块基础类
|
||||
*
|
||||
* @author shidianyue
|
||||
* @version 1.0
|
||||
* @param name 模块名称
|
||||
**/
|
||||
|
||||
abstract class ModuleBase(name: String) extends Actor with ClusterActor with BaseActor{
|
||||
val pe = PeerExtension(context.system)
|
||||
val atype = ModuleNameToIntActorType
|
||||
atype match{
|
||||
case 0 =>
|
||||
case _ =>
|
||||
RepLogger.info(RepLogger.System_Logger, this.getLogMsgPrefix(s"--------Actor create,actor name=${name}"))
|
||||
pe.register(atype, self)
|
||||
}
|
||||
|
||||
private def ModuleNameToIntActorType:Int={
|
||||
name match{
|
||||
case "memberlistener" => 1
|
||||
case "modulemanager" => 2
|
||||
case "webapi" => 3
|
||||
case "peerhelper" => 4
|
||||
case "blocker" => 5
|
||||
case "preloaderoftransaction" => 6
|
||||
case "endorser" => 7
|
||||
case "voter" => 8
|
||||
case "synchrequester" => 9
|
||||
case "transactionpool" => 10
|
||||
case "storager" => 11
|
||||
case "synchresponser" => 12
|
||||
case "statiscollecter" => 13
|
||||
case "endorsementcollectioner" => 14
|
||||
//case "endorsementrequester" => 15
|
||||
case "confirmerofblock" => 16
|
||||
case "gensisblock" => 17
|
||||
case "api" => 18
|
||||
case "transactiondispatcher" => 19
|
||||
case "dispatchofRecvendorsement" => 20
|
||||
case "dispatchofpreload" => 21
|
||||
case _ => 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 日志前缀
|
||||
*
|
||||
*/
|
||||
def getLogMsgPrefix(msg:String):String = {
|
||||
s"${pe.getSysTag}~${this.name}~${msg}~"
|
||||
}
|
||||
|
||||
/**
|
||||
* 事件时间戳封装
|
||||
* @param msg
|
||||
* @param step
|
||||
* @param actorRef
|
||||
*/
|
||||
def logTime(timetag:String,time:Long,isstart:Boolean,bheight:Long,trannum:Int): Unit = {
|
||||
if(isstart){
|
||||
RepTimeTracer.setStartTime(pe.getSysTag, timetag, time,bheight,trannum)
|
||||
}else{
|
||||
RepTimeTracer.setEndTime(pe.getSysTag, timetag, time,bheight,trannum)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Copyright 2019 Blockchain Technology and Application Joint Lab, Linkel Technology Co., Ltd, Beijing, Fintech Research Center of ISCAS.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BA SIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package rep.network.base
|
||||
|
||||
import akka.actor.{Actor, Address, ActorRef}
|
||||
import rep.app.system.ClusterSystem
|
||||
import rep.network.cluster.ClusterActor
|
||||
import rep.network.tools.PeerExtension
|
||||
import rep.crypto.Sha256
|
||||
import scala.collection.mutable
|
||||
import org.slf4j.LoggerFactory
|
||||
import rep.log.RepTimeTracer
|
||||
import rep.log.RepLogger
|
||||
|
||||
|
||||
/**
|
||||
* 模块基础类伴生对象
|
||||
*
|
||||
* @author shidianyue
|
||||
* @version 1.0
|
||||
*
|
||||
* @update 2018-05 jiangbuyun
|
||||
**/
|
||||
object ModuleBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统模块基础类
|
||||
*
|
||||
* @author shidianyue
|
||||
* @version 1.0
|
||||
* @param name 模块名称
|
||||
**/
|
||||
|
||||
abstract class ModuleBase(name: String) extends Actor with ClusterActor with BaseActor{
|
||||
val pe = PeerExtension(context.system)
|
||||
/*val atype = ModuleNameToIntActorType
|
||||
atype match{
|
||||
case 0 =>
|
||||
case _ =>
|
||||
RepLogger.info(RepLogger.System_Logger, this.getLogMsgPrefix(s"--------Actor create,actor name=${name}"))
|
||||
pe.register(atype, self)
|
||||
}*/
|
||||
|
||||
/*private def ModuleNameToIntActorType:Int={
|
||||
name match{
|
||||
case "memberlistener" => 1
|
||||
case "modulemanager" => 2
|
||||
case "webapi" => 3
|
||||
case "peerhelper" => 4
|
||||
case "blocker" => 5
|
||||
case "preloaderoftransaction" => 6
|
||||
case "endorser" => 7
|
||||
case "voter" => 8
|
||||
case "synchrequester" => 9
|
||||
case "transactionpool" => 10
|
||||
case "storager" => 11
|
||||
case "synchresponser" => 12
|
||||
case "statiscollecter" => 13
|
||||
case "endorsementcollectioner" => 14
|
||||
//case "endorsementrequester" => 15
|
||||
case "confirmerofblock" => 16
|
||||
case "gensisblock" => 17
|
||||
case "api" => 18
|
||||
case "transactiondispatcher" => 19
|
||||
case "dispatchofRecvendorsement" => 20
|
||||
case "dispatchofpreload" => 21
|
||||
case _ => 0
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
* 日志前缀
|
||||
*
|
||||
*/
|
||||
def getLogMsgPrefix(msg:String):String = {
|
||||
s"${pe.getSysTag}~${this.name}~${msg}~"
|
||||
}
|
||||
|
||||
/**
|
||||
* 事件时间戳封装
|
||||
* @param msg
|
||||
* @param step
|
||||
* @param actorRef
|
||||
*/
|
||||
def logTime(timetag:String,time:Long,isstart:Boolean,bheight:Long,trannum:Int): Unit = {
|
||||
if(isstart){
|
||||
RepTimeTracer.setStartTime(pe.getSysTag, timetag, time,bheight,trannum)
|
||||
}else{
|
||||
RepTimeTracer.setEndTime(pe.getSysTag, timetag, time,bheight,trannum)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,24 +19,25 @@ package rep.network.cache
|
||||
import java.security.cert.Certificate
|
||||
|
||||
import com.google.protobuf.ByteString
|
||||
|
||||
import akka.actor.{ Actor, Address, Props }
|
||||
import akka.actor.{Actor, Address, Props}
|
||||
import akka.cluster.pubsub.DistributedPubSubMediator.Publish
|
||||
import rep.app.conf.SystemProfile
|
||||
import rep.crypto.cert.SignTool
|
||||
import rep.network.{ Topic }
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.network.cache.TransactionPool.CheckedTransactionResult
|
||||
import rep.network.consensus.vote.Voter.VoteOfBlocker
|
||||
import rep.network.consensus.cfrd.vote.Voter.VoteOfBlocker
|
||||
import rep.protos.peer.ChaincodeId
|
||||
import rep.protos.peer.{ Event, Transaction }
|
||||
import rep.protos.peer.{Event, Transaction}
|
||||
import rep.storage.IdxPrefix.WorldStateKeyPreFix
|
||||
import rep.storage.ImpDataAccess
|
||||
import rep.utils.{ ActorUtils, GlobalUtils }
|
||||
import rep.utils.{ActorUtils, GlobalUtils}
|
||||
import rep.utils.GlobalUtils.EventType
|
||||
import rep.utils.SerializeUtils
|
||||
import rep.log.RepLogger
|
||||
import rep.network.autotransaction.Topic
|
||||
import rep.network.util.NodeHelp
|
||||
import rep.network.module._
|
||||
import rep.network.module.cfrd.CFRDActorType
|
||||
|
||||
/**
|
||||
* 交易缓冲池伴生对象
|
||||
@ -128,7 +129,7 @@ class TransactionPool(moduleName: String) extends ModuleBase(moduleName) {
|
||||
RepLogger.trace(RepLogger.System_Logger,this.getLogMsgPrefix(s"${pe.getSysTag} trans pool recv,txid=${t.id}"))
|
||||
//广播接收交易事件
|
||||
if (pe.getTransPoolMgr.getTransLength() >= SystemProfile.getMinBlockTransNum)
|
||||
pe.getActorRef(GlobalUtils.ActorType.voter) ! VoteOfBlocker
|
||||
pe.getActorRef(CFRDActorType.ActorType.voter) ! VoteOfBlocker
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,11 +18,11 @@ package rep.network.cluster
|
||||
|
||||
import akka.actor.{Actor, ActorRef}
|
||||
import akka.cluster.pubsub.DistributedPubSubMediator.{Publish, Subscribe}
|
||||
import rep.network.Topic
|
||||
import rep.protos.peer.Event
|
||||
import rep.utils.ActorUtils
|
||||
import rep.utils.GlobalUtils.EventType
|
||||
import rep.app.conf.SystemProfile
|
||||
import rep.network.autotransaction.Topic
|
||||
|
||||
/**
|
||||
* Akka组网类
|
||||
|
@ -16,27 +16,29 @@
|
||||
|
||||
package rep.network.cluster
|
||||
|
||||
import akka.actor.{ Actor, Address, Props }
|
||||
import akka.actor.{Actor, Address, Props}
|
||||
import akka.cluster.ClusterEvent._
|
||||
import akka.cluster.pubsub.DistributedPubSub
|
||||
import akka.cluster.{ Cluster, MemberStatus }
|
||||
import akka.cluster.{Cluster, MemberStatus}
|
||||
import rep.app.conf.TimePolicy
|
||||
import rep.app.conf.SystemProfile
|
||||
import rep.network.Topic
|
||||
import rep.network.cluster.MemberListener.{ Recollection }
|
||||
import rep.network.tools.PeerExtension
|
||||
import rep.utils.GlobalUtils.{ ActorType, EventType }
|
||||
import rep.utils.{ TimeUtils }
|
||||
import rep.network.cluster.MemberListener.Recollection
|
||||
import rep.network.module.cfrd.CFRDActorType
|
||||
import rep.utils.GlobalUtils.{ EventType}
|
||||
import rep.utils.TimeUtils
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
import scala.collection.mutable.HashMap
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.network.sync.SyncMsg.StartSync
|
||||
|
||||
import scala.util.control.Breaks._
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
import rep.log.RepLogger
|
||||
import rep.protos.peer.Event
|
||||
import rep.network.util.NodeHelp
|
||||
import rep.app.RepChainMgr
|
||||
import rep.network.autotransaction.Topic
|
||||
|
||||
/**
|
||||
* Cluster节点状态监听模块
|
||||
@ -158,7 +160,7 @@ class MemberListener(MoudleName: String) extends ModuleBase(MoudleName) with Clu
|
||||
if (pe.getNodeMgr.getStableNodes.size >= SystemProfile.getVoteNoteMin) {
|
||||
//组网成功之后开始系统同步
|
||||
RepLogger.info(RepLogger.System_Logger, this.getLogMsgPrefix(s"Recollection: system startup ,start sync,node name=${pe.getSysTag}"))
|
||||
pe.getActorRef(ActorType.synchrequester) ! StartSync(true)
|
||||
pe.getActorRef(CFRDActorType.ActorType.synchrequester) ! StartSync(true)
|
||||
this.isStartSynch = true
|
||||
} else {
|
||||
RepLogger.info(RepLogger.System_Logger, this.getLogMsgPrefix(s"Recollection: nodes less ${SystemProfile.getVoteNoteMin},node name=${pe.getSysTag}"))
|
||||
|
@ -14,36 +14,41 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package rep.network.consensus.block
|
||||
package rep.network.consensus.cfrd.block
|
||||
|
||||
import akka.util.Timeout
|
||||
|
||||
import scala.concurrent.duration._
|
||||
import akka.pattern.ask
|
||||
import akka.pattern.AskTimeoutException
|
||||
import scala.concurrent._
|
||||
|
||||
import akka.actor.{ ActorRef, Address, Props }
|
||||
import scala.concurrent._
|
||||
import akka.actor.{ActorRef, Address, Props}
|
||||
import akka.cluster.pubsub.DistributedPubSubMediator.Publish
|
||||
import com.google.protobuf.ByteString
|
||||
import rep.app.conf.{ SystemProfile, TimePolicy }
|
||||
import rep.app.conf.{SystemProfile, TimePolicy}
|
||||
import rep.crypto.Sha256
|
||||
import rep.network.consensus.vote.Voter.VoteOfBlocker
|
||||
import rep.network.consensus.cfrd.vote.Voter.VoteOfBlocker
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.network.consensus.block.Blocker.{ ConfirmedBlock, PreTransBlock, PreTransBlockResult }
|
||||
import rep.network.consensus.cfrd.block.Blocker.{ConfirmedBlock, PreTransBlock, PreTransBlockResult}
|
||||
import rep.protos.peer._
|
||||
import rep.storage.ImpDataAccess
|
||||
import rep.utils.GlobalUtils.{ ActorType, BlockEvent, EventType, NodeStatus }
|
||||
import rep.utils.GlobalUtils.{BlockEvent, EventType, NodeStatus}
|
||||
|
||||
import scala.collection.mutable
|
||||
import com.sun.beans.decoder.FalseElementHandler
|
||||
|
||||
import scala.util.control.Breaks
|
||||
import rep.utils.IdTool
|
||||
import rep.network.module.ModuleActorType
|
||||
|
||||
import scala.util.control.Breaks._
|
||||
import rep.network.consensus.util.{ BlockHelp, BlockVerify }
|
||||
import rep.network.consensus.util.{BlockHelp, BlockVerify}
|
||||
import rep.network.util.NodeHelp
|
||||
import rep.network.Topic
|
||||
import rep.network.consensus.endorse.EndorseMsg
|
||||
import rep.network.consensus.cfrd.endorse.EndorseMsg
|
||||
import rep.log.RepLogger
|
||||
import rep.log.RepTimeTracer
|
||||
import rep.network.autotransaction.Topic
|
||||
import rep.network.module.cfrd.CFRDActorType
|
||||
|
||||
object Blocker {
|
||||
def props(name: String): Props = Props(classOf[Blocker], name)
|
||||
@ -117,7 +122,7 @@ class Blocker(moduleName: String) extends ModuleBase(moduleName) {
|
||||
private def ExecuteTransactionOfBlock(block: Block): Block = {
|
||||
try {
|
||||
//val future = pe.getActorRef(ActorType.preloaderoftransaction) ? Blocker.PreTransBlock(block, "preload")
|
||||
val future = pe.getActorRef(ActorType.dispatchofpreload) ? Blocker.PreTransBlock(block, "preload")
|
||||
val future = pe.getActorRef(ModuleActorType.ActorType.dispatchofpreload) ? Blocker.PreTransBlock(block, "preload")
|
||||
val result = Await.result(future, timeout.duration).asInstanceOf[PreTransBlockResult]
|
||||
if (result.result) {
|
||||
result.blc
|
||||
@ -210,11 +215,11 @@ class Blocker(moduleName: String) extends ModuleBase(moduleName) {
|
||||
}else{
|
||||
//在发出背书时,告诉对方我是当前出块人,取出系统的名称
|
||||
RepTimeTracer.setStartTime(pe.getSysTag, "Endorsement", System.currentTimeMillis(), blc.height, blc.transactions.size)
|
||||
pe.getActorRef(ActorType.endorsementcollectioner) ! EndorseMsg.CollectEndorsement(this.preblock, pe.getSysTag)
|
||||
pe.getActorRef(CFRDActorType.ActorType.endorsementcollectioner) ! EndorseMsg.CollectEndorsement(this.preblock, pe.getSysTag)
|
||||
}
|
||||
} else {
|
||||
RepLogger.trace(RepLogger.Consensus_Logger, this.getLogMsgPrefix("create new block error,CreateBlock is null" + "~" + selfAddr))
|
||||
pe.getActorRef(ActorType.voter) ! VoteOfBlocker
|
||||
pe.getActorRef(CFRDActorType.ActorType.voter) ! VoteOfBlocker
|
||||
}
|
||||
//}
|
||||
}
|
@ -14,32 +14,37 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package rep.network.consensus.block
|
||||
package rep.network.consensus.cfrd.block
|
||||
|
||||
import akka.util.Timeout
|
||||
|
||||
import scala.concurrent.duration._
|
||||
import akka.pattern.ask
|
||||
import akka.pattern.AskTimeoutException
|
||||
|
||||
import scala.concurrent._
|
||||
import rep.app.conf.{ SystemProfile }
|
||||
import akka.actor.{ ActorRef, Props, Address }
|
||||
import rep.app.conf.SystemProfile
|
||||
import akka.actor.{ActorRef, Address, Props}
|
||||
import rep.crypto.Sha256
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.network.Topic
|
||||
import rep.network.util.NodeHelp
|
||||
import rep.protos.peer.{ Event, Transaction }
|
||||
import rep.utils.GlobalUtils.{ ActorType, BlockEvent, EventType, NodeStatus }
|
||||
import rep.protos.peer.{Event, Transaction}
|
||||
import rep.utils.GlobalUtils.{ BlockEvent, EventType, NodeStatus}
|
||||
import com.sun.beans.decoder.FalseElementHandler
|
||||
|
||||
import scala.util.control.Breaks._
|
||||
import scala.util.control.Exception.Finally
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import rep.network.consensus.block.Blocker.{ ConfirmedBlock }
|
||||
import rep.network.persistence.Storager.{ BlockRestore, SourceOfBlock, BatchStore }
|
||||
import rep.network.consensus.util.{ BlockVerify, BlockHelp }
|
||||
|
||||
import rep.network.consensus.cfrd.block.Blocker.ConfirmedBlock
|
||||
import rep.network.persistence.Storager.{BatchStore, BlockRestore, SourceOfBlock}
|
||||
import rep.network.consensus.util.{BlockHelp, BlockVerify}
|
||||
import rep.log.RepLogger
|
||||
import rep.log.RepTimeTracer
|
||||
import rep.network.autotransaction.Topic
|
||||
import rep.network.module.ModuleActorType
|
||||
import rep.network.sync.SyncMsg.SyncRequestOfStorager
|
||||
import rep.network.consensus.vote.Voter.VoteOfBlocker
|
||||
import rep.network.consensus.cfrd.vote.Voter.VoteOfBlocker
|
||||
|
||||
object ConfirmOfBlock {
|
||||
def props(name: String): Props = Props(classOf[ConfirmOfBlock], name)
|
||||
@ -106,7 +111,7 @@ class ConfirmOfBlock(moduleName: String) extends ModuleBase(moduleName) {
|
||||
//背书信息排序正确
|
||||
RepLogger.trace(RepLogger.Consensus_Logger, this.getLogMsgPrefix(s"confirm verify endorsement sort,height=${block.height}"))
|
||||
pe.getBlockCacheMgr.addToCache(BlockRestore(block, SourceOfBlock.CONFIRMED_BLOCK, actRefOfBlock))
|
||||
pe.getActorRef(ActorType.storager) ! BatchStore
|
||||
pe.getActorRef(ModuleActorType.ActorType.storager) ! BatchStore
|
||||
sendEvent(EventType.RECEIVE_INFO, mediator, pe.getSysTag, Topic.Block, Event.Action.BLOCK_NEW)
|
||||
} else {
|
||||
////背书信息排序错误
|
||||
@ -117,7 +122,7 @@ class ConfirmOfBlock(moduleName: String) extends ModuleBase(moduleName) {
|
||||
} else {
|
||||
RepLogger.trace(RepLogger.Consensus_Logger, this.getLogMsgPrefix(s"confirm verify endorsement sort,height=${block.height}"))
|
||||
pe.getBlockCacheMgr.addToCache(BlockRestore(block, SourceOfBlock.CONFIRMED_BLOCK, actRefOfBlock))
|
||||
pe.getActorRef(ActorType.storager) ! BatchStore
|
||||
pe.getActorRef(ModuleActorType.ActorType.storager) ! BatchStore
|
||||
sendEvent(EventType.RECEIVE_INFO, mediator, pe.getSysTag, Topic.Block, Event.Action.BLOCK_NEW)
|
||||
}
|
||||
}
|
@ -14,28 +14,30 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package rep.network.consensus.block
|
||||
package rep.network.consensus.cfrd.block
|
||||
|
||||
import akka.actor.{ Actor, ActorRef, Props, Address, ActorSelection }
|
||||
import akka.actor.{Actor, ActorRef, ActorSelection, Address, Props}
|
||||
import akka.cluster.pubsub.DistributedPubSubMediator.Publish
|
||||
import akka.routing._;
|
||||
import rep.app.conf.{ SystemProfile, TimePolicy }
|
||||
import akka.routing._
|
||||
import rep.app.conf.{SystemProfile, TimePolicy}
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.network.consensus.endorse.EndorseMsg.{ RequesterOfEndorsement, ResultOfEndorseRequester, CollectEndorsement,ResendEndorseInfo }
|
||||
import rep.network.consensus.block.Blocker.ConfirmedBlock
|
||||
import rep.network.consensus.cfrd.endorse.EndorseMsg.{CollectEndorsement, RequesterOfEndorsement, ResendEndorseInfo, ResultOfEndorseRequester}
|
||||
import rep.network.consensus.cfrd.block.Blocker.ConfirmedBlock
|
||||
import rep.network.tools.PeerExtension
|
||||
import rep.network.Topic
|
||||
import rep.protos.peer._
|
||||
import rep.utils.GlobalUtils.{ EventType }
|
||||
import rep.utils.GlobalUtils.EventType
|
||||
import rep.utils._
|
||||
|
||||
import scala.collection.mutable._
|
||||
import rep.network.consensus.util.BlockVerify
|
||||
|
||||
import scala.util.control.Breaks
|
||||
import rep.network.util.NodeHelp
|
||||
import rep.network.consensus.util.BlockHelp
|
||||
import rep.network.consensus.util.BlockVerify
|
||||
import rep.log.RepLogger
|
||||
import rep.log.RepTimeTracer
|
||||
import rep.network.autotransaction.Topic
|
||||
|
||||
object EndorseCollector {
|
||||
def props(name: String): Props = Props(classOf[EndorseCollector], name)
|
@ -14,31 +14,34 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package rep.network.consensus.block
|
||||
package rep.network.consensus.cfrd.block
|
||||
|
||||
import akka.util.Timeout
|
||||
|
||||
import scala.concurrent.duration._
|
||||
import akka.pattern.ask
|
||||
import akka.pattern.AskTimeoutException
|
||||
import scala.concurrent._
|
||||
|
||||
import akka.actor.{ Actor, ActorRef, Props, Address, ActorSelection }
|
||||
import scala.concurrent._
|
||||
import akka.actor.{Actor, ActorRef, ActorSelection, Address, Props}
|
||||
import com.google.protobuf.ByteString
|
||||
import com.google.protobuf.timestamp.Timestamp
|
||||
import rep.app.conf.{ SystemProfile, TimePolicy }
|
||||
import rep.app.conf.{SystemProfile, TimePolicy}
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.network.consensus.endorse.EndorseMsg.{ EndorsementInfo, ResultOfEndorsed, RequesterOfEndorsement, ResultOfEndorseRequester, ResultFlagOfEndorse,ResendEndorseInfo }
|
||||
import rep.network.consensus.cfrd.endorse.EndorseMsg.{EndorsementInfo, RequesterOfEndorsement, ResendEndorseInfo, ResultFlagOfEndorse, ResultOfEndorseRequester, ResultOfEndorsed}
|
||||
import rep.network.tools.PeerExtension
|
||||
import rep.network.Topic
|
||||
import rep.protos.peer._
|
||||
import rep.utils._
|
||||
import akka.pattern.AskTimeoutException
|
||||
import rep.network.consensus.util.BlockVerify
|
||||
|
||||
import scala.util.control.Breaks
|
||||
import rep.utils.GlobalUtils.{ EventType, ActorType }
|
||||
import rep.utils.GlobalUtils.{ EventType}
|
||||
import rep.network.sync.SyncMsg.StartSync
|
||||
import rep.log.RepLogger
|
||||
import rep.log.RepTimeTracer
|
||||
import rep.network.autotransaction.Topic
|
||||
import rep.network.module.cfrd.CFRDActorType
|
||||
|
||||
object EndorsementRequest4Future {
|
||||
def props(name: String): Props = Props(classOf[EndorsementRequest4Future], name)
|
||||
@ -101,7 +104,7 @@ class EndorsementRequest4Future(moduleName: String) extends ModuleBase(moduleNam
|
||||
if (result.result == ResultFlagOfEndorse.BlockHeightError) {
|
||||
if (result.endorserOfChainInfo.height > pe.getCurrentHeight + 1) {
|
||||
//todo 需要从块缓冲判断是否启动块同步
|
||||
pe.getActorRef(ActorType.synchrequester) ! StartSync(false)
|
||||
pe.getActorRef(CFRDActorType.ActorType.synchrequester) ! StartSync(false)
|
||||
context.parent ! ResultOfEndorseRequester(false, null, reqinfo.blc.hashOfBlock.toStringUtf8(), reqinfo.endorer)
|
||||
RepLogger.trace(RepLogger.Consensus_Logger, this.getLogMsgPrefix( s"--------endorsementRequest4Future recv endorsement result must synch,height=${reqinfo.blc.height},local height=${pe.getCurrentHeight} "))
|
||||
} else {
|
@ -14,33 +14,39 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package rep.network.consensus.block
|
||||
package rep.network.consensus.cfrd.block
|
||||
|
||||
import akka.util.Timeout
|
||||
|
||||
import scala.concurrent.duration._
|
||||
import akka.pattern.ask
|
||||
import akka.pattern.AskTimeoutException
|
||||
import scala.concurrent._
|
||||
|
||||
import akka.actor.{ ActorRef, Address, Props }
|
||||
import scala.concurrent._
|
||||
import akka.actor.{ActorRef, Address, Props}
|
||||
import akka.cluster.pubsub.DistributedPubSubMediator.Publish
|
||||
import com.google.protobuf.ByteString
|
||||
import rep.app.conf.{ SystemProfile, TimePolicy }
|
||||
import rep.app.conf.{SystemProfile, TimePolicy}
|
||||
import rep.crypto.Sha256
|
||||
import rep.network._
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.network.consensus.block.Blocker.{ConfirmedBlock,PreTransBlock,PreTransBlockResult}
|
||||
import rep.network.consensus.cfrd.block.Blocker.{ConfirmedBlock, PreTransBlock, PreTransBlockResult}
|
||||
import rep.protos.peer._
|
||||
import rep.storage.ImpDataAccess
|
||||
import rep.utils.GlobalUtils.{ ActorType, BlockEvent, EventType, NodeStatus }
|
||||
import rep.network.module.ModuleActorType
|
||||
import rep.utils.GlobalUtils.{ BlockEvent, EventType, NodeStatus}
|
||||
|
||||
import scala.collection.mutable
|
||||
import com.sun.beans.decoder.FalseElementHandler
|
||||
|
||||
import scala.util.control.Breaks
|
||||
import rep.utils.IdTool
|
||||
|
||||
import scala.util.control.Breaks._
|
||||
import rep.network.consensus.util.{ BlockHelp, BlockVerify }
|
||||
import rep.network.consensus.util.{BlockHelp, BlockVerify}
|
||||
import rep.network.util.NodeHelp
|
||||
import rep.log.RepLogger
|
||||
import rep.network.autotransaction.Topic
|
||||
|
||||
object GenesisBlocker {
|
||||
def props(name: String): Props = Props(classOf[GenesisBlocker], name)
|
||||
@ -80,7 +86,7 @@ class GenesisBlocker(moduleName: String) extends ModuleBase(moduleName) {
|
||||
private def ExecuteTransactionOfBlock(block: Block): Block = {
|
||||
try {
|
||||
//val future = pe.getActorRef(ActorType.preloaderoftransaction) ? PreTransBlock(block, "preload")
|
||||
val future = pe.getActorRef(ActorType.dispatchofpreload) ? PreTransBlock(block, "preload")
|
||||
val future = pe.getActorRef(ModuleActorType.ActorType.dispatchofpreload) ? PreTransBlock(block, "preload")
|
||||
val result = Await.result(future, timeout.duration).asInstanceOf[PreTransBlockResult]
|
||||
if (result.result) {
|
||||
result.blc
|
@ -14,27 +14,29 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package rep.network.consensus.endorse
|
||||
package rep.network.consensus.cfrd.endorse
|
||||
|
||||
import akka.actor.{ Actor, ActorRef, Props, Address, ActorSelection }
|
||||
import akka.actor.{Actor, ActorRef, ActorSelection, Address, Props}
|
||||
import akka.cluster.pubsub.DistributedPubSubMediator.Publish
|
||||
import akka.routing._;
|
||||
import rep.app.conf.{ SystemProfile, TimePolicy }
|
||||
import akka.routing._
|
||||
import rep.app.conf.{SystemProfile, TimePolicy}
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.network.tools.PeerExtension
|
||||
import rep.network.Topic
|
||||
import rep.protos.peer._
|
||||
import rep.utils.GlobalUtils.{ EventType }
|
||||
import rep.utils.GlobalUtils.EventType
|
||||
import rep.utils._
|
||||
|
||||
import scala.collection.mutable._
|
||||
import rep.network.consensus.util.BlockVerify
|
||||
|
||||
import scala.util.control.Breaks
|
||||
import rep.network.util.NodeHelp
|
||||
import rep.network.consensus.util.BlockHelp
|
||||
import rep.network.consensus.util.BlockVerify
|
||||
import rep.log.RepLogger
|
||||
import rep.log.RepTimeTracer
|
||||
import rep.network.consensus.endorse.EndorseMsg.{ EndorsementInfo}
|
||||
import rep.network.autotransaction.Topic
|
||||
import rep.network.consensus.cfrd.endorse.EndorseMsg.EndorsementInfo
|
||||
|
||||
object DispatchOfRecvEndorsement {
|
||||
def props(name: String): Props = Props(classOf[DispatchOfRecvEndorsement], name)
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package rep.network.consensus.endorse
|
||||
package rep.network.consensus.cfrd.endorse
|
||||
|
||||
import akka.actor.{ Address}
|
||||
import rep.protos.peer.{Signature,Block,BlockchainInfo}
|
@ -14,36 +14,39 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package rep.network.consensus.endorse
|
||||
package rep.network.consensus.cfrd.endorse
|
||||
|
||||
import akka.util.Timeout
|
||||
|
||||
import scala.concurrent.duration._
|
||||
import akka.pattern.ask
|
||||
import akka.pattern.AskTimeoutException
|
||||
import scala.concurrent._
|
||||
|
||||
import akka.actor.{ ActorRef, Props, Address, ActorSystemImpl }
|
||||
import scala.concurrent._
|
||||
import akka.actor.{ActorRef, ActorSystemImpl, Address, Props}
|
||||
import rep.crypto.Sha256
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.network.Topic
|
||||
import rep.network.util.NodeHelp
|
||||
import rep.protos.peer.{ Event, Transaction }
|
||||
import rep.app.conf.{ SystemProfile, TimePolicy, SystemCertList }
|
||||
import rep.storage.{ ImpDataPreload, ImpDataPreloadMgr }
|
||||
import rep.utils.GlobalUtils.{ ActorType, BlockEvent, EventType, NodeStatus }
|
||||
import rep.protos.peer.{Event, Transaction}
|
||||
import rep.app.conf.{SystemCertList, SystemProfile, TimePolicy}
|
||||
import rep.storage.{ImpDataPreload, ImpDataPreloadMgr}
|
||||
import rep.utils.GlobalUtils.{ BlockEvent, EventType, NodeStatus}
|
||||
import com.sun.beans.decoder.FalseElementHandler
|
||||
//import rep.network.consensus.vote.Voter.VoteOfBlocker
|
||||
import rep.network.autotransaction.Topic
|
||||
//import rep.network.consensus.cfrd.vote.Voter.VoteOfBlocker
|
||||
import sun.font.TrueTypeFont
|
||||
import scala.util.control.Breaks._
|
||||
import rep.network.module.ModuleActorType
|
||||
import rep.network.module.cfrd.CFRDActorType
|
||||
import scala.util.control.Exception.Finally
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import rep.network.consensus.endorse.EndorseMsg.{ EndorsementInfo, ResultOfEndorsed, ResultFlagOfEndorse }
|
||||
import rep.network.consensus.block.Blocker.{ PreTransBlock, PreTransBlockResult }
|
||||
import rep.network.consensus.cfrd.endorse.EndorseMsg.{ EndorsementInfo, ResultOfEndorsed, ResultFlagOfEndorse }
|
||||
import rep.network.consensus.cfrd.block.Blocker.{ PreTransBlock, PreTransBlockResult }
|
||||
import rep.network.consensus.util.{ BlockVerify, BlockHelp }
|
||||
import rep.network.sync.SyncMsg.StartSync
|
||||
import rep.log.RepLogger
|
||||
import rep.log.RepTimeTracer
|
||||
import rep.network.consensus.vote.Voter
|
||||
import rep.network.consensus.cfrd.vote.Voter
|
||||
|
||||
|
||||
object Endorser4Future {
|
||||
@ -67,7 +70,7 @@ class Endorser4Future(moduleName: String) extends ModuleBase(moduleName) {
|
||||
//背书块的交易预执行,然后验证block
|
||||
private def AskPreloadTransactionOfBlock(block: Block): Future[Boolean] =
|
||||
//pe.getActorRef(ActorType.preloaderoftransaction).ask(PreTransBlock(block, "endors"))(timeout).mapTo[PreTransBlockResult].flatMap(f => {
|
||||
pe.getActorRef(ActorType.dispatchofpreload).ask(PreTransBlock(block, "endors"))(timeout).mapTo[PreTransBlockResult].flatMap(f => {
|
||||
pe.getActorRef(ModuleActorType.ActorType.dispatchofpreload).ask(PreTransBlock(block, "endors"))(timeout).mapTo[PreTransBlockResult].flatMap(f => {
|
||||
//println(s"${pe.getSysTag}:entry AskPreloadTransactionOfBlock")
|
||||
val result = Promise[Boolean]
|
||||
var tmpblock = f.blc.withHashOfBlock(block.hashOfBlock)
|
||||
@ -175,9 +178,9 @@ class Endorser4Future(moduleName: String) extends ModuleBase(moduleName) {
|
||||
} else {
|
||||
//todo 需要判断区块缓存,再决定是否需要启动同步
|
||||
if(info.blc.height > pe.getCurrentHeight+1){
|
||||
pe.getActorRef(ActorType.synchrequester) ! StartSync(false)
|
||||
pe.getActorRef(CFRDActorType.ActorType.synchrequester) ! StartSync(false)
|
||||
}else if(info.blc.height > pe.getCurrentHeight+1){
|
||||
pe.getActorRef(ActorType.voter) ! Voter.VoteOfForce
|
||||
pe.getActorRef(CFRDActorType.ActorType.voter) ! Voter.VoteOfForce
|
||||
}
|
||||
//当前块hash和抽签的出块人都不一致,暂时不能够进行背书,可以进行缓存
|
||||
RepLogger.trace(RepLogger.Consensus_Logger, this.getLogMsgPrefix( s"block hash is not equal or blocker is not equal,recv endorse request,endorse height=${info.blc.height},local height=${pe.getCurrentHeight}"))
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package rep.network.consensus.vote
|
||||
package rep.network.consensus.cfrd.vote
|
||||
|
||||
import rep.crypto.Sha256
|
||||
import scala.collection.mutable
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package rep.network.consensus.vote
|
||||
package rep.network.consensus.cfrd.vote
|
||||
|
||||
import akka.actor.{ Actor, Address, Props }
|
||||
import rep.app.conf.{ SystemProfile, TimePolicy, SystemCertList }
|
||||
@ -22,13 +22,14 @@ import rep.crypto.Sha256
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.protos.peer.BlockchainInfo
|
||||
import rep.storage.ImpDataAccess
|
||||
import rep.utils.GlobalUtils.{ ActorType, BlockEvent, BlockerInfo, NodeStatus }
|
||||
import rep.utils.GlobalUtils.{ BlockEvent, BlockerInfo, NodeStatus }
|
||||
import com.sun.beans.decoder.FalseElementHandler
|
||||
import rep.network.util.NodeHelp
|
||||
import rep.network.consensus.block.Blocker.{ CreateBlock }
|
||||
import rep.network.consensus.cfrd.block.Blocker.{ CreateBlock }
|
||||
import rep.network.sync.SyncMsg.StartSync
|
||||
import rep.network.consensus.block.GenesisBlocker.GenesisBlock
|
||||
import rep.network.consensus.cfrd.block.GenesisBlocker.GenesisBlock
|
||||
import rep.log.RepLogger
|
||||
import rep.network.module.cfrd.CFRDActorType
|
||||
|
||||
object Voter {
|
||||
|
||||
@ -96,7 +97,7 @@ class Voter(moduleName: String) extends ModuleBase(moduleName) with CRFDVoter {
|
||||
private def NoticeBlockerMsg = {
|
||||
if (this.Blocker.blocker.equals(pe.getSysTag)) {
|
||||
//发送建立新块的消息
|
||||
pe.getActorRef(ActorType.blocker) ! CreateBlock
|
||||
pe.getActorRef(CFRDActorType.ActorType.blocker) ! CreateBlock
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,7 +139,7 @@ class Voter(moduleName: String) extends ModuleBase(moduleName) with CRFDVoter {
|
||||
RepLogger.trace(RepLogger.Vote_Logger, this.getLogMsgPrefix(s"sysname=${pe.getSysTag},read block voter,currentHeight=${this.Blocker.VoteHeight +SystemProfile.getBlockNumberOfRaft},currentHash=${currentblockhash}" + "~" + selfAddr))
|
||||
}else{
|
||||
RepLogger.trace(RepLogger.Vote_Logger, this.getLogMsgPrefix(s"sysname=${pe.getSysTag},second voter in synch,currentHeight=${this.Blocker.VoteHeight +SystemProfile.getBlockNumberOfRaft}" + "~" + selfAddr))
|
||||
pe.getActorRef(ActorType.synchrequester) ! StartSync(false)
|
||||
pe.getActorRef(CFRDActorType.ActorType.synchrequester) ! StartSync(false)
|
||||
}
|
||||
}else{
|
||||
NoticeBlockerMsg
|
||||
@ -191,7 +192,7 @@ class Voter(moduleName: String) extends ModuleBase(moduleName) with CRFDVoter {
|
||||
//系统属于初始化状态
|
||||
if (NodeHelp.isSeedNode(pe.getSysTag)) {
|
||||
// 建立创世块消息
|
||||
pe.getActorRef(ActorType.gensisblock) ! GenesisBlock
|
||||
pe.getActorRef(CFRDActorType.ActorType.gensisblock) ! GenesisBlock
|
||||
} else {
|
||||
// 发出同步消息
|
||||
//pe.setSystemStatus(NodeStatus.Synching)
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package rep.network.consensus.vote
|
||||
package rep.network.consensus.cfrd.vote
|
||||
|
||||
|
||||
|
@ -20,18 +20,20 @@ import com.google.protobuf.ByteString
|
||||
import com.google.protobuf.timestamp.Timestamp
|
||||
import scalapb.json4s.JsonFormat
|
||||
import rep.app.conf.SystemProfile
|
||||
import rep.crypto.{ Sha256 }
|
||||
import rep.protos.peer.{ Block, Signature, Transaction, ChaincodeId, CertId }
|
||||
import rep.crypto.Sha256
|
||||
import rep.protos.peer.{Block, CertId, ChaincodeId, Signature, Transaction}
|
||||
import rep.utils.TimeUtils
|
||||
import rep.storage.IdxPrefix
|
||||
import rep.sc.Shim._
|
||||
import rep.storage._
|
||||
import java.security.cert.{ Certificate }
|
||||
import rep.network.PeerHelper
|
||||
import java.security.cert.Certificate
|
||||
|
||||
import rep.utils.SerializeUtils
|
||||
|
||||
import scala.util.control.Breaks
|
||||
import org.slf4j.LoggerFactory
|
||||
import rep.crypto.cert.SignTool
|
||||
import rep.network.autotransaction.PeerHelper
|
||||
import rep.utils.IdTool
|
||||
|
||||
object BlockHelp {
|
||||
|
6
src/main/scala/rep/network/module/IModule.scala
Normal file
6
src/main/scala/rep/network/module/IModule.scala
Normal file
@ -0,0 +1,6 @@
|
||||
package rep.network.module
|
||||
|
||||
trait IModule {
|
||||
def startupConsensus: Unit
|
||||
def loadConsensusModule:Unit
|
||||
}
|
197
src/main/scala/rep/network/module/IModuleManager.scala
Normal file
197
src/main/scala/rep/network/module/IModuleManager.scala
Normal file
@ -0,0 +1,197 @@
|
||||
package rep.network.module
|
||||
|
||||
import akka.actor.Props
|
||||
import com.typesafe.config.Config
|
||||
import rep.app.conf.SystemProfile.Trans_Create_Type_Enum
|
||||
import rep.app.conf.{SystemProfile, TimePolicy}
|
||||
import rep.crypto.cert.SignTool
|
||||
import rep.log.{RepLogger, RepTimeTracer}
|
||||
import rep.network.autotransaction.PeerHelper
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.network.cache.TransactionPool
|
||||
import rep.network.cluster.MemberListener
|
||||
import rep.network.transaction.DispatchOfPreload
|
||||
import rep.network.persistence.Storager
|
||||
import rep.sc.TransactionDispatcher
|
||||
import rep.storage.ImpDataAccess
|
||||
import rep.storage.verify.verify4Storage
|
||||
import rep.ui.web.EventServer
|
||||
import rep.utils.ActorUtils
|
||||
|
||||
|
||||
/**
|
||||
* Created by jiangbuyun on 2020/03/15.
|
||||
* 模块管理的基础类,启动时加载默认的公共的actor,然后根据不同的共识协议,加载不同的共识actor
|
||||
* 不同的协议需要继承这个基础类
|
||||
*/
|
||||
object IModuleManager {
|
||||
def props(name: String, sysTag: String, enableStatistic: Boolean, enableWebSocket: Boolean, isStartup: Boolean): Props = Props(classOf[IModuleManager], name, sysTag, enableStatistic: Boolean, enableWebSocket: Boolean, isStartup: Boolean)
|
||||
|
||||
//启动共识模块的消息,这个消息的发送前提是系统同步已经完成,消息的发送者为同步模块
|
||||
case object startup_Consensus
|
||||
}
|
||||
|
||||
class IModuleManager(moduleName: String, sysTag: String, enableStatistic: Boolean, enableWebSocket: Boolean, isStartup: Boolean) extends ModuleBase(moduleName) with IModule{
|
||||
|
||||
private val conf = context.system.settings.config
|
||||
|
||||
init
|
||||
|
||||
if (!checkSystemStorage) {
|
||||
context.system.terminate()
|
||||
}
|
||||
|
||||
|
||||
loadCommonActor
|
||||
loadConsensusModule
|
||||
|
||||
private def checkSystemStorage: Boolean = {
|
||||
var r = true
|
||||
try {
|
||||
if (!verify4Storage.verify(sysTag)) {
|
||||
r = false
|
||||
}
|
||||
} catch {
|
||||
case e: Exception => {
|
||||
r = false
|
||||
//throw new Exception("Storager Verify Error,info:" + e.getMessage)
|
||||
}
|
||||
}
|
||||
r
|
||||
}
|
||||
|
||||
//初始化系统actor,完成公共actor的装载,包括证书、配置信息的装载,也包括存储的检查
|
||||
private def init: Unit = {
|
||||
pe.register(ModuleActorType.ActorType.modulemanager,self)
|
||||
val (ip, port) = ActorUtils.getIpAndPort(selfAddr)
|
||||
pe.setIpAndPort(ip, port)
|
||||
pe.setSysTag(sysTag)
|
||||
val confHeler = new ConfigerHelper(conf, sysTag, pe.getSysTag)
|
||||
confHeler.init()
|
||||
|
||||
}
|
||||
|
||||
private def loadCommonActor:Unit = {
|
||||
loadApiModule
|
||||
loadTransModule
|
||||
loadStorageModule
|
||||
loadClusterModule
|
||||
}
|
||||
|
||||
private def loadApiModule = {
|
||||
if (enableStatistic) RepTimeTracer.openTimeTrace else RepTimeTracer.closeTimeTrace
|
||||
if (enableWebSocket) {
|
||||
pe.register(ModuleActorType.ActorType.webapi,context.system.actorOf(Props[EventServer], "webapi"))
|
||||
}
|
||||
}
|
||||
|
||||
private def loadAutoTestStub:Any = {
|
||||
if (SystemProfile.getTransCreateType == Trans_Create_Type_Enum.AUTO ) {
|
||||
pe.register(ModuleActorType.ActorType.peerhelper,context.actorOf(PeerHelper.props("peerhelper"), "peerhelper"))
|
||||
}
|
||||
}
|
||||
|
||||
private def loadTransModule:Any={
|
||||
if (this.isStartup) {
|
||||
pe.register(ModuleActorType.ActorType.transactiondispatcher, context.actorOf(TransactionDispatcher.props("transactiondispatcher"), "transactiondispatcher"))
|
||||
}
|
||||
pe.register(ModuleActorType.ActorType.dispatchofpreload, context.actorOf(DispatchOfPreload.props("dispatchofpreload"), "dispatchofpreload"))
|
||||
pe.register(ModuleActorType.ActorType.transactionpool, context.actorOf(TransactionPool.props("transactionpool"), "transactionpool"))
|
||||
}
|
||||
|
||||
private def loadStorageModule:Any={
|
||||
pe.register(ModuleActorType.ActorType.storager,context.actorOf(Storager.props("storager"), "storager"))
|
||||
}
|
||||
|
||||
private def loadClusterModule = {
|
||||
context.actorOf(MemberListener.props("memberlistener"), "memberlistener")
|
||||
}
|
||||
|
||||
//启动共识模块,不同的共识方式启动的actor也不相同,继承模块需要重载此方法
|
||||
override def startupConsensus: Unit = ???
|
||||
|
||||
//装载共识模块,继承模块需要重载此方法
|
||||
override def loadConsensusModule: Unit = ???
|
||||
|
||||
|
||||
override def receive: Receive = {
|
||||
case IModuleManager.startup_Consensus =>
|
||||
RepLogger.trace(RepLogger.System_Logger, this.getLogMsgPrefix(s"recv startup command,systemname=${this.sysTag}"))
|
||||
loadAutoTestStub
|
||||
startupConsensus
|
||||
case _ => //ignore
|
||||
RepLogger.trace(RepLogger.System_Logger, this.getLogMsgPrefix(s"recv unknow command,it is not startup command,systemname=${this.sysTag}"))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class ConfigerHelper(conf: Config, tag: String, dbTag: String) {
|
||||
|
||||
def init(): Unit = {
|
||||
authInitByCfg(tag)
|
||||
dbInit(dbTag)
|
||||
timePolicyInit(conf)
|
||||
}
|
||||
|
||||
/**
|
||||
* Authorization module init
|
||||
*
|
||||
* @param jksFilePath
|
||||
* @param pwd
|
||||
* @param trustJksFilePath
|
||||
* @param trustPwd
|
||||
*/
|
||||
private def authInit(sysTag: String, jksFilePath: String, pwd: String, trustJksFilePath: String, trustPwd: String): Unit = {
|
||||
//init the ECDSA param
|
||||
SignTool.loadPrivateKey(sysTag, pwd, jksFilePath)
|
||||
SignTool.loadNodeCertList(trustPwd, trustJksFilePath)
|
||||
//ECDSASign.apply(sysTag, jksFilePath, pwd, trustJksFilePath, trustPwd)
|
||||
//ECDSASign.preLoadKey(sysTag)
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据配置初始化本地安全配置
|
||||
*/
|
||||
private def authInitByCfg(sysTag: String): Unit = {
|
||||
/*val mykeyPath = conf.getString("akka.remote.netty.ssl.security.base-path") + sysTag + ".jks"
|
||||
val psw = conf.getString("akka.remote.netty.ssl.security.key-store-password")
|
||||
val trustPath = conf.getString("akka.remote.netty.ssl.security.trust-store-mm")
|
||||
val trustPwd = conf.getString("akka.remote.netty.ssl.security.trust-store-password-mm")*/
|
||||
|
||||
val mykeyPath = conf.getString("akka.remote.artery.ssl.config-ssl-engine.base-path") + sysTag + ".jks"
|
||||
val psw = conf.getString("akka.remote.artery.ssl.config-ssl-engine.key-store-password")
|
||||
val trustPath = conf.getString("akka.remote.artery.ssl.config-ssl-engine.trust-store-mm")
|
||||
val trustPwd = conf.getString("akka.remote.artery.ssl.config-ssl-engine.trust-store-password-mm")
|
||||
authInit(sysTag, mykeyPath, psw, trustPath, trustPwd)
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化DB信息
|
||||
*
|
||||
* @param dbTag
|
||||
*/
|
||||
private def dbInit(dbTag: String): Unit = {
|
||||
ImpDataAccess.GetDataAccess(dbTag)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化系统相关配置
|
||||
*
|
||||
* @param config
|
||||
*/
|
||||
private def sysInit(config: Config): Unit = {
|
||||
SystemProfile.initConfigSystem(config)
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化时间策略配置
|
||||
*
|
||||
* @param config
|
||||
*/
|
||||
private def timePolicyInit(config: Config): Unit = {
|
||||
TimePolicy.initTimePolicy(config)
|
||||
}
|
||||
|
||||
}
|
23
src/main/scala/rep/network/module/ModuleActorType.scala
Normal file
23
src/main/scala/rep/network/module/ModuleActorType.scala
Normal file
@ -0,0 +1,23 @@
|
||||
package rep.network.module
|
||||
|
||||
object ModuleActorType {
|
||||
|
||||
//系统的actor类型的注册,关键字以10开头
|
||||
case object ActorType {
|
||||
//外部API服务actor
|
||||
val webapi = 101
|
||||
//自动(测试时采用)产生交易的actor
|
||||
val peerhelper = 102
|
||||
//分派交易预执行actor
|
||||
val dispatchofpreload = 103
|
||||
//出块时分派交易预执行actor
|
||||
val transactiondispatcher = 104
|
||||
//交易缓存池actor,接收广播交易
|
||||
val transactionpool = 105
|
||||
//区块存储actor,将确认的块持久化到磁盘
|
||||
val storager = 106
|
||||
//
|
||||
val modulemanager = 107
|
||||
}
|
||||
|
||||
}
|
@ -1,218 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Blockchain Technology and Application Joint Lab, Linkel Technology Co., Ltd, Beijing, Fintech Research Center of ISCAS.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BA SIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package rep.network.module
|
||||
|
||||
import akka.actor.{ ActorRef, Props }
|
||||
import com.typesafe.config.{ Config }
|
||||
import rep.app.conf.SystemProfile.Trans_Create_Type_Enum
|
||||
import rep.app.conf.{ SystemProfile, TimePolicy }
|
||||
import rep.network.PeerHelper
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.network.cache.TransactionPool
|
||||
import rep.network.persistence.Storager
|
||||
import rep.ui.web.EventServer
|
||||
import rep.network.cluster.MemberListener
|
||||
import rep.network.sync.{ SynchronizeResponser, SynchronizeRequester4Future }
|
||||
import rep.sc.TransactionDispatcher
|
||||
import rep.network.consensus.block.{ GenesisBlocker, ConfirmOfBlock, EndorseCollector, Blocker }
|
||||
import rep.network.consensus.endorse.{ Endorser4Future, DispatchOfRecvEndorsement }
|
||||
import rep.network.consensus.transaction.{ DispatchOfPreload, PreloaderForTransaction }
|
||||
import rep.network.consensus.vote.Voter
|
||||
|
||||
import rep.storage.ImpDataAccess
|
||||
import rep.utils.ActorUtils
|
||||
import rep.utils.GlobalUtils.ActorType
|
||||
import rep.crypto.cert.SignTool
|
||||
import rep.log.RepLogger
|
||||
import rep.storage.verify.verify4Storage
|
||||
import rep.log.RepTimeTracer
|
||||
|
||||
/**
|
||||
* Created by shidianyue on 2017/9/22.
|
||||
*/
|
||||
object ModuleManager {
|
||||
def props(name: String, sysTag: String, enableStatistic: Boolean, enableWebSocket: Boolean, isStartup: Boolean): Props = Props(classOf[ModuleManager], name, sysTag, enableStatistic: Boolean, enableWebSocket: Boolean, isStartup: Boolean)
|
||||
|
||||
case object startup_Consensus
|
||||
}
|
||||
|
||||
class ModuleManager(moduleName: String, sysTag: String, enableStatistic: Boolean, enableWebSocket: Boolean, isStartup: Boolean) extends ModuleBase(moduleName) {
|
||||
|
||||
private val conf = context.system.settings.config
|
||||
|
||||
init()
|
||||
|
||||
if (!checkSystemStorage) {
|
||||
context.system.terminate()
|
||||
}
|
||||
|
||||
loadModule
|
||||
|
||||
def checkSystemStorage: Boolean = {
|
||||
var r = true
|
||||
try {
|
||||
if (!verify4Storage.verify(sysTag)) {
|
||||
r = false
|
||||
}
|
||||
} catch {
|
||||
case e: Exception => {
|
||||
r = false
|
||||
//throw new Exception("Storager Verify Error,info:" + e.getMessage)
|
||||
}
|
||||
}
|
||||
r
|
||||
}
|
||||
|
||||
def init(): Unit = {
|
||||
val (ip, port) = ActorUtils.getIpAndPort(selfAddr)
|
||||
pe.setIpAndPort(ip, port)
|
||||
pe.setSysTag(sysTag)
|
||||
val confHeler = new ConfigerHelper(conf, sysTag, pe.getSysTag)
|
||||
confHeler.init()
|
||||
}
|
||||
|
||||
def loadModule = {
|
||||
loadApiModule
|
||||
loadSystemModule
|
||||
loadConsensusModule
|
||||
loadClusterModule
|
||||
|
||||
RepLogger.trace(RepLogger.Consensus_Logger, this.getLogMsgPrefix(s"ModuleManager ${sysTag} start"))
|
||||
}
|
||||
|
||||
def loadConsensusModule = {
|
||||
val typeConsensus = context.system.settings.config.getString("system.consensus.type")
|
||||
if (typeConsensus == "CRFD") {
|
||||
context.actorOf(Blocker.props("blocker"), "blocker")
|
||||
context.actorOf(GenesisBlocker.props("gensisblock"), "gensisblock")
|
||||
context.actorOf(ConfirmOfBlock.props("confirmerofblock"), "confirmerofblock")
|
||||
|
||||
context.actorOf(EndorseCollector.props("endorsementcollectioner"), "endorsementcollectioner")
|
||||
context.actorOf(DispatchOfRecvEndorsement.props("dispatchofRecvendorsement"), "dispatchofRecvendorsement")
|
||||
|
||||
if (this.isStartup) {
|
||||
context.actorOf(TransactionDispatcher.props("transactiondispatcher"), "transactiondispatcher")
|
||||
}
|
||||
context.actorOf(DispatchOfPreload.props("dispatchofpreload"), "dispatchofpreload")
|
||||
|
||||
context.actorOf(Voter.props("voter"), "voter")
|
||||
context.actorOf(TransactionPool.props("transactionpool"), "transactionpool")
|
||||
}
|
||||
}
|
||||
|
||||
def loadApiModule = {
|
||||
//if (enableStatistic) context.actorOf(Props[StatisticCollection], "statistic")
|
||||
if (enableStatistic) RepTimeTracer.openTimeTrace else RepTimeTracer.closeTimeTrace
|
||||
if (enableWebSocket) /*{if(pe.getActorRef(ActorType.webapi) == null) */ context.system.actorOf(Props[EventServer], "webapi")
|
||||
|
||||
}
|
||||
|
||||
def loadSystemModule = {
|
||||
context.actorOf(Storager.props("storager"), "storager")
|
||||
context.actorOf(SynchronizeRequester4Future.props("synchrequester"), "synchrequester")
|
||||
context.actorOf(SynchronizeResponser.props("synchresponser"), "synchresponser")
|
||||
}
|
||||
|
||||
def loadClusterModule = {
|
||||
context.actorOf(MemberListener.props("memberlistener"), "memberlistener")
|
||||
}
|
||||
|
||||
//除了广播消息,P2P的跨域消息都通过其中转(同步,存储等)
|
||||
override def receive: Receive = {
|
||||
case ModuleManager.startup_Consensus =>
|
||||
RepLogger.trace(RepLogger.System_Logger, this.getLogMsgPrefix(s"trans create type ${SystemProfile.getTransCreateType},actor=${pe.getActorRef(ActorType.peerhelper)}"))
|
||||
if (SystemProfile.getTransCreateType == Trans_Create_Type_Enum.AUTO && pe.getActorRef(ActorType.peerhelper) == null) {
|
||||
context.actorOf(PeerHelper.props("peerhelper"), "peerhelper")
|
||||
}
|
||||
if (pe.getActorRef(ActorType.voter) == null) {
|
||||
context.actorOf(Voter.props("voter"), "voter")
|
||||
}
|
||||
pe.getActorRef(ActorType.voter) ! Voter.VoteOfBlocker
|
||||
case _ => //ignore
|
||||
}
|
||||
}
|
||||
|
||||
class ConfigerHelper(conf: Config, tag: String, dbTag: String) {
|
||||
|
||||
def init(): Unit = {
|
||||
authInitByCfg(tag)
|
||||
dbInit(dbTag)
|
||||
//sysInit(conf)
|
||||
timePolicyInit(conf)
|
||||
}
|
||||
|
||||
/**
|
||||
* Authorization module init
|
||||
*
|
||||
* @param jksFilePath
|
||||
* @param pwd
|
||||
* @param trustJksFilePath
|
||||
* @param trustPwd
|
||||
*/
|
||||
private def authInit(sysTag: String, jksFilePath: String, pwd: String, trustJksFilePath: String, trustPwd: String): Unit = {
|
||||
//init the ECDSA param
|
||||
SignTool.loadPrivateKey(sysTag, pwd, jksFilePath)
|
||||
SignTool.loadNodeCertList(trustPwd, trustJksFilePath)
|
||||
//ECDSASign.apply(sysTag, jksFilePath, pwd, trustJksFilePath, trustPwd)
|
||||
//ECDSASign.preLoadKey(sysTag)
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据配置初始化本地安全配置
|
||||
*/
|
||||
private def authInitByCfg(sysTag: String): Unit = {
|
||||
/*val mykeyPath = conf.getString("akka.remote.netty.ssl.security.base-path") + sysTag + ".jks"
|
||||
val psw = conf.getString("akka.remote.netty.ssl.security.key-store-password")
|
||||
val trustPath = conf.getString("akka.remote.netty.ssl.security.trust-store-mm")
|
||||
val trustPwd = conf.getString("akka.remote.netty.ssl.security.trust-store-password-mm")*/
|
||||
|
||||
val mykeyPath = conf.getString("akka.remote.artery.ssl.config-ssl-engine.base-path") + sysTag + ".jks"
|
||||
val psw = conf.getString("akka.remote.artery.ssl.config-ssl-engine.key-store-password")
|
||||
val trustPath = conf.getString("akka.remote.artery.ssl.config-ssl-engine.trust-store-mm")
|
||||
val trustPwd = conf.getString("akka.remote.artery.ssl.config-ssl-engine.trust-store-password-mm")
|
||||
authInit(sysTag, mykeyPath, psw, trustPath, trustPwd)
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化DB信息
|
||||
*
|
||||
* @param dbTag
|
||||
*/
|
||||
private def dbInit(dbTag: String): Unit = {
|
||||
ImpDataAccess.GetDataAccess(dbTag)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化系统相关配置
|
||||
*
|
||||
* @param config
|
||||
*/
|
||||
private def sysInit(config: Config): Unit = {
|
||||
SystemProfile.initConfigSystem(config)
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化时间策略配置
|
||||
*
|
||||
* @param config
|
||||
*/
|
||||
private def timePolicyInit(config: Config): Unit = {
|
||||
TimePolicy.initTimePolicy(config)
|
||||
}
|
||||
|
||||
}
|
17
src/main/scala/rep/network/module/cfrd/CFRDActorType.scala
Normal file
17
src/main/scala/rep/network/module/cfrd/CFRDActorType.scala
Normal file
@ -0,0 +1,17 @@
|
||||
package rep.network.module.cfrd
|
||||
|
||||
object CFRDActorType {
|
||||
//cfrd共识模式的actor类型的注册,关键字以20开头
|
||||
case object ActorType{
|
||||
val blocker = 201
|
||||
val voter = 202
|
||||
val endorsementcollectioner = 203
|
||||
|
||||
val confirmerofblock = 204
|
||||
val dispatchofRecvendorsement = 205
|
||||
val gensisblock = 206
|
||||
|
||||
val synchrequester = 207
|
||||
val synchresponser = 208
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package rep.network.module.cfrd
|
||||
|
||||
import akka.actor.{ Props}
|
||||
import rep.network.consensus.cfrd.block.{Blocker, ConfirmOfBlock, EndorseCollector, GenesisBlocker}
|
||||
import rep.network.consensus.cfrd.endorse.DispatchOfRecvEndorsement
|
||||
import rep.network.consensus.cfrd.vote.Voter
|
||||
import rep.network.module.{IModuleManager, ModuleActorType}
|
||||
import rep.network.sync.{SynchronizeRequester4Future, SynchronizeResponser}
|
||||
|
||||
object ModuleManagerOfCFRD{
|
||||
def props(name: String, sysTag: String, enableStatistic: Boolean, enableWebSocket: Boolean, isStartup: Boolean): Props = Props(classOf[ModuleManagerOfCFRD], name, sysTag, enableStatistic: Boolean, enableWebSocket: Boolean, isStartup: Boolean)
|
||||
|
||||
}
|
||||
|
||||
class ModuleManagerOfCFRD(moduleName: String, sysTag: String, enableStatistic: Boolean, enableWebSocket: Boolean, isStartup: Boolean) extends IModuleManager(moduleName,sysTag, enableStatistic, enableWebSocket, isStartup){
|
||||
|
||||
//启动共识模块,启动CFRD共识
|
||||
override def startupConsensus: Unit = {
|
||||
pe.getActorRef(CFRDActorType.ActorType.voter) ! Voter.VoteOfBlocker
|
||||
}
|
||||
|
||||
override def loadConsensusModule = {
|
||||
pe.register(CFRDActorType.ActorType.blocker,context.actorOf(Blocker.props("blocker"), "blocker"))
|
||||
pe.register(CFRDActorType.ActorType.endorsementcollectioner,context.actorOf(EndorseCollector.props("endorsementcollectioner"), "endorsementcollectioner"))
|
||||
pe.register(CFRDActorType.ActorType.dispatchofRecvendorsement,context.actorOf(DispatchOfRecvEndorsement.props("dispatchofRecvendorsement"), "dispatchofRecvendorsement"))
|
||||
pe.register(CFRDActorType.ActorType.voter,context.actorOf(Voter.props("voter"), "voter"))
|
||||
pe.register(CFRDActorType.ActorType.gensisblock,context.actorOf(GenesisBlocker.props("gensisblock"), "gensisblock"))
|
||||
pe.register(CFRDActorType.ActorType.confirmerofblock,context.actorOf(ConfirmOfBlock.props("confirmerofblock"), "confirmerofblock"))
|
||||
|
||||
pe.register(CFRDActorType.ActorType.synchrequester,context.actorOf(SynchronizeRequester4Future.props("synchrequester"), "synchrequester"))
|
||||
pe.register(CFRDActorType.ActorType.synchresponser,context.actorOf(SynchronizeResponser.props("synchresponser"), "synchresponser"))
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -17,24 +17,27 @@
|
||||
package rep.network.persistence
|
||||
|
||||
|
||||
import akka.actor.{ ActorRef, Props }
|
||||
import akka.actor.{ActorRef, Props}
|
||||
import akka.cluster.pubsub.DistributedPubSubMediator.Publish
|
||||
import com.google.protobuf.ByteString
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.network.Topic
|
||||
import rep.protos.peer._
|
||||
import rep.storage.ImpDataAccess
|
||||
import rep.network.consensus.vote.Voter.{VoteOfBlocker}
|
||||
import rep.network.consensus.cfrd.vote.Voter.VoteOfBlocker
|
||||
|
||||
import scala.collection.mutable
|
||||
import rep.utils.GlobalUtils.{ ActorType, BlockEvent, EventType, NodeStatus }
|
||||
import rep.utils.GlobalUtils.{ BlockEvent, EventType, NodeStatus}
|
||||
|
||||
import scala.collection.immutable
|
||||
import rep.network.sync.SyncMsg.{SyncRequestOfStorager,StartSync}
|
||||
import rep.network.sync.SyncMsg.{StartSync, SyncRequestOfStorager}
|
||||
import rep.network.module.cfrd.CFRDActorType
|
||||
import scala.util.control.Breaks._
|
||||
import rep.network.util.NodeHelp
|
||||
import rep.network.sync.SyncMsg.{BlockDataOfRequest,BlockDataOfResponse}
|
||||
import rep.network.sync.SyncMsg.{BlockDataOfRequest, BlockDataOfResponse}
|
||||
import rep.log.RepLogger
|
||||
import rep.log.RepTimeTracer
|
||||
import rep.app.conf.{ SystemCertList}
|
||||
import rep.app.conf.SystemCertList
|
||||
import rep.network.autotransaction.Topic
|
||||
|
||||
|
||||
object Storager {
|
||||
@ -113,7 +116,7 @@ class Storager(moduleName: String) extends ModuleBase(moduleName) {
|
||||
if (pe.getBlockCacheMgr.isEmpty ) {
|
||||
RepLogger.trace(RepLogger.Storager_Logger, this.getLogMsgPrefix("presistence is over,this is startup vote" + "~" + selfAddr))
|
||||
//通知抽签模块,开始抽签
|
||||
pe.getActorRef( ActorType.voter) ! VoteOfBlocker
|
||||
pe.getActorRef( CFRDActorType.ActorType.voter) ! VoteOfBlocker
|
||||
}else{
|
||||
RepLogger.trace(RepLogger.Storager_Logger, this.getLogMsgPrefix( s"presistence is over,cache has data,do not vote,height=${pe.getCurrentHeight} ~" + selfAddr))
|
||||
}
|
||||
@ -126,7 +129,7 @@ class Storager(moduleName: String) extends ModuleBase(moduleName) {
|
||||
RepLogger.trace(RepLogger.Storager_Logger, this.getLogMsgPrefix( s"presistence is failed,must start sync,start send sync request ,height=${pe.getCurrentHeight} ~" + selfAddr))
|
||||
val hs = pe.getBlockCacheMgr.getKeyArray4Sort
|
||||
val max = hs(hs.length-1)
|
||||
pe.getActorRef(ActorType.synchrequester) ! SyncRequestOfStorager(blker,max)
|
||||
pe.getActorRef(CFRDActorType.ActorType.synchrequester) ! SyncRequestOfStorager(blker,max)
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,7 +188,7 @@ class Storager(moduleName: String) extends ModuleBase(moduleName) {
|
||||
}
|
||||
} else {
|
||||
pe.getBlockCacheMgr.removeFromCache(blkRestore.blk.height)
|
||||
pe.getActorRef(ActorType.synchrequester) ! StartSync(false)
|
||||
pe.getActorRef(CFRDActorType.ActorType.synchrequester) ! StartSync(false)
|
||||
RepLogger.trace(RepLogger.Storager_Logger, this.getLogMsgPrefix(s"block restor is failed in persistence module,block prehash error,must restart height:${blkRestore.blk.height}" + "~" + selfAddr))
|
||||
}
|
||||
} else if (blkRestore.blk.height < (pe.getCurrentHeight + 1)) {
|
||||
|
@ -26,17 +26,18 @@ import akka.actor.{ ActorRef, Props, Address, ActorSelection }
|
||||
import akka.cluster.pubsub.DistributedPubSubMediator.Publish
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.app.conf.TimePolicy
|
||||
import rep.network.module.ModuleManager
|
||||
import rep.network.module.IModuleManager
|
||||
import rep.storage.ImpDataAccess
|
||||
import rep.protos.peer._
|
||||
import rep.network.persistence.Storager.{ BlockRestore, SourceOfBlock }
|
||||
import scala.collection._
|
||||
import rep.utils.GlobalUtils.{ ActorType, BlockEvent, EventType, NodeStatus }
|
||||
import rep.utils.GlobalUtils.{ BlockEvent, EventType, NodeStatus }
|
||||
import rep.app.conf.SystemProfile
|
||||
import rep.network.util.NodeHelp
|
||||
import rep.network.sync.SyncMsg.{ ResponseInfo, StartSync, BlockDataOfRequest, BlockDataOfResponse, SyncRequestOfStorager, ChainInfoOfRequest }
|
||||
import scala.util.control.Breaks._
|
||||
import rep.log.RepLogger
|
||||
import rep.network.module.ModuleActorType
|
||||
import scala.collection.mutable.HashMap
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
|
||||
@ -117,7 +118,7 @@ class SynchronizeRequester4Future(moduleName: String) extends ModuleBase(moduleN
|
||||
//logMsg(LogType.INFO, "--------AsyncGetNodeOfChainInfo success")
|
||||
var result = Await.result(future1, timeout.duration).asInstanceOf[BlockDataOfResponse]
|
||||
RepLogger.trace(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix(s"height=${height}--------getBlockData success"))
|
||||
pe.getActorRef(ActorType.storager) ! BlockRestore(result.data, SourceOfBlock.SYNC_BLOCK, ref)
|
||||
pe.getActorRef(ModuleActorType.ActorType.storager) ! BlockRestore(result.data, SourceOfBlock.SYNC_BLOCK, ref)
|
||||
true
|
||||
} catch {
|
||||
case e: AskTimeoutException =>
|
||||
@ -242,7 +243,7 @@ class SynchronizeRequester4Future(moduleName: String) extends ModuleBase(moduleN
|
||||
pe.setSynching(false)
|
||||
if (rb) {
|
||||
if (isNoticeModuleMgr)
|
||||
pe.getActorRef(ActorType.modulemanager) ! ModuleManager.startup_Consensus
|
||||
pe.getActorRef(ModuleActorType.ActorType.modulemanager) ! IModuleManager.startup_Consensus
|
||||
} else {
|
||||
schedulerLink = scheduler.scheduleOnce(1.second, self, StartSync(isNoticeModuleMgr))
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ package rep.network.sync
|
||||
import akka.actor.{ ActorRef, Props }
|
||||
import akka.cluster.pubsub.DistributedPubSubMediator.Publish
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.utils.GlobalUtils.{ ActorType, BlockEvent, EventType }
|
||||
import rep.utils.GlobalUtils.{ BlockEvent, EventType }
|
||||
import rep.storage.ImpDataAccess
|
||||
import rep.protos.peer._
|
||||
import rep.network.util.NodeHelp
|
||||
|
@ -14,27 +14,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package rep.network.consensus.transaction
|
||||
package rep.network.transaction
|
||||
|
||||
import akka.actor.{ Actor, ActorRef, Props, Address, ActorSelection }
|
||||
import akka.cluster.pubsub.DistributedPubSubMediator.Publish
|
||||
import akka.routing._;
|
||||
import rep.app.conf.{ SystemProfile, TimePolicy }
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.network.tools.PeerExtension
|
||||
import rep.network.Topic
|
||||
import rep.protos.peer._
|
||||
import rep.utils.GlobalUtils.{ EventType }
|
||||
import rep.utils._
|
||||
import scala.collection.mutable._
|
||||
import rep.network.consensus.util.BlockVerify
|
||||
import scala.util.control.Breaks
|
||||
import rep.network.util.NodeHelp
|
||||
import rep.network.consensus.util.BlockHelp
|
||||
import rep.network.consensus.util.BlockVerify
|
||||
import akka.actor.Props
|
||||
import akka.routing._
|
||||
import rep.app.conf.SystemProfile
|
||||
import rep.log.RepLogger
|
||||
import rep.log.RepTimeTracer
|
||||
import rep.network.consensus.block.Blocker.{ PreTransBlock}
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.network.consensus.cfrd.block.Blocker.PreTransBlock
|
||||
|
||||
|
||||
object DispatchOfPreload {
|
||||
@ -43,8 +30,6 @@ object DispatchOfPreload {
|
||||
|
||||
|
||||
class DispatchOfPreload(moduleName: String) extends ModuleBase(moduleName) {
|
||||
import context.dispatcher
|
||||
import scala.concurrent.duration._
|
||||
import scala.collection.immutable._
|
||||
|
||||
private var router: Router = null
|
@ -14,42 +14,35 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package rep.network.consensus.transaction
|
||||
package rep.network.transaction
|
||||
|
||||
import akka.actor.Props
|
||||
import akka.pattern.{AskTimeoutException, ask}
|
||||
import akka.util.Timeout
|
||||
import scala.concurrent.duration._
|
||||
import akka.pattern.ask
|
||||
import akka.pattern.AskTimeoutException
|
||||
import scala.concurrent._
|
||||
|
||||
import akka.actor.{ Actor, ActorRef, Props }
|
||||
import com.google.protobuf.ByteString
|
||||
import com.google.protobuf.timestamp.Timestamp
|
||||
import rep.app.conf.{ SystemProfile, TimePolicy }
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.network.consensus.block.Blocker.{ PreTransBlock, PreTransBlockResult}
|
||||
import rep.network.tools.PeerExtension
|
||||
import rep.network.Topic
|
||||
import rep.protos.peer._
|
||||
import rep.sc.SandboxDispatcher.DoTransaction
|
||||
import rep.sc.Sandbox.DoTransactionResult
|
||||
import rep.storage.{ ImpDataPreloadMgr }
|
||||
import rep.utils.GlobalUtils.ActorType
|
||||
import rep.utils._
|
||||
import scala.collection.mutable
|
||||
import akka.pattern.AskTimeoutException
|
||||
import rep.app.conf.TimePolicy
|
||||
import rep.crypto.Sha256
|
||||
import rep.log.RepLogger
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.network.consensus.cfrd.block.Blocker.{PreTransBlock, PreTransBlockResult}
|
||||
import rep.protos.peer._
|
||||
import rep.sc.Sandbox.DoTransactionResult
|
||||
import rep.sc.SandboxDispatcher.DoTransaction
|
||||
import rep.sc.TypeOfSender
|
||||
import rep.storage.ImpDataPreloadMgr
|
||||
import rep.network.module.ModuleActorType
|
||||
import rep.utils._
|
||||
|
||||
import scala.collection.mutable
|
||||
import scala.concurrent._
|
||||
|
||||
object PreloaderForTransaction {
|
||||
def props(name: String): Props = Props(classOf[PreloaderForTransaction], name)
|
||||
}
|
||||
|
||||
class PreloaderForTransaction(moduleName: String) extends ModuleBase(moduleName) {
|
||||
import context.dispatcher
|
||||
import scala.concurrent.duration._
|
||||
import scala.collection.breakOut
|
||||
import scala.concurrent.duration._
|
||||
|
||||
implicit val timeout = Timeout(TimePolicy.getTimeoutPreload*10.seconds)
|
||||
|
||||
@ -59,7 +52,7 @@ class PreloaderForTransaction(moduleName: String) extends ModuleBase(moduleName)
|
||||
|
||||
private def ExecuteTransaction(t: Transaction, db_identifier: String): (Int, DoTransactionResult) = {
|
||||
try {
|
||||
val future1 = pe.getActorRef(ActorType.transactiondispatcher) ? new DoTransaction(t, db_identifier,TypeOfSender.FromPreloader)
|
||||
val future1 = pe.getActorRef(ModuleActorType.ActorType.transactiondispatcher) ? new DoTransaction(t, db_identifier,TypeOfSender.FromPreloader)
|
||||
//val future1 = pe.getActorRef(ActorType.preloadtransrouter) ? new DoTransaction(t, db_identifier)
|
||||
val result = Await.result(future1, timeout.duration).asInstanceOf[DoTransactionResult]
|
||||
(0, result)
|
@ -1,30 +1,32 @@
|
||||
package rep.sc
|
||||
|
||||
import akka.util.Timeout
|
||||
|
||||
import scala.concurrent.duration._
|
||||
import akka.pattern.ask
|
||||
import akka.pattern.AskTimeoutException
|
||||
import scala.concurrent._
|
||||
|
||||
import akka.actor.{ Actor, ActorRef, Props }
|
||||
import scala.concurrent._
|
||||
import akka.actor.{Actor, ActorRef, Props}
|
||||
import com.google.protobuf.ByteString
|
||||
import com.google.protobuf.timestamp.Timestamp
|
||||
import rep.app.conf.{ SystemProfile, TimePolicy }
|
||||
import rep.app.conf.{SystemProfile, TimePolicy}
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.network.consensus.block.Blocker.{ PreTransBlock, PreTransBlockResult }
|
||||
import rep.network.consensus.cfrd.block.Blocker.{PreTransBlock, PreTransBlockResult}
|
||||
import rep.network.tools.PeerExtension
|
||||
import rep.network.Topic
|
||||
import rep.protos.peer._
|
||||
import rep.sc.Sandbox.DoTransactionResult
|
||||
import rep.sc.SandboxDispatcher.DoTransaction
|
||||
import rep.storage.{ ImpDataPreloadMgr }
|
||||
import rep.utils.GlobalUtils.ActorType
|
||||
import rep.storage.ImpDataPreloadMgr
|
||||
|
||||
import rep.utils._
|
||||
|
||||
import scala.collection.mutable
|
||||
import akka.pattern.AskTimeoutException
|
||||
import rep.crypto.Sha256
|
||||
import rep.log.RepLogger
|
||||
import akka.routing._;
|
||||
import akka.routing._
|
||||
import rep.network.autotransaction.Topic;
|
||||
|
||||
object TransactionDispatcher {
|
||||
def props(name: String): Props = Props(classOf[TransactionDispatcher], name)
|
||||
|
@ -1,149 +1,149 @@
|
||||
/*
|
||||
* Copyright 2019 Blockchain Technology and Application Joint Lab, Linkel Technology Co., Ltd, Beijing, Fintech Research Center of ISCAS.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BA SIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package rep.utils
|
||||
|
||||
import java.io.{File, PrintWriter}
|
||||
|
||||
import rep.network.PeerHelper
|
||||
import com.typesafe.config.ConfigFactory
|
||||
import com.google.protobuf.ByteString
|
||||
import com.google.protobuf.timestamp.Timestamp
|
||||
import rep.protos.peer._
|
||||
import scalapb.json4s.JsonFormat
|
||||
import rep.crypto.Sha256
|
||||
import org.json4s.{DefaultFormats, Formats, jackson}
|
||||
import org.json4s.jackson.JsonMethods._
|
||||
import org.json4s.DefaultFormats._
|
||||
import rep.network.consensus.util.BlockHelp
|
||||
import rep.crypto.cert.SignTool
|
||||
|
||||
import scala.collection.mutable
|
||||
import rep.sc.tpl._
|
||||
import rep.sc.tpl.ContractCert
|
||||
|
||||
/**
|
||||
* 用于生成创世块json文件,该json文件可以在链初始化时由节点加载
|
||||
* 创世块中预置了deploy基础方法的交易
|
||||
*@author shidianyue
|
||||
*/
|
||||
object GenesisBuilder {
|
||||
|
||||
implicit val serialization = jackson.Serialization // or native.Serialization
|
||||
implicit val formats = DefaultFormats
|
||||
|
||||
def main(args: Array[String]): Unit = {
|
||||
SignTool.loadPrivateKey("121000005l35120456.node1", "123", "jks/121000005l35120456.node1.jks")
|
||||
SignTool.loadNodeCertList("changeme", "jks/mytruststore.jks")
|
||||
SignTool.loadPrivateKey("951002007l78123233.super_admin", "super_admin", "jks/951002007l78123233.super_admin.jks")
|
||||
val sysName = "121000005l35120456.node1"
|
||||
//交易发起人是超级管理员
|
||||
//增加scala的资产管理合约
|
||||
// read deploy funcs
|
||||
val s1 = scala.io.Source.fromFile("src/main/scala/rep/sc/tpl/ContractCert.scala","UTF-8")
|
||||
val l1 = try s1.mkString finally s1.close()
|
||||
|
||||
val cid = new ChaincodeId("ContractCert",1)
|
||||
|
||||
var translist : Array[Transaction] = new Array[Transaction] (15)
|
||||
|
||||
|
||||
//val dep_trans = PeerHelper.createTransaction4Deploy(sysName, cid,
|
||||
// l1, "",5000, rep.protos.peer.ChaincodeDeploy.CodeType.CODE_SCALA)
|
||||
val dep_trans = PeerHelper.createTransaction4Deploy("951002007l78123233.super_admin", cid,
|
||||
l1, "",5000, rep.protos.peer.ChaincodeDeploy.CodeType.CODE_SCALA)
|
||||
translist(0) = dep_trans
|
||||
|
||||
//val dep_trans_state = PeerHelper.createTransaction4State(sysName, cid, true)
|
||||
//translist(1) = dep_trans_state
|
||||
|
||||
//System.out.println(Json4s.compactJson(dep_trans))
|
||||
|
||||
var signers : Array[Signer] = new Array[Signer](6)
|
||||
signers(0) = Signer("node1","121000005l35120456","18912345678",List("node1"))
|
||||
signers(1) = Signer("node2","12110107bi45jh675g","18912345678",List("node2"))
|
||||
signers(2) = Signer("node3","122000002n00123567","18912345678",List("node3"))
|
||||
signers(3) = Signer("node4","921000005k36123789","18912345678",List("node4"))
|
||||
signers(4) = Signer("node5","921000006e0012v696","18912345678",List("node5"))
|
||||
signers(5) = Signer("super_admin","951002007l78123233","18912345678",List("super_admin"))
|
||||
|
||||
|
||||
|
||||
for(i<-0 to 5){
|
||||
translist(i+1) = PeerHelper.createTransaction4Invoke("951002007l78123233.super_admin", cid,
|
||||
"SignUpSigner", Seq(SerializeUtils.compactJson(signers(i))))
|
||||
}
|
||||
|
||||
|
||||
for(i<-0 to 5){
|
||||
val certfile = scala.io.Source.fromFile("jks/"+signers(i).creditCode+"."+signers(i).name+".cer","UTF-8")
|
||||
val certstr = try certfile.mkString finally certfile.close()
|
||||
// val cert = SignTool.getCertByFile("jks/"+signers(i).creditCode+"."+signers(i).name+".cer")
|
||||
val millis = System.currentTimeMillis()
|
||||
|
||||
val tmp = rep.protos.peer.Certificate(certstr,"SHA1withECDSA",true,Option(Timestamp(millis/1000 , ((millis % 1000) * 1000000).toInt)))
|
||||
//val aa = new ContractCert
|
||||
val a : CertInfo = CertInfo(signers(i).creditCode,signers(i).name,tmp)
|
||||
translist(i+7) = PeerHelper.createTransaction4Invoke("951002007l78123233.super_admin", cid,
|
||||
"SignUpCert", Seq(SerializeUtils.compactJson(a)))
|
||||
}
|
||||
|
||||
|
||||
val s2 = scala.io.Source.fromFile("src/main/scala/rep/sc/tpl/ContractAssetsTPL.scala","UTF-8")
|
||||
val c2 = try s2.mkString finally s2.close()
|
||||
val cid2 = new ChaincodeId("ContractAssetsTPL",1)
|
||||
val dep_asserts_trans = PeerHelper.createTransaction4Deploy(sysName, cid2,
|
||||
c2, "",5000, rep.protos.peer.ChaincodeDeploy.CodeType.CODE_SCALA)
|
||||
translist(13) = dep_asserts_trans
|
||||
|
||||
// read invoke scala contract
|
||||
val s3 = scala.io.Source.fromFile("api_req/json/set.json","UTF-8")
|
||||
val ct1 = try s3.mkString finally s3.close()
|
||||
|
||||
translist(14) = PeerHelper.createTransaction4Invoke("951002007l78123233.super_admin", cid2,
|
||||
"set", Seq(ct1))
|
||||
|
||||
|
||||
|
||||
//create gensis block
|
||||
val millis = ConfigFactory.load().getLong("akka.genesisblock.creationBlockTime")
|
||||
|
||||
var blk = new Block(1,1,translist,Seq(),_root_.com.google.protobuf.ByteString.EMPTY,
|
||||
_root_.com.google.protobuf.ByteString.EMPTY)
|
||||
|
||||
//获得管理员证书和签名
|
||||
// val (priKA, pubKA, certA) = ECDSASign.getKeyPair("super_admin")
|
||||
// val (prik, pubK, cert) = ECDSASign.getKeyPair("1")
|
||||
//val blk_hash = blk.toByteArray
|
||||
//签名之前不再使用hash
|
||||
//val blk_hash = Sha256.hash(blk.toByteArray)
|
||||
//超级管理员背书(角色)
|
||||
//创建者背书(1)
|
||||
/*blk = blk.withEndorsements(Seq(
|
||||
BlockHelp.SignDataOfBlock(blk_hash,"951002007l78123233.super_admin"),
|
||||
BlockHelp.SignDataOfBlock(blk_hash,"121000005l35120456.node1")))*/
|
||||
blk = blk.clearEndorsements
|
||||
blk = blk.clearTransactionResults
|
||||
val r = JsonFormat.toJson(blk)
|
||||
val rstr = pretty(render(r))
|
||||
println(rstr)
|
||||
|
||||
val pw = new PrintWriter("json/gensis.json","UTF-8")
|
||||
pw.write(rstr)
|
||||
pw.flush()
|
||||
pw.close()
|
||||
}
|
||||
/*
|
||||
* Copyright 2019 Blockchain Technology and Application Joint Lab, Linkel Technology Co., Ltd, Beijing, Fintech Research Center of ISCAS.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BA SIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package rep.utils
|
||||
|
||||
import java.io.{File, PrintWriter}
|
||||
|
||||
import com.typesafe.config.ConfigFactory
|
||||
import com.google.protobuf.ByteString
|
||||
import com.google.protobuf.timestamp.Timestamp
|
||||
import rep.protos.peer._
|
||||
import scalapb.json4s.JsonFormat
|
||||
import rep.crypto.Sha256
|
||||
import org.json4s.{DefaultFormats, Formats, jackson}
|
||||
import org.json4s.jackson.JsonMethods._
|
||||
import org.json4s.DefaultFormats._
|
||||
import rep.network.consensus.util.BlockHelp
|
||||
import rep.crypto.cert.SignTool
|
||||
import rep.network.autotransaction.PeerHelper
|
||||
|
||||
import scala.collection.mutable
|
||||
import rep.sc.tpl._
|
||||
import rep.sc.tpl.ContractCert
|
||||
|
||||
/**
|
||||
* 用于生成创世块json文件,该json文件可以在链初始化时由节点加载
|
||||
* 创世块中预置了deploy基础方法的交易
|
||||
*@author shidianyue
|
||||
*/
|
||||
object GenesisBuilder {
|
||||
|
||||
implicit val serialization = jackson.Serialization // or native.Serialization
|
||||
implicit val formats = DefaultFormats
|
||||
|
||||
def main(args: Array[String]): Unit = {
|
||||
SignTool.loadPrivateKey("121000005l35120456.node1", "123", "jks/121000005l35120456.node1.jks")
|
||||
SignTool.loadNodeCertList("changeme", "jks/mytruststore.jks")
|
||||
SignTool.loadPrivateKey("951002007l78123233.super_admin", "super_admin", "jks/951002007l78123233.super_admin.jks")
|
||||
val sysName = "121000005l35120456.node1"
|
||||
//交易发起人是超级管理员
|
||||
//增加scala的资产管理合约
|
||||
// read deploy funcs
|
||||
val s1 = scala.io.Source.fromFile("src/main/scala/rep/sc/tpl/ContractCert.scala","UTF-8")
|
||||
val l1 = try s1.mkString finally s1.close()
|
||||
|
||||
val cid = new ChaincodeId("ContractCert",1)
|
||||
|
||||
var translist : Array[Transaction] = new Array[Transaction] (15)
|
||||
|
||||
|
||||
//val dep_trans = PeerHelper.createTransaction4Deploy(sysName, cid,
|
||||
// l1, "",5000, rep.protos.peer.ChaincodeDeploy.CodeType.CODE_SCALA)
|
||||
val dep_trans = PeerHelper.createTransaction4Deploy("951002007l78123233.super_admin", cid,
|
||||
l1, "",5000, rep.protos.peer.ChaincodeDeploy.CodeType.CODE_SCALA)
|
||||
translist(0) = dep_trans
|
||||
|
||||
//val dep_trans_state = PeerHelper.createTransaction4State(sysName, cid, true)
|
||||
//translist(1) = dep_trans_state
|
||||
|
||||
//System.out.println(Json4s.compactJson(dep_trans))
|
||||
|
||||
var signers : Array[Signer] = new Array[Signer](6)
|
||||
signers(0) = Signer("node1","121000005l35120456","18912345678",List("node1"))
|
||||
signers(1) = Signer("node2","12110107bi45jh675g","18912345678",List("node2"))
|
||||
signers(2) = Signer("node3","122000002n00123567","18912345678",List("node3"))
|
||||
signers(3) = Signer("node4","921000005k36123789","18912345678",List("node4"))
|
||||
signers(4) = Signer("node5","921000006e0012v696","18912345678",List("node5"))
|
||||
signers(5) = Signer("super_admin","951002007l78123233","18912345678",List("super_admin"))
|
||||
|
||||
|
||||
|
||||
for(i<-0 to 5){
|
||||
translist(i+1) = PeerHelper.createTransaction4Invoke("951002007l78123233.super_admin", cid,
|
||||
"SignUpSigner", Seq(SerializeUtils.compactJson(signers(i))))
|
||||
}
|
||||
|
||||
|
||||
for(i<-0 to 5){
|
||||
val certfile = scala.io.Source.fromFile("jks/"+signers(i).creditCode+"."+signers(i).name+".cer","UTF-8")
|
||||
val certstr = try certfile.mkString finally certfile.close()
|
||||
// val cert = SignTool.getCertByFile("jks/"+signers(i).creditCode+"."+signers(i).name+".cer")
|
||||
val millis = System.currentTimeMillis()
|
||||
|
||||
val tmp = rep.protos.peer.Certificate(certstr,"SHA1withECDSA",true,Option(Timestamp(millis/1000 , ((millis % 1000) * 1000000).toInt)))
|
||||
//val aa = new ContractCert
|
||||
val a : CertInfo = CertInfo(signers(i).creditCode,signers(i).name,tmp)
|
||||
translist(i+7) = PeerHelper.createTransaction4Invoke("951002007l78123233.super_admin", cid,
|
||||
"SignUpCert", Seq(SerializeUtils.compactJson(a)))
|
||||
}
|
||||
|
||||
|
||||
val s2 = scala.io.Source.fromFile("src/main/scala/rep/sc/tpl/ContractAssetsTPL.scala","UTF-8")
|
||||
val c2 = try s2.mkString finally s2.close()
|
||||
val cid2 = new ChaincodeId("ContractAssetsTPL",1)
|
||||
val dep_asserts_trans = PeerHelper.createTransaction4Deploy(sysName, cid2,
|
||||
c2, "",5000, rep.protos.peer.ChaincodeDeploy.CodeType.CODE_SCALA)
|
||||
translist(13) = dep_asserts_trans
|
||||
|
||||
// read invoke scala contract
|
||||
val s3 = scala.io.Source.fromFile("api_req/json/set.json","UTF-8")
|
||||
val ct1 = try s3.mkString finally s3.close()
|
||||
|
||||
translist(14) = PeerHelper.createTransaction4Invoke("951002007l78123233.super_admin", cid2,
|
||||
"set", Seq(ct1))
|
||||
|
||||
|
||||
|
||||
//create gensis block
|
||||
val millis = ConfigFactory.load().getLong("akka.genesisblock.creationBlockTime")
|
||||
|
||||
var blk = new Block(1,1,translist,Seq(),_root_.com.google.protobuf.ByteString.EMPTY,
|
||||
_root_.com.google.protobuf.ByteString.EMPTY)
|
||||
|
||||
//获得管理员证书和签名
|
||||
// val (priKA, pubKA, certA) = ECDSASign.getKeyPair("super_admin")
|
||||
// val (prik, pubK, cert) = ECDSASign.getKeyPair("1")
|
||||
//val blk_hash = blk.toByteArray
|
||||
//签名之前不再使用hash
|
||||
//val blk_hash = Sha256.hash(blk.toByteArray)
|
||||
//超级管理员背书(角色)
|
||||
//创建者背书(1)
|
||||
/*blk = blk.withEndorsements(Seq(
|
||||
BlockHelp.SignDataOfBlock(blk_hash,"951002007l78123233.super_admin"),
|
||||
BlockHelp.SignDataOfBlock(blk_hash,"121000005l35120456.node1")))*/
|
||||
blk = blk.clearEndorsements
|
||||
blk = blk.clearTransactionResults
|
||||
val r = JsonFormat.toJson(blk)
|
||||
val rstr = pretty(render(r))
|
||||
println(rstr)
|
||||
|
||||
val pw = new PrintWriter("json/gensis.json","UTF-8")
|
||||
pw.write(rstr)
|
||||
pw.flush()
|
||||
pw.close()
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ import java.util
|
||||
import org.json4s.jackson.JsonMethods.{pretty, render}
|
||||
import org.json4s.{DefaultFormats, jackson}
|
||||
import rep.crypto.cert.SignTool
|
||||
import rep.network.PeerHelper
|
||||
import rep.network.autotransaction.PeerHelper
|
||||
import rep.protos.peer.{Block, ChaincodeId, Signer, Transaction}
|
||||
import scalapb.json4s.JsonFormat
|
||||
|
||||
|
@ -61,7 +61,7 @@ object GlobalUtils {
|
||||
val BLOCK_CHAIN = "BLOCK_CHAIN"
|
||||
}
|
||||
|
||||
case object ActorType{
|
||||
/*case object ActorType{
|
||||
val memberlistener = 1
|
||||
val modulemanager = 2
|
||||
val webapi = 3
|
||||
@ -83,7 +83,7 @@ object GlobalUtils {
|
||||
val transactiondispatcher = 19
|
||||
val dispatchofRecvendorsement = 20
|
||||
val dispatchofpreload = 21
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
@ -1,31 +1,33 @@
|
||||
package rep.sc
|
||||
|
||||
import akka.util.Timeout
|
||||
|
||||
import scala.concurrent.duration._
|
||||
import akka.pattern.ask
|
||||
import akka.pattern.AskTimeoutException
|
||||
import rep.network.module.ModuleActorType
|
||||
import scala.concurrent._
|
||||
|
||||
import akka.actor.{Actor, ActorRef, Props}
|
||||
import com.google.protobuf.ByteString
|
||||
import com.google.protobuf.timestamp.Timestamp
|
||||
import rep.app.conf.{SystemProfile, TimePolicy}
|
||||
import rep.network.base.ModuleBase
|
||||
import rep.network.consensus.block.Blocker.{PreTransBlock, PreTransBlockResult}
|
||||
import rep.network.consensus.cfrd.block.Blocker.{PreTransBlock, PreTransBlockResult}
|
||||
import rep.network.tools.PeerExtension
|
||||
import rep.network.Topic
|
||||
import rep.protos.peer._
|
||||
import rep.sc.SandboxDispatcher.DoTransaction
|
||||
import rep.sc.Sandbox.DoTransactionResult
|
||||
import rep.storage.{ImpDataPreloadMgr}
|
||||
import rep.utils.GlobalUtils.ActorType
|
||||
import rep.storage.ImpDataPreloadMgr
|
||||
|
||||
import rep.utils._
|
||||
|
||||
import scala.collection.mutable
|
||||
import akka.pattern.AskTimeoutException
|
||||
import rep.crypto.Sha256
|
||||
import rep.log.RepLogger
|
||||
import akka.routing._;
|
||||
import rep.network.consensus.transaction.PreloaderForTransaction
|
||||
import akka.routing._
|
||||
import rep.network.autotransaction.Topic
|
||||
import rep.network.transaction.PreloaderForTransaction;
|
||||
|
||||
|
||||
object BlockStubActor {
|
||||
@ -42,7 +44,7 @@ class BlockStubActor(moduleName: String) extends ModuleBase(moduleName) {
|
||||
import scala.concurrent.duration._
|
||||
import rep.utils.IdTool
|
||||
import rep.sc.BlockStubActor._
|
||||
import rep.network.consensus.block.Blocker
|
||||
import rep.network.consensus.cfrd.block.Blocker
|
||||
import rep.network.consensus.util.BlockHelp
|
||||
import rep.network.persistence.Storager.{SourceOfBlock, BlockRestore}
|
||||
|
||||
@ -51,7 +53,7 @@ class BlockStubActor(moduleName: String) extends ModuleBase(moduleName) {
|
||||
private def ExecuteTransactionOfBlock(block: Block): Block = {
|
||||
try {
|
||||
//val ref = pe.getActorRef(ActorType.preloaderoftransaction)
|
||||
val ref = pe.getActorRef(ActorType.dispatchofpreload)
|
||||
val ref = pe.getActorRef(ModuleActorType.ActorType.dispatchofpreload)
|
||||
//val ref1 = this.transpreload
|
||||
val future = ref ? Blocker.PreTransBlock(block, "preload")
|
||||
val result = Await.result(future, timeout.duration).asInstanceOf[PreTransBlockResult]
|
||||
@ -92,7 +94,7 @@ class BlockStubActor(moduleName: String) extends ModuleBase(moduleName) {
|
||||
case wb: WriteBlockStub =>
|
||||
val newblock = CreateBlock(wb.trans)
|
||||
if (newblock != null) {
|
||||
pe.getActorRef(ActorType.storager).forward(BlockRestore(newblock, SourceOfBlock.TEST_PROBE, self))
|
||||
pe.getActorRef(ModuleActorType.ActorType.storager).forward(BlockRestore(newblock, SourceOfBlock.TEST_PROBE, self))
|
||||
}
|
||||
case _ => //ignore
|
||||
}
|
||||
|
@ -25,10 +25,9 @@ import org.scalatest._
|
||||
import rep.app.conf.SystemProfile
|
||||
import rep.app.system.ClusterSystem
|
||||
import rep.app.system.ClusterSystem.InitType
|
||||
import rep.network.PeerHelper
|
||||
import rep.network.module.ModuleManager
|
||||
import rep.network.autotransaction.PeerHelper
|
||||
import rep.network.module.cfrd.ModuleManagerOfCFRD
|
||||
import rep.protos.peer.{Certificate, ChaincodeId, Signer}
|
||||
|
||||
import rep.sc.TransferSpec.ACTION
|
||||
import rep.sc.tpl._
|
||||
import rep.sc.tpl.ContractCert
|
||||
@ -60,7 +59,7 @@ class ContractCertSpec(_system: ActorSystem) extends TestKit(_system) with Match
|
||||
val dbTag = "121000005l35120456.node1"
|
||||
val cid = ChaincodeId(SystemProfile.getAccountChaincodeName, 1)
|
||||
//建立PeerManager实例是为了调用transactionCreator(需要用到密钥签名),无他
|
||||
val pm: ActorRef = system.actorOf(ModuleManager.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
val pm: ActorRef = system.actorOf(ModuleManagerOfCFRD.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
|
||||
val signers: Array[Signer] = Array(
|
||||
Signer("node1", "121000005l35120456", "18912345678", List("node1")),
|
||||
|
@ -1,19 +1,19 @@
|
||||
package rep.sc
|
||||
|
||||
import akka.actor.{ActorSystem, ActorRef}
|
||||
import akka.actor.{ActorRef, ActorSystem}
|
||||
import akka.testkit.{TestKit, TestProbe}
|
||||
import org.json4s.{DefaultFormats, jackson}
|
||||
import org.json4s.native.Serialization.{write, writePretty}
|
||||
import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers}
|
||||
import rep.app.system.ClusterSystem
|
||||
import rep.app.system.ClusterSystem.InitType
|
||||
import rep.network.PeerHelper
|
||||
import rep.network.module.ModuleManager
|
||||
import rep.network.module.cfrd.ModuleManagerOfCFRD
|
||||
import rep.protos.peer.{Certificate, ChaincodeId, Signer}
|
||||
import rep.sc.TransferSpec.{ACTION, SetMap}
|
||||
import rep.storage.ImpDataAccess
|
||||
import rep.utils.SerializeUtils.toJson
|
||||
import rep.app.conf.SystemProfile
|
||||
import rep.network.autotransaction.PeerHelper
|
||||
|
||||
import scala.concurrent.duration._
|
||||
import scala.collection.mutable.Map
|
||||
@ -122,7 +122,7 @@ class ContractTest(_system: ActorSystem)
|
||||
val sysName = "121000005l35120456.node1"
|
||||
val dbTag = "121000005l35120456.node1"
|
||||
//建立PeerManager实例是为了调用transactionCreator(需要用到密钥签名),无他
|
||||
val pm = system.actorOf(ModuleManager.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
val pm = system.actorOf(ModuleManagerOfCFRD.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
|
||||
val sm: SetMap = Map("121000005l35120456" -> 50, "12110107bi45jh675g" -> 50, "122000002n00123567" -> 50)
|
||||
val sms = write(sm)
|
||||
|
@ -26,17 +26,13 @@ import rep.protos.peer._
|
||||
import rep.sc.Sandbox._
|
||||
import rep.app.system.ClusterSystem
|
||||
import rep.app.system.ClusterSystem.InitType
|
||||
|
||||
import rep.network.PeerHelper
|
||||
import org.json4s.{DefaultFormats, jackson}
|
||||
import de.heikoseeberger.akkahttpjson4s.Json4sSupport
|
||||
import org.json4s._
|
||||
import rep.network.module.ModuleManager
|
||||
import rep.network.module.cfrd.ModuleManagerOfCFRD
|
||||
import rep.storage.ImpDataAccess
|
||||
import rep.utils.SerializeUtils.deserialise
|
||||
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
import java.io.IOException
|
||||
import java.io.PrintWriter
|
||||
import java.io.FileWriter
|
||||
@ -47,6 +43,7 @@ import org.json4s.{DefaultFormats, Formats, jackson}
|
||||
import org.json4s.native.Serialization.writePretty
|
||||
import org.json4s.native.Serialization
|
||||
import org.json4s.native.Serialization.{read, write}
|
||||
import rep.network.autotransaction.PeerHelper
|
||||
|
||||
/** 合约容器实现的单元测试
|
||||
*
|
||||
@ -82,7 +79,7 @@ class DeliveryAndStorageProofSpec(_system: ActorSystem)
|
||||
val sysName = "121000005l35120456.node1"
|
||||
val dbTag = "121000005l35120456.node1"
|
||||
//建立PeerManager实例是为了调用transactionCreator(需要用到密钥签名),无他
|
||||
val pm = system.actorOf(ModuleManager.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
val pm = system.actorOf(ModuleManagerOfCFRD.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
|
||||
//加载合约脚本
|
||||
val s1 = scala.io.Source.fromFile("src/main/scala/rep/sc/tpl/DeliveryAndStorageProof.scala")
|
||||
|
@ -26,17 +26,13 @@ import rep.protos.peer._
|
||||
import rep.sc.Sandbox._
|
||||
import rep.app.system.ClusterSystem
|
||||
import rep.app.system.ClusterSystem.InitType
|
||||
|
||||
import rep.network.PeerHelper
|
||||
import org.json4s.{DefaultFormats, jackson}
|
||||
import de.heikoseeberger.akkahttpjson4s.Json4sSupport
|
||||
import org.json4s._
|
||||
import rep.network.module.ModuleManager
|
||||
import rep.network.module.cfrd.ModuleManagerOfCFRD
|
||||
import rep.storage.ImpDataAccess
|
||||
import rep.utils.SerializeUtils.deserialise
|
||||
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
import java.io.IOException
|
||||
import java.io.PrintWriter
|
||||
import java.io.FileWriter
|
||||
@ -47,8 +43,8 @@ import org.json4s.{DefaultFormats, Formats, jackson}
|
||||
import org.json4s.native.Serialization.writePretty
|
||||
import org.json4s.native.Serialization
|
||||
import org.json4s.native.Serialization.{read, write}
|
||||
|
||||
import rep.crypto.cert.SignTool
|
||||
import rep.network.autotransaction.PeerHelper
|
||||
|
||||
/** 合约容器实现的单元测试
|
||||
*
|
||||
@ -83,7 +79,7 @@ class DeploySpec(_system: ActorSystem)
|
||||
|
||||
val sysName = "121000005l35120456.node1"
|
||||
//建立PeerManager实例是为了调用transactionCreator(需要用到密钥签名),无他
|
||||
val pm = system.actorOf(ModuleManager.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
val pm = system.actorOf(ModuleManagerOfCFRD.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
|
||||
//加载合约脚本
|
||||
val s1 = scala.io.Source.fromFile("src/main/scala/rep/sc/tpl/ContractAssetsTPL.scala")
|
||||
|
@ -23,8 +23,8 @@ import org.json4s.native.Serialization.{write, writePretty}
|
||||
import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers}
|
||||
import rep.app.system.ClusterSystem
|
||||
import rep.app.system.ClusterSystem.InitType
|
||||
import rep.network.PeerHelper
|
||||
import rep.network.module.ModuleManager
|
||||
import rep.network.autotransaction.PeerHelper
|
||||
import rep.network.module.cfrd.ModuleManagerOfCFRD
|
||||
import rep.protos.peer.{Certificate, ChaincodeId, Signer}
|
||||
import rep.sc.SandboxSpec.{ACTION, SetMap}
|
||||
import rep.sc.tpl._
|
||||
@ -75,7 +75,7 @@ class SandboxSpec(_system: ActorSystem)
|
||||
val sysName = "121000005l35120456.node1"
|
||||
val dbTag = "121000005l35120456.node1"
|
||||
//建立PeerManager实例是为了调用transactionCreator(需要用到密钥签名),无他
|
||||
val pm = system.actorOf(ModuleManager.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
val pm = system.actorOf(ModuleManagerOfCFRD.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
// 部署资产管理
|
||||
val s1 = scala.io.Source.fromFile("src/main/scala/rep/sc/tpl/ContractAssetsTPL.scala")
|
||||
val l1 = try s1.mkString finally s1.close()
|
||||
|
@ -23,8 +23,8 @@ import org.json4s.native.Serialization.{write, writePretty}
|
||||
import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers}
|
||||
import rep.app.system.ClusterSystem
|
||||
import rep.app.system.ClusterSystem.InitType
|
||||
import rep.network.PeerHelper
|
||||
import rep.network.module.ModuleManager
|
||||
import rep.network.autotransaction.PeerHelper
|
||||
import rep.network.module.cfrd.ModuleManagerOfCFRD
|
||||
import rep.protos.peer.{Certificate, ChaincodeId, Signer}
|
||||
import rep.sc.TransferSpec.{ACTION, SetMap}
|
||||
import rep.sc.tpl._
|
||||
@ -73,7 +73,7 @@ class StateSpec(_system: ActorSystem)
|
||||
val sysName = "121000005l35120456.node1"
|
||||
val dbTag = "121000005l35120456.node1"
|
||||
//建立PeerManager实例是为了调用transactionCreator(需要用到密钥签名),无他
|
||||
val pm = system.actorOf(ModuleManager.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
val pm = system.actorOf(ModuleManagerOfCFRD.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
|
||||
// 部署资产管理
|
||||
val s1 = scala.io.Source.fromFile("src/main/scala/rep/sc/tpl/ContractAssetsTPL.scala")
|
||||
|
@ -26,17 +26,13 @@ import rep.protos.peer._
|
||||
import rep.sc.Sandbox._
|
||||
import rep.app.system.ClusterSystem
|
||||
import rep.app.system.ClusterSystem.InitType
|
||||
|
||||
import rep.network.PeerHelper
|
||||
import org.json4s.{DefaultFormats, jackson}
|
||||
import de.heikoseeberger.akkahttpjson4s.Json4sSupport
|
||||
import org.json4s._
|
||||
import rep.network.module.ModuleManager
|
||||
import rep.network.module.cfrd.ModuleManagerOfCFRD
|
||||
import rep.storage.ImpDataAccess
|
||||
import rep.utils.SerializeUtils.deserialise
|
||||
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
import java.io.IOException
|
||||
import java.io.PrintWriter
|
||||
import java.io.FileWriter
|
||||
@ -47,6 +43,7 @@ import org.json4s.{DefaultFormats, Formats, jackson}
|
||||
import org.json4s.native.Serialization.writePretty
|
||||
import org.json4s.native.Serialization
|
||||
import org.json4s.native.Serialization.{read, write}
|
||||
import rep.network.autotransaction.PeerHelper
|
||||
|
||||
/** 合约容器实现的单元测试
|
||||
*
|
||||
@ -82,7 +79,7 @@ class SupplySpec(_system: ActorSystem)
|
||||
val sysName = "121000005l35120456.node1"
|
||||
val dbTag = "121000005l35120456.node1"
|
||||
//建立PeerManager实例是为了调用transactionCreator(需要用到密钥签名),无他
|
||||
val pm = system.actorOf(ModuleManager.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
val pm = system.actorOf(ModuleManagerOfCFRD.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
|
||||
//加载合约脚本
|
||||
val s1 = scala.io.Source.fromFile("src/main/scala/rep/sc/tpl/SupplyTPL.scala")
|
||||
|
@ -26,17 +26,13 @@ import rep.protos.peer._
|
||||
import rep.sc.Sandbox._
|
||||
import rep.app.system.ClusterSystem
|
||||
import rep.app.system.ClusterSystem.InitType
|
||||
|
||||
import rep.network.PeerHelper
|
||||
import org.json4s.{DefaultFormats, jackson}
|
||||
import de.heikoseeberger.akkahttpjson4s.Json4sSupport
|
||||
import org.json4s._
|
||||
import rep.network.module.ModuleManager
|
||||
import rep.network.module.cfrd.ModuleManagerOfCFRD
|
||||
import rep.storage.ImpDataAccess
|
||||
import rep.utils.SerializeUtils.deserialise
|
||||
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
import java.io.IOException
|
||||
import java.io.PrintWriter
|
||||
import java.io.FileWriter
|
||||
@ -47,6 +43,7 @@ import org.json4s.{DefaultFormats, Formats, jackson}
|
||||
import org.json4s.native.Serialization.writePretty
|
||||
import org.json4s.native.Serialization
|
||||
import org.json4s.native.Serialization.{read, write}
|
||||
import rep.network.autotransaction.PeerHelper
|
||||
|
||||
/** 合约容器实现的单元测试
|
||||
*
|
||||
@ -82,7 +79,7 @@ class SupplySpec2(_system: ActorSystem)
|
||||
val sysName = "121000005l35120456.node1"
|
||||
val dbTag = "121000005l35120456.node1"
|
||||
//建立PeerManager实例是为了调用transactionCreator(需要用到密钥签名),无他
|
||||
val pm = system.actorOf(ModuleManager.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
val pm = system.actorOf(ModuleManagerOfCFRD.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
|
||||
//加载合约脚本
|
||||
val s1 = scala.io.Source.fromFile("src/main/scala/rep/sc/tpl/SupplyTPL2.scala")
|
||||
|
@ -23,8 +23,8 @@ import org.json4s.native.Serialization.{write, writePretty}
|
||||
import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers}
|
||||
import rep.app.system.ClusterSystem
|
||||
import rep.app.system.ClusterSystem.InitType
|
||||
import rep.network.PeerHelper
|
||||
import rep.network.module.ModuleManager
|
||||
import rep.network.autotransaction.PeerHelper
|
||||
import rep.network.module.cfrd.ModuleManagerOfCFRD
|
||||
import rep.protos.peer.{Certificate, ChaincodeId, Signer}
|
||||
import rep.sc.TransferSpec.{ACTION, SetMap}
|
||||
import rep.sc.tpl._
|
||||
@ -76,7 +76,7 @@ class TransferSpec(_system: ActorSystem)
|
||||
val sysName = "121000005l35120456.node1"
|
||||
val dbTag = "121000005l35120456.node1"
|
||||
//建立PeerManager实例是为了调用transactionCreator(需要用到密钥签名),无他
|
||||
val pm = system.actorOf(ModuleManager.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
val pm = system.actorOf(ModuleManagerOfCFRD.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
|
||||
// 部署资产管理
|
||||
val s1 = scala.io.Source.fromFile("src/main/scala/rep/sc/tpl/ContractAssetsTPL.scala")
|
||||
|
@ -23,8 +23,8 @@ import org.json4s.native.Serialization.{write, writePretty}
|
||||
import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers}
|
||||
import rep.app.system.ClusterSystem
|
||||
import rep.app.system.ClusterSystem.InitType
|
||||
import rep.network.PeerHelper
|
||||
import rep.network.module.ModuleManager
|
||||
import rep.network.autotransaction.PeerHelper
|
||||
import rep.network.module.cfrd.ModuleManagerOfCFRD
|
||||
import rep.protos.peer.{Certificate, ChaincodeId, Signer}
|
||||
import rep.sc.TransferSpec.{ACTION, SetMap}
|
||||
import rep.sc.tpl._
|
||||
@ -61,7 +61,7 @@ class TransferSpec2(_system: ActorSystem) extends TestKit(_system) with Matchers
|
||||
val sysName = "121000005l35120456.node1"
|
||||
val dbTag = "121000005l35120456.node1"
|
||||
//建立PeerManager实例是为了调用transactionCreator(需要用到密钥签名),无他
|
||||
val pm = system.actorOf(ModuleManager.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
val pm = system.actorOf(ModuleManagerOfCFRD.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
|
||||
// 部署资产管理
|
||||
val s1 = scala.io.Source.fromFile("src/main/scala/rep/sc/tpl/ContractAssetsTPL2.scala")
|
||||
|
@ -17,20 +17,21 @@
|
||||
package rep.sc
|
||||
|
||||
import akka.util.Timeout
|
||||
|
||||
import scala.concurrent.duration._
|
||||
import akka.pattern.ask
|
||||
import akka.pattern.AskTimeoutException
|
||||
import scala.concurrent._
|
||||
|
||||
import akka.actor.{ActorSystem, ActorRef, ActorSelection}
|
||||
import scala.concurrent._
|
||||
import akka.actor.{ActorRef, ActorSelection, ActorSystem}
|
||||
import akka.testkit.{TestKit, TestProbe}
|
||||
import org.json4s.{DefaultFormats, jackson}
|
||||
import org.json4s.native.Serialization.{write, writePretty}
|
||||
import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers}
|
||||
import rep.app.system.ClusterSystem
|
||||
import rep.app.system.ClusterSystem.InitType
|
||||
import rep.network.PeerHelper
|
||||
import rep.network.module.ModuleManager
|
||||
import rep.network.autotransaction.PeerHelper
|
||||
import rep.network.module.cfrd.ModuleManagerOfCFRD
|
||||
import rep.protos.peer.{Certificate, ChaincodeId, Signer}
|
||||
import rep.sc.tpl._
|
||||
//.{CertStatus,CertInfo}
|
||||
@ -42,7 +43,7 @@ import rep.app.conf.SystemProfile
|
||||
|
||||
import scala.concurrent.duration._
|
||||
import scala.collection.mutable.Map
|
||||
import rep.utils.GlobalUtils.ActorType
|
||||
import rep.network.module.cfrd.CFRDActorType
|
||||
import rep.protos.peer.Transaction
|
||||
|
||||
import scala.concurrent.ExecutionContext.Implicits._
|
||||
@ -75,7 +76,7 @@ class TransferSpec3(_system: ActorSystem) extends TestKit(_system) with Matchers
|
||||
val sysName = "121000005l35120456.node1"
|
||||
val dbTag = "121000005l35120456.node1"
|
||||
//建立PeerManager实例是为了调用transactionCreator(需要用到密钥签名),无他
|
||||
val pm = system.actorOf(ModuleManager.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
val pm = system.actorOf(ModuleManagerOfCFRD.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
|
||||
//val path = pm.path.address.toString + "/user/modulemanager/preloadtransrouter"
|
||||
//val sandbox2 = system.actorOf(TransactionDispatcher.props("transactiondispatcher"),"transactiondispatcher")
|
||||
|
@ -21,8 +21,8 @@ import akka.testkit.{TestKit, TestProbe}
|
||||
import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers}
|
||||
import rep.app.system.ClusterSystem
|
||||
import rep.app.system.ClusterSystem.InitType
|
||||
import rep.network.PeerHelper
|
||||
import rep.network.module.ModuleManager
|
||||
import rep.network.autotransaction.PeerHelper
|
||||
import rep.network.module.cfrd.ModuleManagerOfCFRD
|
||||
import rep.protos.peer.{Certificate, ChaincodeId, Signer}
|
||||
import rep.sc.TransferSpec.{ACTION, SetMap}
|
||||
import rep.sc.tpl._
|
||||
@ -58,7 +58,7 @@ class TransferSpec_Legal(_system: ActorSystem) extends TestKit(_system) with Mat
|
||||
val sysName = "121000005l35120456.node1"
|
||||
val dbTag = "121000005l35120456.node1"
|
||||
//建立PeerManager实例是为了调用transactionCreator(需要用到密钥签名),无他
|
||||
val pm = system.actorOf(ModuleManager.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
val pm = system.actorOf(ModuleManagerOfCFRD.props("modulemanager", sysName, false, false, false), "modulemanager")
|
||||
|
||||
// 部署资产管理
|
||||
val s1 = scala.io.Source.fromFile("src/main/scala/rep/sc/tpl/ContractAssets_Legal.scala")
|
||||
|
Loading…
Reference in New Issue
Block a user