mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-13 02:35:52 +00:00
Avoid trying to resolve dependencies of newly solved orphan blocks when we are still downloading headers.
This commit is contained in:
parent
a837bd2885
commit
049baad8c6
@ -672,7 +672,13 @@ public class Peer {
|
|||||||
// chain twice (or more!) on the same connection! The block chain would filter out the duplicates but
|
// chain twice (or more!) on the same connection! The block chain would filter out the duplicates but
|
||||||
// only at a huge speed penalty. By finding the orphan root we ensure every getblocks looks the same
|
// only at a huge speed penalty. By finding the orphan root we ensure every getblocks looks the same
|
||||||
// no matter how many blocks are solved, and therefore that the (2) duplicate filtering can work.
|
// no matter how many blocks are solved, and therefore that the (2) duplicate filtering can work.
|
||||||
|
//
|
||||||
|
// We only do this if we are not currently downloading headers. If we are then we don't want to kick
|
||||||
|
// off a request for lots more headers in parallel.
|
||||||
|
if (downloadBlockBodies)
|
||||||
blockChainDownload(blockChain.getOrphanRoot(m.getHash()).getHash());
|
blockChainDownload(blockChain.getOrphanRoot(m.getHash()).getHash());
|
||||||
|
else
|
||||||
|
log.info("Did not start chain download on solved block due to in-flight header download.");
|
||||||
}
|
}
|
||||||
} catch (VerificationException e) {
|
} catch (VerificationException e) {
|
||||||
// We don't want verification failures to kill the thread.
|
// We don't want verification failures to kill the thread.
|
||||||
@ -827,8 +833,9 @@ public class Peer {
|
|||||||
// disk IO to figure out what we've got. Normally peers will not send us inv for things we already have
|
// disk IO to figure out what we've got. Normally peers will not send us inv for things we already have
|
||||||
// so we just re-request it here, and if we get duplicates the block chain / wallet will filter them out.
|
// so we just re-request it here, and if we get duplicates the block chain / wallet will filter them out.
|
||||||
for (InventoryItem item : blocks) {
|
for (InventoryItem item : blocks) {
|
||||||
if (blockChain.isOrphan(item.hash)) {
|
if (blockChain.isOrphan(item.hash) && downloadBlockBodies) {
|
||||||
// If an orphan was re-advertised, ask for more blocks.
|
// If an orphan was re-advertised, ask for more blocks unless we are not currently downloading
|
||||||
|
// full block data because we have a getheaders outstanding.
|
||||||
blockChainDownload(blockChain.getOrphanRoot(item.hash).getHash());
|
blockChainDownload(blockChain.getOrphanRoot(item.hash).getHash());
|
||||||
} else {
|
} else {
|
||||||
// Don't re-request blocks we already requested. Normally this should not happen. However there is
|
// Don't re-request blocks we already requested. Normally this should not happen. However there is
|
||||||
@ -958,8 +965,6 @@ public class Peer {
|
|||||||
private Sha256Hash lastGetBlocksBegin, lastGetBlocksEnd;
|
private Sha256Hash lastGetBlocksBegin, lastGetBlocksEnd;
|
||||||
|
|
||||||
private synchronized void blockChainDownload(Sha256Hash toHash) throws IOException {
|
private synchronized void blockChainDownload(Sha256Hash toHash) throws IOException {
|
||||||
// This may run in ANY thread.
|
|
||||||
|
|
||||||
// The block chain download process is a bit complicated. Basically, we start with one or more blocks in a
|
// The block chain download process is a bit complicated. Basically, we start with one or more blocks in a
|
||||||
// chain that we have from a previous session. We want to catch up to the head of the chain BUT we don't know
|
// chain that we have from a previous session. We want to catch up to the head of the chain BUT we don't know
|
||||||
// where that chain is up to or even if the top block we have is even still in the chain - we
|
// where that chain is up to or even if the top block we have is even still in the chain - we
|
||||||
|
Loading…
x
Reference in New Issue
Block a user