[bisq-network/bisq] Dao fix reorg issues (#2056)

Manfred Karrer notifications at github.com
Wed Dec 5 16:52:15 UTC 2018

ManfredKarrer commented on this pull request.

> +        }
+        try {
+            Block block = blockParser.parseBlock(rawBlock);
+            if (pendingBlocks.contains(rawBlock))
+                pendingBlocks.remove(rawBlock);
+            // After parsing we check if we have pending blocks we might have received earlier but which have been
+            // not connecting from the latest height we had. The list is sorted by height
+            if (!pendingBlocks.isEmpty()) {
+                // To avoid ConcurrentModificationException we copy the list. It might be altered in the method call
+                ArrayList<RawBlock> tempPendingBlocks = new ArrayList<>(pendingBlocks);
+                for (RawBlock tempPendingBlock : tempPendingBlocks) {
+                    try {
+                        doParseBlock(tempPendingBlock);

Yes right I think that is wrong. It would iterate multiple times with lists which have been already applied. E.g. if you have 5 items and first recursive call copies the list then removes the current block from the source list and then copy the list again and start another loop with 4 itmes. Once that recursion is done the parent recursion would still iterate the remaining elements but those have been already processed. So either we add a check there if the block is still in the source list or we dont use a loop but only call with the first element (list is sorted) and so we avoid the remaining iterations from the current loop. 
What do you think? 

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20181205/0cd9a978/attachment.html>

More information about the bisq-github mailing list