英文:
Subflow versus single flow calling while migration of 2000 states
问题
-
编写两个流程,第一个流程获取所有 2000 个 CarState 并通过 subFlow() 函数逐个传递每个 CarState,第二个流程中可以进行新状态、交易构建器和交易完成等操作。
-
编写一个单一流程,在同一个流程中获取所有 2000 个 CarState,并在循环内创建新状态、交易构建器和交易完成等步骤。
我想知道哪种方式是最佳的做法,请帮助。
英文:
I want to update 2000 corda states of CarState while migrating from V1 to V2. In order to write a flow for that, two ways I can think of:
-
Write two flows, which first flow get all the 2000 carstates and call the second flow passing each Carstate in loop by subFlow() function and in second flow, we can do the creation of newstate,Txn builder & Transaction finalization etc.
-
Write a single flow, which get all 2000 carstates and in loop inside the same flow create newstate, txn builder, txn finalisation steps etc.
I would like to know which one is the best way to do, Please help.
答案1
得分: 1
以上提到的两种方式之间没有太大的区别。所有的状态最终都会进入调用堆栈。
但是如果你担心OOM错误,你可能希望先检索车辆的ID,然后在循环内逐个获取每辆车的状态。这将减少内存开销。
英文:
There isn't much difference in both the ways mentioned above. All the states eventually will end up on the call stack anyway.
But if you are worried about OOM errors, you might want to retrieve the IDs of the cars first, then fetch each car state one by one inside a loop. This would reduce the memory over head.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论