mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-14 11:15:51 +00:00
Quick hack to not crash when connected to a node that has less of the chain than we do. Real fix must wait for PeerGroup to land. Resolves issue 44.
This commit is contained in:
parent
ea8cbd7465
commit
1a4e2e67d1
@ -327,9 +327,14 @@ public class Peer {
|
||||
if (chainHeight <= 0) {
|
||||
// This should not happen because we shouldn't have given the user a Peer that is to another client-mode
|
||||
// node. If that happens it means the user overrode us somewhere.
|
||||
throw new RuntimeException("Peer does not have block chain");
|
||||
throw new RuntimeException("Peer does not have block chain");
|
||||
}
|
||||
int blocksToGet = chainHeight - blockChain.getChainHead().getHeight();
|
||||
if (blocksToGet < 0) {
|
||||
// This peer has fewer blocks than we do. It isn't usable.
|
||||
// TODO: We can't do the right thing here until Mirons patch lands. For now just return a zero latch.
|
||||
return new CountDownLatch(0);
|
||||
}
|
||||
chainCompletionLatch = new CountDownLatch(blocksToGet);
|
||||
if (blocksToGet > 0) {
|
||||
// When we just want as many blocks as possible, we can set the target hash to zero.
|
||||
|
Loading…
x
Reference in New Issue
Block a user