子流程与单流程调用在迁移2000个状态时的比较。

huangapple go评论49阅读模式
英文:

Subflow versus single flow calling while migration of 2000 states

问题

  1. 编写两个流程,第一个流程获取所有 2000 个 CarState 并通过 subFlow() 函数逐个传递每个 CarState,第二个流程中可以进行新状态、交易构建器和交易完成等操作。

  2. 编写一个单一流程,在同一个流程中获取所有 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:

  1. 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.

  2. 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.

huangapple
  • 本文由 发表于 2023年3月9日 18:52:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/75683599.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定