Does batching writes support multiple writing values of the same key? #5229
bh4rtp2023
started this conversation in
General
Replies: 1 comment
-
|
Yes, this is supported, but with an important caveat. Within a single transaction, Fabric only keeps one write per key in the write-set. If your batch logic updates the same key multiple times, each PutState simply overwrites the previous value in memory, and only the final value is committed when the transaction is validated. So this works fine as long as you don’t rely on intermediate values being persisted. If you need to preserve multiple updates, you’ll need to encode them into the value, use separate (for example, composite) keys, or compute the final value first and write once. Hope that helps — happy to clarify if needed. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am doing a batch chaincode writes. In some of these batching writes, it needs to update values of the same key.
Is this supported by batching chaincode writes feature? Thanks.
Beta Was this translation helpful? Give feedback.
All reactions