重构代码--45修改合约状态判断,当合约部署已经在某个快照中执行了,并且没有入块。这时同一合约的另外一个部署命令过来,应该可以执行。

This commit is contained in:
wuwei1972 2019-04-28 23:11:19 +08:00
parent d340b8541a
commit a9f48a76b9

View File

@ -96,7 +96,7 @@ class SandboxDispatcher(moduleName: String, cid: String) extends ModuleBase(modu
import scala.collection.immutable._
var ContractState: ContractStateType.Value = ContractStateType.ContractInNone
var txidOfContractDeploy: String = ""
//var txidOfContractDeploy: String = ""
private var RouterOfParallelSandboxs: Router = null
private var SerialSandbox: ActorRef = null
@ -115,8 +115,9 @@ class SandboxDispatcher(moduleName: String, cid: String) extends ModuleBase(modu
if (txid == null) {
None
} else {
this.txidOfContractDeploy = deserialise(txid).asInstanceOf[String]
db.getTransDataByTxId(this.txidOfContractDeploy)
//this.txidOfContractDeploy = deserialise(txid).asInstanceOf[String]
//db.getTransDataByTxId(this.txidOfContractDeploy)
db.getTransDataByTxId(deserialise(txid).asInstanceOf[String])
}
}
@ -131,10 +132,10 @@ class SandboxDispatcher(moduleName: String, cid: String) extends ModuleBase(modu
val snapshot = ImpDataPreloadMgr.GetImpDataPreload(pe.getSysTag, da)
val txid = snapshot.Get(key_tx)
if (txid != null) {
val txid_str = deserialise(txid).asInstanceOf[String]
if (txid_str == this.txidOfContractDeploy) {
//val txid_str = deserialise(txid).asInstanceOf[String]
//if (txid_str == this.txidOfContractDeploy) {
b = true
}
//}
}
b
}
@ -150,7 +151,11 @@ class SandboxDispatcher(moduleName: String, cid: String) extends ModuleBase(modu
//cc not exist
if (t.`type` == Transaction.Type.CHAINCODE_DEPLOY) {
this.ContractState = ContractStateType.ContractInSnapshot
this.txidOfContractDeploy = t.id
if (IsContractInSnapshot(da)) {
throw new SandboxException(ERR_REPEATED_CID)
}else{
this.ContractState = ContractStateType.ContractInSnapshot
}
} else {
if (IsContractInSnapshot(da)) {
//contract in snapshot