Skip to content

Commit

Permalink
Engine: Small refactoring of partial transactions (#3951)
Browse files Browse the repository at this point in the history
* small refactoring of partial transaction

CHANGELOG_BEGIN
CHANGELOG_END

* cosmetic changes
  • Loading branch information
remyhaemmerle-da authored and mergify[bot] committed Jan 9, 2020
1 parent 27fd561 commit c0f387f
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 220 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,12 @@ case class Conversions(homePackageId: Ref.PackageId) {
def convertPartialTransaction(ptx: Tx.PartialTransaction): PartialTransaction = {
val builder = PartialTransaction.newBuilder
.addAllNodes(ptx.nodes.map(Function.tupled(convertTxNode)).asJava)
.addAllRoots(ptx.roots.toImmArray.toSeq.sortBy(_.index).map(convertTxNodeId).asJava)
.addAllRoots(
ptx.context.children.toImmArray.toSeq.sortBy(_.index).map(convertTxNodeId).asJava)

ptx.context match {
case Tx.ContextRoot =>
Unit
case Tx.ContextExercises(ctx) =>
case Tx.ContextRoot(_) =>
case Tx.ContextExercises(ctx, _) =>
val ecBuilder = ExerciseContext.newBuilder
.setTargetId(mkContractRef(ctx.targetId, ctx.templateId))
.setChoiceId(ctx.choiceId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ object SBuiltin {
case _ => crash("Bad key")
}
val (coid, newPtx) = machine.ptx
.create(
.insertCreate(
coinst = V.ContractInst(template = templateId, arg = createArg, agreementText = agreement),
optLocation = machine.lastLocation,
signatories = sigs,
Expand Down Expand Up @@ -1006,8 +1006,8 @@ object SBuiltin {
val observers = extractParties(args.get(2))
val stakeholders = observers union signatories
val contextActors = machine.ptx.context match {
case ContextExercises(ctx) => ctx.actingParties union ctx.signatories
case ContextRoot => machine.committers
case ContextExercises(ctx, _) => ctx.actingParties union ctx.signatories
case ContextRoot(_) => machine.committers
}

machine.ptx = machine.ptx.insertFetch(
Expand Down
Loading

0 comments on commit c0f387f

Please sign in to comment.