Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atomic.transformAndExtract fails to compare case class #1644

Open
pragmaxim opened this issue Sep 23, 2022 · 0 comments
Open

Atomic.transformAndExtract fails to compare case class #1644

pragmaxim opened this issue Sep 23, 2022 · 0 comments

Comments

@pragmaxim
Copy link

pragmaxim commented Sep 23, 2022

case class BlockCache(byId: Map[BlockId, BlockInfo], byHeight: SortedMap[Int, BlockInfo])
case class ProgressState(
  lastBlockIdInEpoch: SortedMap[Int, BlockId],
  invalidEpochs: SortedMap[Int, InvalidEpochCandidate],
  blockCache: BlockCache
)
      val x = 
        stateRef.transformAndExtract { state =>
          val (e, newState) = state.update(withSomeThingThatDefinitelyChangesTheState)
          if (state != newState)
            logger.info(s"$e, $newState")
          else
            logger.info(s"It is the same $e, $newState") /// NEVER CALLED
          (e, newState)
        }
      logger.info(s"HAAAAAAAAAAAAAAAAAAAA")
      x

Now the callback executes multiple times even though the state is always different, update operation is simple, referentially transparent method running only on current thread.

New epoch 69 created, persisted Epochs: 70[0 - 69], blocks cache size (heights): 1124[1024 - 71712], invalid Epochs: 0
New epoch 69 created, persisted Epochs: 70[0 - 69], blocks cache size (heights): 1130[1024 - 71718], invalid Epochs: 0
New epoch 69 created, persisted Epochs: 70[0 - 69], blocks cache size (heights): 1132[1024 - 71720], invalid Epochs: 0
New epoch 69 created, persisted Epochs: 70[0 - 69], blocks cache size (heights): 1133[1024 - 71721], invalid Epochs: 0
New epoch 69 created, persisted Epochs: 70[0 - 69], blocks cache size (heights): 1134[1024 - 71722], invalid Epochs: 0
New epoch 69 created, persisted Epochs: 70[0 - 69], blocks cache size (heights): 1136[1024 - 71724], invalid Epochs: 0
New epoch 69 created, persisted Epochs: 70[0 - 69], blocks cache size (heights): 1137[1024 - 71725], invalid Epochs: 0
New epoch 69 created, persisted Epochs: 70[0 - 69], blocks cache size (heights): 1139[1024 - 71727], invalid Epochs: 0
New epoch 69 created, persisted Epochs: 70[0 - 69], blocks cache size (heights): 1140[1024 - 71728], invalid Epochs: 0
New epoch 69 created, persisted Epochs: 70[0 - 69], blocks cache size (heights): 1141[1024 - 71729], invalid Epochs: 0
HAAAAAAAAAAAAAAAAAAAA
New epoch 70 created, persisted Epochs: 71[0 - 70], blocks cache size (heights): 1124[1024 - 72736], invalid Epochs: 0
New epoch 70 created, persisted Epochs: 71[0 - 70], blocks cache size (heights): 1127[1024 - 72739], invalid Epochs: 0
New epoch 70 created, persisted Epochs: 71[0 - 70], blocks cache size (heights): 1129[1024 - 72741], invalid Epochs: 0
New epoch 70 created, persisted Epochs: 71[0 - 70], blocks cache size (heights): 1131[1024 - 72743], invalid Epochs: 0
New epoch 70 created, persisted Epochs: 71[0 - 70], blocks cache size (heights): 1132[1024 - 72744], invalid Epochs: 0
New epoch 70 created, persisted Epochs: 71[0 - 70], blocks cache size (heights): 1134[1024 - 72746], invalid Epochs: 0
New epoch 70 created, persisted Epochs: 71[0 - 70], blocks cache size (heights): 1135[1024 - 72747], invalid Epochs: 0
New epoch 70 created, persisted Epochs: 71[0 - 70], blocks cache size (heights): 1137[1024 - 72749], invalid Epochs: 0
New epoch 70 created, persisted Epochs: 71[0 - 70], blocks cache size (heights): 1139[1024 - 72751], invalid Epochs: 0
New epoch 70 created, persisted Epochs: 71[0 - 70], blocks cache size (heights): 1141[1024 - 72753], invalid Epochs: 0
HAAAAAAAAAAAAAAAAAAAA```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant