Blockchain 在hyperledger composer中设计模型文件

Blockchain 在hyperledger composer中设计模型文件,blockchain,hyperledger,hyperledger-composer,Blockchain,Hyperledger,Hyperledger Composer,考虑到一个银行场景,其中参与者是客户,交易是转账,它可以是 由accountId标识的资产帐户{ o字符串accountId ->客户所有者 o双重平衡 } 交易账户转账{ ->来自 ->说明 o双倍金额 } 但如果有不同类型的参与者持有账户呢。就像一个只能转移发送者,而另一个只能接收者?如何解决这个问题,因为帐户不能有两种类型的所有者 这会是这样吗 由accountId标识的资产帐户{ o字符串accountId o双重平衡 } 由sid标识的参与者发件人{ ->帐户 o字符串sId } ri

考虑到一个银行场景,其中参与者是客户,交易是转账,它可以是

由accountId标识的资产帐户{ o字符串accountId ->客户所有者 o双重平衡 } 交易账户转账{ ->来自 ->说明 o双倍金额 }

但如果有不同类型的参与者持有账户呢。就像一个只能转移发送者,而另一个只能接收者?如何解决这个问题,因为帐户不能有两种类型的所有者

这会是这样吗

由accountId标识的资产帐户{ o字符串accountId o双重平衡 } 由sid标识的参与者发件人{ ->帐户 o字符串sId } rid识别的参与者-接收者{ ->帐户 o字符串rId } 事务发送{ ->发送者发送者 ->接收机 }

像上面那样设计模型合适吗?

是的,应该可以

为了确保只有发送方可以执行传输,您可以在事务处理器中实现一个逻辑,如果调用事务的参与者不是发送方,则会出现异常

模型

总磷

否则,您可以在访问控制文件中实现一个规则,仅当调用事务的人是发送者时才允许转账

rule AllowSenderToTransferMoney {
    description: "Sender can transfer money"
    participant(m): "org.example.sender"
    operation: ALL
    resource(v): "org.example.account"
    transaction(tx): "org.example.send"
    action: ALLOW
} 

将认可ACL规则作为更干净的方法-因为它没有在事务逻辑中实现,并且“Cluser”授权规则在一个地方。
async function send(tx) {  
    if (currentParticipant.getFullyQualifiedType() !== 'org.example.sender') {
      // Throw an error as the current participant is not a sender.
      throw new Error('Current participant is not a sender');
    }

    //Other business logics
}
rule AllowSenderToTransferMoney {
    description: "Sender can transfer money"
    participant(m): "org.example.sender"
    operation: ALL
    resource(v): "org.example.account"
    transaction(tx): "org.example.send"
    action: ALLOW
}