[bisq-network/bisq] Request blocks in case we have not received it (#2730)

sqrrm notifications at github.com
Wed Apr 17 11:24:52 UTC 2019


sqrrm requested changes on this pull request.

I think it would be better to ask for the first block we don't have rather than the last block we have.

> +            if (!daoStateService.isParseBlockChainComplete())
+                return;
+
+            if (checkForBlockReceivedTimer != null) {
+                // In case we received a new block before out timer gets called we stop the old timer
+                checkForBlockReceivedTimer.stop();
+            }
+
+            // We expect to receive the new BSQ block from the network shortly after BitcoinJ has been aware of it.
+            // If we don't receive it we request it manually from seed nodes
+            checkForBlockReceivedTimer = UserThread.runAfter(() -> {
+                if (daoStateService.getChainHeight() < height) {
+                    log.warn("We did not receive a block from the network {} seconds after we saw the new block in BicoinJ. " +
+                                    "We request from our seed nodes missing blocks from block height {}.",
+                            CHECK_FOR_BLOCK_RECEIVED_DELAY_SEC, daoStateService.getChainHeight());
+                    liteNodeNetworkService.requestBlocks(daoStateService.getChainHeight());

This means we're asking for block `daoStateService.getChainHeight()` and up, but we already have the block at `daoStateService.getChainHeight()`, wouldn't it be better to ask for `daoStateService.getChainHeight() + 1`?

It's also only asking seednodes, any full node should be fine to ask and then we can use the block hash to verify we have the right blocks, and if not we block that ban that full node and ask the next. That's not really relevant to this PR though.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/2730#pullrequestreview-227693787
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20190417/1b7e381a/attachment.html>


More information about the bisq-github mailing list