Corda Flow Participants How To Add & Remove

依然范特西╮ 提交于 2019-12-24 08:55:58

问题


  1. Can we add/remove participant in the subsequent transaction if the original transaction does not have it.

  2. I have party A which has created one transaction and added a participant Party B. The state created in the transaction is shared with Party B. There are state properties like FirstName, LastName and Status. Party B changes the status to green and then the transaction is completed and recorded to vault of Party B and Party A.

The same process is followed between Party A and Party C. The same process is followed between Party A and Party D. ------Party B / Party A /-------Party C \ ------Party D

I have a use case wherein Party B, Party C, Party D can change the status in the state to Green. As soon as all the status becomes green, I want to initiate a flow at Party A.

What is the best way to implement this in Corda?


回答1:


1) Yes you can add or remove by placing the participant inside the participant list you could initailize them as null at the start, just remember to send the flowSession to everyone that is involved in the state/transaction. However by performing this action do take note that the chain of transactions ( walk the chain ) will still apply hence the newly added participant would be able to view the history of the state so if there is a requirement for sensitive information to specific party it would be exposed to all participants for the state.

2) Yes you could do that also, there are two sections for the flow the @InitiatingFlow and the @InitiatedBy ( Responder ) flow you could put a logic here to query your vault for related transactions and do your logic operations




回答2:


1)One way to do it would be to have your state property to have a List parties. in your getParticipants() method which you've overridden in the state class return this list. Now at the time of creating the state you can add as many parties as you want. Once the state has been persisted. You can update this state now and add as many participants as you want to parties field.

2) Not sure in here but if you are party agnostic you can have a status ENUM in your state and make it go from PINE,PEAR,LIME,GREEN(Order of green color) and have each party update the status accordingly. Once green you can start your flow. Make your state scheduled-able and check if it's green you can start the flow to do whatever you want.

PS:This is a workaround I can think of from top of my head, I'm not sure if this an appropriate way to do it in corda.



来源:https://stackoverflow.com/questions/49613796/corda-flow-participants-how-to-add-remove

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!