mirror of
https://github.com/digital-asset/daml.git
synced 2024-11-10 10:46:11 +03:00
Add functions to compute disclosure for different stream types (#4970)
* Add functions to compute disclosure for different stream types CHANGELOG_BEGIN CHANGELOG_END * Address https://github.com/digital-asset/daml/pull/4970#pullrequestreview-373708955 * Optimize imports
This commit is contained in:
parent
f69100a4d4
commit
cc2e97ee51
@ -0,0 +1,32 @@
|
||||
// Copyright (c) 2020 The DAML Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package com.digitalasset.platform.index
|
||||
|
||||
import com.digitalasset.daml.lf.data.Ref.Party
|
||||
import com.digitalasset.daml.lf.data.Relation.Relation
|
||||
import com.digitalasset.daml.lf.engine.Blinding
|
||||
import com.digitalasset.daml.lf.transaction.Transaction.{NodeId, Transaction}
|
||||
import com.digitalasset.daml.lf.transaction.{GenTransaction, NodeInfo}
|
||||
|
||||
object Disclosure {
|
||||
|
||||
def forFlatTransaction[Nid, Cid, Val](tx: GenTransaction[Nid, Cid, Val]): Relation[Nid, Party] =
|
||||
tx.nodes.collect {
|
||||
case (nodeId, c: NodeInfo.Create) =>
|
||||
nodeId -> c.stakeholders
|
||||
case (nodeId, e: NodeInfo.Exercise) if e.consuming =>
|
||||
nodeId -> e.stakeholders
|
||||
}
|
||||
|
||||
def forTransactionTree(tx: Transaction): Relation[NodeId, Party] = {
|
||||
val createAndExercise: Set[NodeId] =
|
||||
tx.nodes.collect {
|
||||
case p @ (_, _: NodeInfo.Create) => p
|
||||
case p @ (_, _: NodeInfo.Exercise) => p
|
||||
}.keySet
|
||||
|
||||
Blinding.blind(tx).disclosure.filterKeys(createAndExercise)
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user