Skip to content

Does foreach iterate over uncommitted ledger? #3926

Answered by achamayou
divneil-intel asked this question in Q&A
Discussion options

You must be logged in to vote

foreach(), like get() and put() operates on the current read version, which may or may not be committed by consensus. It is guaranteed that if the read version is rolled back, the subsequent transaction containing the foreach will also be rolled back. Or to put it another way, if the transaction containing the foreach commits, then the read version it resolved to must have also committed.

There is not a foreach equivalent to get_globally_committed() if that's what you mean, that would let a transaction iterate over a map at the latest know committed value on a node.

Note that using get_globally_committed() in the context of a write transaction is dangerous and will potentially lead to a s…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by divneil-intel
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants