mirror of
https://gitee.com/BTAJL/repchain.git
synced 2024-11-30 18:58:20 +08:00
Merge remote-tracking branch 'origin/up_pre' into yf_preview
This commit is contained in:
commit
b4e1f6e1fa
@ -10,6 +10,7 @@ val akkaHttpVersion = "10.1.8"
|
||||
dependencyOverrides ++= Seq(
|
||||
"org.json4s" % "json4s-jackson_2.12" % "3.6.5",
|
||||
"com.google.guava" % "guava" % "21.0",
|
||||
"com.thesamet.scalapb" % "scalapb-runtime_2.12" % "0.7.0",
|
||||
"org.scala-lang.modules" % "scala-xml_2.12" % "1.1.1"
|
||||
)
|
||||
|
||||
|
@ -180,7 +180,8 @@ class RestActor(moduleName: String) extends ModuleBase(moduleName) {
|
||||
//预执行异常,废弃交易,向api调用者发送异常
|
||||
sender ! PostResult(t.id, None, Option(err.cause.getMessage))
|
||||
}
|
||||
case false => throw new RuntimeException("验证签名出错")
|
||||
case false =>
|
||||
sender ! PostResult(t.id, None, Option("验证签名出错"))
|
||||
}
|
||||
|
||||
}catch{
|
||||
@ -193,22 +194,25 @@ class RestActor(moduleName: String) extends ModuleBase(moduleName) {
|
||||
|
||||
case tranSign(tr: String) =>
|
||||
val tr1 = BytesHex.hex2bytes(tr) // 解析交易编码后的16进制字符串,进行解码16进制反解码decode
|
||||
var txr = Transaction.defaultInstance
|
||||
try {
|
||||
val txr = Transaction.parseFrom(tr1)
|
||||
txr = Transaction.parseFrom(tr1)
|
||||
preTransaction(txr)
|
||||
} catch {
|
||||
case e:Exception =>
|
||||
sender ! PostResult("", None, Option(s"transaction parser error! + ${e.getMessage}"))
|
||||
sender ! PostResult(txr.id, None, Option(s"transaction parser error! + ${e.getMessage}"))
|
||||
}
|
||||
|
||||
//处理post CSpec构造交易的请求
|
||||
case c: CSpec =>
|
||||
//构建transaction并通过peer广播
|
||||
var txr = Transaction.defaultInstance
|
||||
//debug状态才动用节点密钥签名
|
||||
if(contractOperationMode==0){
|
||||
val t = buildTranaction(pe.getSysTag, c)
|
||||
preTransaction(t)
|
||||
}else sender ! PostResult(null, None, Option("非Debug状态下此调用无效"))
|
||||
//构建transaction并通过peer预执行广播
|
||||
txr = buildTranaction(pe.getSysTag, c)
|
||||
preTransaction(txr)
|
||||
}else
|
||||
sender ! PostResult(txr.id, None, Option("非Debug状态下此调用无效"))
|
||||
|
||||
// 流式提交交易
|
||||
case t: Transaction =>
|
||||
|
@ -2,7 +2,7 @@ package rep.network.consensus.util
|
||||
|
||||
import com.google.protobuf.ByteString
|
||||
import com.google.protobuf.timestamp.Timestamp
|
||||
import com.trueaccord.scalapb.json.JsonFormat
|
||||
import scalapb.json4s.JsonFormat
|
||||
import rep.app.conf.SystemProfile
|
||||
import rep.crypto.{ Sha256 }
|
||||
import rep.protos.peer.{ Block, Signature, Transaction, ChaincodeId, CertId }
|
||||
|
@ -29,7 +29,6 @@ import org.slf4j.LoggerFactory
|
||||
import org.json4s.{DefaultFormats, Formats, jackson}
|
||||
import de.heikoseeberger.akkahttpjson4s.Json4sSupport
|
||||
import org.json4s._
|
||||
import com.trueaccord.scalapb.json.JsonFormat
|
||||
import akka.util.Timeout
|
||||
import Shim._
|
||||
import rep.crypto.BytesHex
|
||||
@ -46,6 +45,8 @@ import rep.log.RepLogger
|
||||
*
|
||||
*/
|
||||
object Sandbox {
|
||||
val ERR_UNKNOWN_TRANSACTION_TYPE = "无效的交易类型"
|
||||
|
||||
val SplitChainCodeId = "_"
|
||||
//日志前缀
|
||||
val log_prefix = "Sandbox-"
|
||||
@ -211,6 +212,8 @@ abstract class Sandbox(cid:ChaincodeId) extends Actor {
|
||||
if(state_bytes == null){
|
||||
throw new SandboxException(ERR_INVOKE_CHAINCODE_NOT_EXIST)
|
||||
}
|
||||
case _ => throw SandboxException(ERR_UNKNOWN_TRANSACTION_TYPE)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -182,6 +182,7 @@ class TransProcessor(name: String, parent: ActorRef) extends Actor {
|
||||
case Transaction.Type.CHAINCODE_DEPLOY =>
|
||||
//新执行的deploy交易,新建actor
|
||||
createActorByType( t.para.spec.get.ctype, cid, sn)
|
||||
case _ => throw SandboxException(ERR_UNKNOWN_TRANSACTION_TYPE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ class SandboxJS(cid:ChaincodeId) extends Sandbox(cid){
|
||||
case Transaction.Type.CHAINCODE_INVOKE =>
|
||||
val r1 = sandbox.eval(t.para.ipt.get.function)
|
||||
r1.asInstanceOf[ActionResult]
|
||||
case _ => throw SandboxException(ERR_UNKNOWN_TRANSACTION_TYPE)
|
||||
}
|
||||
new DoTransactionResult(t.id, r,
|
||||
shim.ol.toList,None)
|
||||
|
@ -93,6 +93,7 @@ class SandboxScala(cid:ChaincodeId) extends Sandbox(cid){
|
||||
shim.sr.Put(key_tx_state,state_bytes)
|
||||
shim.ol.append(OperLog(key_tx_state, null, ByteString.copyFrom(state_bytes)))
|
||||
null
|
||||
case _ => throw SandboxException(ERR_UNKNOWN_TRANSACTION_TYPE)
|
||||
}
|
||||
new DoTransactionResult(t.id, r,
|
||||
shim.ol.toList,None)
|
||||
|
@ -22,7 +22,7 @@ import com.typesafe.config.ConfigFactory
|
||||
import com.google.protobuf.ByteString
|
||||
import com.google.protobuf.timestamp.Timestamp
|
||||
import rep.protos.peer._
|
||||
import com.trueaccord.scalapb.json.JsonFormat
|
||||
import scalapb.json4s.JsonFormat
|
||||
import rep.crypto.{ Sha256}
|
||||
import org.json4s.{DefaultFormats, Formats, jackson}
|
||||
import org.json4s.jackson.JsonMethods._
|
||||
|
@ -18,7 +18,7 @@ package rep.network
|
||||
|
||||
import akka.actor.{ActorSystem, Props}
|
||||
import akka.testkit.TestKit
|
||||
import com.trueaccord.scalapb.json.JsonFormat
|
||||
import scalapb.json4s.JsonFormat
|
||||
import org.json4s.{DefaultFormats, jackson, _}
|
||||
import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers}
|
||||
import rep.app.system.ClusterSystem
|
||||
|
Loading…
Reference in New Issue
Block a user