org.ethereum.config.SystemProperties Java Examples

The following examples show how to use org.ethereum.config.SystemProperties. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DbFlushManager.java    From nuls-v2 with MIT License 5 votes vote down vote up
public DbFlushManager(SystemProperties config, Set<DbSource> dbSources, AbstractCachedSource<byte[], byte[]> stateDbCache) {
    this.config = config;
    this.dbSources = dbSources;
    sizeThreshold = config.getConfig().getInt("cache.flush.writeCacheSize") * 1024L * 1024;
    commitsCountThreshold = config.getConfig().getInt("cache.flush.blocks");
    flushAfterSyncDone = config.getConfig().getBoolean("cache.flush.shortSyncFlush");
    this.stateDbCache = stateDbCache;
}
 
Example #2
Source File: DbFlushManager.java    From nuls with MIT License 5 votes vote down vote up
public DbFlushManager(SystemProperties config, Set<DbSource> dbSources, AbstractCachedSource<byte[], byte[]> stateDbCache) {
    this.config = config;
    this.dbSources = dbSources;
    sizeThreshold = config.getConfig().getInt("cache.flush.writeCacheSize") * 1024 * 1024;
    commitsCountThreshold = config.getConfig().getInt("cache.flush.blocks");
    flushAfterSyncDone = config.getConfig().getBoolean("cache.flush.shortSyncFlush");
    this.stateDbCache = stateDbCache;
}
 
Example #3
Source File: DatabaseImpl.java    From ethereumj with MIT License 5 votes vote down vote up
public DatabaseImpl(String name) {
    	// Initialize Database
        this.name = name;
		Options options = new Options();
		options.createIfMissing(true);
		options.compressionType(CompressionType.NONE);
		try {
			logger.debug("Opening database");
            File dbLocation = new File(System.getProperty("user.dir") + "/" +
                                       SystemProperties.CONFIG.databaseDir() + "/");
            File fileLocation = new File(dbLocation, name);

			if(SystemProperties.CONFIG.databaseReset()) {
				destroyDB(fileLocation);
			}

			logger.debug("Initializing new or existing database: '{}'", name);
			db = factory.open(fileLocation, options);
//			logger.debug("Showing database stats");
//			String stats = DATABASE.getProperty("leveldb.stats");
//			logger.debug(stats);

            if (logger.isTraceEnabled()){

                logger.trace("Dump for: {}", fileLocation.toString());
                DBIterator iter =  db.iterator();

                while(iter.hasNext()){
                    byte[] key   = iter.peekNext().getKey();
                    byte[] value = iter.peekNext().getValue();

                    logger.trace("key={}, value={}", Hex.toHexString(key), Hex.toHexString(value));
                    iter.next();
                }
            }
		} catch (IOException ioe) {
			logger.error(ioe.getMessage(), ioe);
			throw new RuntimeException("Can't initialize database");
		}		
	}
 
Example #4
Source File: StaticMessages.java    From ethereumj with MIT License 5 votes vote down vote up
private static String buildHelloAnnouncement() {
	String version = SystemProperties.CONFIG.projectVersion();
	String system = System.getProperty("os.name");
	if (system.contains(" "))
		system = system.substring(0, system.indexOf(" "));
	if (System.getProperty("java.vm.vendor").contains("Android"))
		system = "Android";
	String phrase = SystemProperties.CONFIG.helloPhrase();

	return String.format("Ethereum(J)/v%s/%s/%s/Java", version, phrase, system);
}
 
Example #5
Source File: StateSource.java    From nuls-v2 with MIT License 4 votes vote down vote up
public void setConfig(SystemProperties config) {
    int size = config.getConfig().getInt("cache.stateCacheSize");
    readCache.withMaxCapacity(size * 1024 * 1024 / 512); // 512 - approx size of a node
}
 
Example #6
Source File: PruneManager.java    From nuls-v2 with MIT License 4 votes vote down vote up
private PruneManager(SystemProperties config) {
    pruneBlocksCnt = config.databasePruneDepth();
}
 
Example #7
Source File: StateSource.java    From nuls with MIT License 4 votes vote down vote up
public void setConfig(SystemProperties config) {
    int size = config.getConfig().getInt("cache.stateCacheSize");
    readCache.withMaxCapacity(size * 1024 * 1024 / 512); // 512 - approx size of a node
}
 
Example #8
Source File: PruneManager.java    From nuls with MIT License 4 votes vote down vote up
private PruneManager(SystemProperties config) {
    pruneBlocksCnt = config.databasePruneDepth();
}
 
Example #9
Source File: ConnectionConsoleWindow.java    From ethereumj with MIT License 4 votes vote down vote up
/**
     * ERROR (exceptions) WARN (when something happens that's not supposed to)
     *                    INFO (wire output)
     *                    DEBUG (test/displaying intermediate values),
     *                    TRACE (start/end method)
     */
    public ConnectionConsoleWindow(ToolBar toolBar) {
        final ConnectionConsoleWindow thisConsole = this;
        this.toolBar = toolBar;

        java.net.URL url = ClassLoader.getSystemResource("ethereum-icon.png");
        Toolkit kit = Toolkit.getDefaultToolkit();
        Image img = kit.createImage(url);
        this.setIconImage(img);
        addCloseAction();

        JPanel cp = new JPanel(new BorderLayout());

        AbstractTokenMakerFactory atmf = (AbstractTokenMakerFactory) TokenMakerFactory.getDefaultInstance();
        atmf.putMapping("text/console", "org.ethereum.gui.ConsoleTokenMaker");

        textArea = new RSyntaxTextArea(16, 44);
        textArea.setSyntaxEditingStyle("text/console");
//        textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_LISP);
        textArea.setCodeFoldingEnabled(true);
        textArea.setAntiAliasingEnabled(true);

        changeStyleProgrammatically();
        RTextScrollPane sp = new RTextScrollPane(textArea);

        cp.add(sp);

        setContentPane(cp);
        setTitle("Connection Console");
//        setDefaultCloseOperation(EXIT_ON_CLOSE);
        pack();
        setLocation(802, 460);
        
        if (CONFIG.peerDiscovery())
            UIEthereumManager.ethereum.startPeerDiscovery();
		
        Thread t = new Thread() {
			public void run() {

                UIEthereumManager.ethereum.connect(SystemProperties.CONFIG.activePeerIP(),
                        SystemProperties.CONFIG.activePeerPort());
			}
		};

        UIEthereumManager.ethereum.getDefaultPeer().setPeerListener(this);
        t.start();
    }