forked from Qortal/qortal
Install initial peers when creating repository
This commit is contained in:
parent
6feca1f4d6
commit
ad9b42dc5d
@ -25,6 +25,8 @@ import org.eclipse.persistence.exceptions.XMLMarshalException;
|
|||||||
import org.eclipse.persistence.jaxb.JAXBContextFactory;
|
import org.eclipse.persistence.jaxb.JAXBContextFactory;
|
||||||
import org.eclipse.persistence.jaxb.UnmarshallerProperties;
|
import org.eclipse.persistence.jaxb.UnmarshallerProperties;
|
||||||
import org.qora.data.block.BlockData;
|
import org.qora.data.block.BlockData;
|
||||||
|
import org.qora.data.network.BlockSummaryData;
|
||||||
|
import org.qora.network.Network;
|
||||||
import org.qora.repository.BlockRepository;
|
import org.qora.repository.BlockRepository;
|
||||||
import org.qora.repository.DataException;
|
import org.qora.repository.DataException;
|
||||||
import org.qora.repository.Repository;
|
import org.qora.repository.Repository;
|
||||||
@ -339,6 +341,9 @@ public class BlockChain {
|
|||||||
genesisBlock.process();
|
genesisBlock.process();
|
||||||
|
|
||||||
repository.saveChanges();
|
repository.saveChanges();
|
||||||
|
|
||||||
|
// Give Network a change to install initial seed peers
|
||||||
|
Network.installInitialPeers(repository);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,6 +55,8 @@ public class Network extends Thread {
|
|||||||
/** Maximum time since last successful connection for peer info to be propagated, in milliseconds. */
|
/** Maximum time since last successful connection for peer info to be propagated, in milliseconds. */
|
||||||
private static final long RECENT_CONNECTION_THRESHOLD = 24 * 60 * 60 * 1000; // ms
|
private static final long RECENT_CONNECTION_THRESHOLD = 24 * 60 * 60 * 1000; // ms
|
||||||
|
|
||||||
|
private static final String[] INITIAL_PEERS = new String[] { "node1.qora.org", "node2.qora.org" };
|
||||||
|
|
||||||
public static final int MAX_SIGNATURES_PER_REPLY = 500;
|
public static final int MAX_SIGNATURES_PER_REPLY = 500;
|
||||||
public static final int MAX_BLOCK_SUMMARIES_PER_REPLY = 500;
|
public static final int MAX_BLOCK_SUMMARIES_PER_REPLY = 500;
|
||||||
public static final int PEER_ID_LENGTH = 128;
|
public static final int PEER_ID_LENGTH = 128;
|
||||||
@ -143,6 +145,19 @@ public class Network extends Thread {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initial setup
|
||||||
|
|
||||||
|
public static void installInitialPeers(Repository repository) throws DataException {
|
||||||
|
for (String address : INITIAL_PEERS) {
|
||||||
|
PeerAddress peerAddress = PeerAddress.fromString(address);
|
||||||
|
|
||||||
|
PeerData peerData = new PeerData(peerAddress);
|
||||||
|
repository.getNetworkRepository().save(peerData);
|
||||||
|
}
|
||||||
|
|
||||||
|
repository.saveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
// Main thread
|
// Main thread
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user