Merge remote-tracking branch 'origin/dev_jby_preview' into yf_preview

# Conflicts:
#	src/main/scala/rep/utils/GenesisBuilder.scala
This commit is contained in:
brightestboy 2019-03-22 11:19:37 +08:00
commit f19ca32464
6 changed files with 110 additions and 71 deletions

View File

@ -71,7 +71,7 @@ system {
//如果是单机多节点测试模式Repchain则选择0默认节点1会开启
ws_enable = 1//api 0,不开启;1,开启
//交易生产方式
trans_create_type = 1 //0,手动;1,自动
trans_create_type = 0 //0,手动;1,自动
//是否进行TPS测试
statistic_enable = 0 // 0,unable;able

File diff suppressed because one or more lines are too long

View File

@ -27,7 +27,7 @@ import rep.app.conf.SystemProfile
object certCache {
private val getCertLock : Lock = new ReentrantLock();
private var caches : immutable.HashMap[String,(Certificate,java.security.cert.Certificate)] = new immutable.HashMap[String,(Certificate,java.security.cert.Certificate)]()
private var caches : immutable.HashMap[String,(Boolean,java.security.cert.Certificate)] = new immutable.HashMap[String,(Boolean,java.security.cert.Certificate)]()
def getCertByPem(pemcert: String): java.security.cert.Certificate = {
val cf = java.security.cert.CertificateFactory.getInstance("X.509")
@ -52,7 +52,7 @@ object certCache {
val kvcert = SerializeUtils.deserialise(cert.get).asInstanceOf[Certificate]
if(kvcert != null){
rcert = getCertByPem(kvcert.certificate)
caches += certKey -> (kvcert,rcert)
caches += certKey -> (kvcert.certValid,rcert)
}
}
}

View File

@ -73,7 +73,7 @@ object PeerHelper {
val millis = TimeUtils.getCurrentTime()
if (chaincodeId == null) t
val txid = IdTool.getUUID()
val txid = IdTool.getRandomUUID
val cip = new ChaincodeInput(chaincodeInputFunc, params)
t = t.withId(txid)
t = t.withCid(chaincodeId)
@ -96,7 +96,7 @@ object PeerHelper {
val millis = TimeUtils.getCurrentTime()
if (chaincodeId == null) t
val txid = IdTool.getUUID()
val txid = IdTool.getRandomUUID
var cip = new ChaincodeDeploy(timeout)
cip = cip.withCodePackage(spcPackage)
cip = cip.withLegalProse(legal_prose)
@ -122,7 +122,7 @@ object PeerHelper {
val millis = TimeUtils.getCurrentTime()
if (chaincodeId == null) t
val txid = IdTool.getUUID()
val txid = IdTool.getRandomUUID
t = t.withId(txid)
t = t.withCid(chaincodeId)
t = t.withType(rep.protos.peer.Transaction.Type.CHAINCODE_SET_STATE)

View File

@ -31,6 +31,7 @@ import rep.network.consensus.block.BlockHelper
import rep.crypto.cert.SignTool
import scala.collection.mutable
import rep.sc.tpl._
/**
* 用于生成创世块json文件,该json文件可以在链初始化时由节点加载
* 创世块中预置了deploy基础方法的交易
@ -54,13 +55,16 @@ object GenesisBuilder {
val cid = new ChaincodeId("ContractCert",1)
var translist : Array[Transaction] = new Array[Transaction] (15)
var translist : Array[Transaction] = new Array[Transaction] (17)
val dep_trans = PeerHelper.createTransaction4Deploy(sysName, 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)
@ -74,8 +78,8 @@ object GenesisBuilder {
for(i<-0 to 5){
translist(i+1) = PeerHelper.createTransaction4Invoke("951002007l78123233.super_admin", cid,
"SignUpSigner", Seq(SerializeUtils.compactJson(signers(i))))
translist(i+2) = PeerHelper.createTransaction4Invoke("951002007l78123233.super_admin", cid,
"SignUpSigner", Seq(Json4s.compactJson(signers(i))))
}
@ -87,8 +91,8 @@ object GenesisBuilder {
val tmp = rep.protos.peer.Certificate(certstr,"SHA1withECDSA",true,Option(Timestamp(millis/1000 , ((millis % 1000) * 1000000).toInt)))
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)))
translist(i+8) = PeerHelper.createTransaction4Invoke("951002007l78123233.super_admin", cid,
"SignUpCert", Seq(Json4s.compactJson(a)))
}
@ -97,13 +101,16 @@ object GenesisBuilder {
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
translist(14) = dep_asserts_trans
val dep_asserts_trans_state = PeerHelper.createTransaction4State(sysName, cid2, true)
translist(15) = dep_asserts_trans_state
// read invoke scala contract
val s3 = scala.io.Source.fromFile("scripts/set.json")
val ct1 = try s3.mkString finally s3.close()
translist(14) = PeerHelper.createTransaction4Invoke("951002007l78123233.super_admin", cid2,
translist(16) = PeerHelper.createTransaction4Invoke("951002007l78123233.super_admin", cid2,
"set", Seq(ct1))

View File

@ -7,7 +7,7 @@ import com.gilt.timeuuid.TimeUuid
object IdTool {
def getUUID(): String = {
def getUUID: String = {
val uuid = TimeUuid()
uuid.toString
}