mirror of
https://github.com/ChronosX88/Influence-Bootstrap-Node.git
synced 2024-11-22 07:12:20 +00:00
Added config file to store peerID and modified .gitignore
This commit is contained in:
parent
b903f9cc63
commit
55d1b62cfe
16
.gitignore
vendored
16
.gitignore
vendored
@ -1,13 +1,3 @@
|
|||||||
*.iml
|
/out/
|
||||||
.gradle
|
/build/
|
||||||
/local.properties
|
/.idea/
|
||||||
/.idea/caches
|
|
||||||
/.idea/libraries
|
|
||||||
/.idea/modules.xml
|
|
||||||
/.idea/workspace.xml
|
|
||||||
/.idea/navEditor.xml
|
|
||||||
/.idea/assetWizardSettings.xml
|
|
||||||
.DS_Store
|
|
||||||
/out
|
|
||||||
/captures
|
|
||||||
.externalNativeBuild
|
|
@ -7,17 +7,40 @@ import net.tomp2p.p2p.PeerBuilder;
|
|||||||
import net.tomp2p.peers.Number160;
|
import net.tomp2p.peers.Number160;
|
||||||
import net.tomp2p.storage.StorageDisk;
|
import net.tomp2p.storage.StorageDisk;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.IOException;
|
import java.util.Properties;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
private static PeerDHT peerDHT;
|
private static PeerDHT peerDHT;
|
||||||
private static Number160 peerID;
|
private static Number160 peerID;
|
||||||
|
private static Properties props;
|
||||||
|
private static final String DATA_DIR_PATH = System.getProperty("user.home") + "/.local/share/Influence-Bootstrap/";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
//TODO: Save peerID and route table to config
|
props = new Properties();
|
||||||
peerID = Number160.createHash(UUID.randomUUID().toString());
|
File dataDir = new File(DATA_DIR_PATH);
|
||||||
|
File config = new File(DATA_DIR_PATH + "config.properties");
|
||||||
|
try {
|
||||||
|
if(!dataDir.exists() && !config.exists()) {
|
||||||
|
dataDir.mkdir();
|
||||||
|
config.createNewFile();
|
||||||
|
props.setProperty("isFirstRun", "false");
|
||||||
|
props.setProperty("peerID", UUID.randomUUID().toString());
|
||||||
|
props.store(new FileWriter(config), "");
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
|
props.load(new FileInputStream(config));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
peerID = Number160.createHash(props.getProperty("peerID"));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
peerDHT =
|
peerDHT =
|
||||||
new PeerBuilderDHT(new PeerBuilder(peerID).ports(7243).start())
|
new PeerBuilderDHT(new PeerBuilder(peerID).ports(7243).start())
|
||||||
|
Loading…
Reference in New Issue
Block a user