mirror of
https://github.com/ChronosX88/Influence-Bootstrap-Node.git
synced 2024-11-21 15:02:17 +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
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/out
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
/out/
|
||||
/build/
|
||||
/.idea/
|
@ -7,17 +7,40 @@ import net.tomp2p.p2p.PeerBuilder;
|
||||
import net.tomp2p.peers.Number160;
|
||||
import net.tomp2p.storage.StorageDisk;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Main {
|
||||
private static PeerDHT peerDHT;
|
||||
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) {
|
||||
//TODO: Save peerID and route table to config
|
||||
peerID = Number160.createHash(UUID.randomUUID().toString());
|
||||
props = new Properties();
|
||||
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 {
|
||||
peerDHT =
|
||||
new PeerBuilderDHT(new PeerBuilder(peerID).ports(7243).start())
|
||||
|
Loading…
Reference in New Issue
Block a user