Changed database and dump location to sdcard with internal memory backup.
This commit is contained in:
parent
3fc6455c0e
commit
86eec731d6
|
@ -2,6 +2,7 @@ package org.ethereum.android_app;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Environment;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
|
@ -12,6 +13,9 @@ import android.view.MenuItem;
|
|||
import android.os.Build;
|
||||
|
||||
import org.ethereum.android.EthereumManager;
|
||||
import org.ethereum.config.SystemProperties;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
||||
public class MainActivity extends ActionBarActivity {
|
||||
|
@ -35,7 +39,15 @@ public class MainActivity extends ActionBarActivity {
|
|||
toolbar = (Toolbar) findViewById(R.id.tool_bar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
ethereumManager = new EthereumManager(this);
|
||||
String databaseFolder = null;
|
||||
File extStore = Environment.getExternalStorageDirectory();
|
||||
if (extStore.exists()) {
|
||||
databaseFolder = extStore.getAbsolutePath();
|
||||
} else {
|
||||
databaseFolder = getApplicationInfo().dataDir;
|
||||
}
|
||||
|
||||
ethereumManager = new EthereumManager(this, databaseFolder);
|
||||
|
||||
adapter = new TabsPagerAdapter(getSupportFragmentManager(), ethereumManager);
|
||||
viewPager = (ViewPager) findViewById(R.id.pager);
|
||||
|
@ -100,7 +112,7 @@ public class MainActivity extends ActionBarActivity {
|
|||
Log.v(TAG, "111");
|
||||
|
||||
Log.v(TAG, "222");
|
||||
long duration = ethereumManager.connect();
|
||||
long duration = ethereumManager.connect(SystemProperties.CONFIG.databaseDir() + File.separator + "poc-9-492k.dmp");
|
||||
//ConsoleFragment consoleeFrag = (ConsoleFragment)getSupportFragmentManager().findFragmentById(R.id.console);
|
||||
//consoleeFrag.updateDuration(duration);
|
||||
Log.v(TAG, "333");
|
||||
|
|
|
@ -9,12 +9,11 @@ import org.ethereum.android.di.components.DaggerEthereumComponent;
|
|||
import org.ethereum.config.SystemProperties;
|
||||
import org.ethereum.facade.Ethereum;
|
||||
import org.ethereum.listener.EthereumListenerAdapter;
|
||||
import org.ethereum.android.manager.BlockLoader;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.ethereum.android.jsonrpc.JsonRpcServer;
|
||||
|
||||
import static org.ethereum.config.SystemProperties.CONFIG;
|
||||
|
||||
public class EthereumManager {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger("manager");
|
||||
|
@ -24,9 +23,16 @@ public class EthereumManager {
|
|||
private JsonRpcServer jsonRpcServer;
|
||||
|
||||
|
||||
public EthereumManager(Context context) {
|
||||
public EthereumManager(Context context, String databaseFolder) {
|
||||
|
||||
System.setProperty("sun.arch.data.model", "32");
|
||||
System.setProperty("leveldb.mmap", "false");
|
||||
|
||||
if (databaseFolder != null) {
|
||||
System.out.println("Database folder: " + databaseFolder);
|
||||
SystemProperties.CONFIG.setDataBaseDir(databaseFolder);
|
||||
}
|
||||
|
||||
ethereum = DaggerEthereumComponent.builder()
|
||||
.ethereumModule(new EthereumModule(context))
|
||||
.build().ethereum();
|
||||
|
@ -38,15 +44,16 @@ public class EthereumManager {
|
|||
|
||||
}
|
||||
|
||||
public long connect() {
|
||||
public long connect(String dumpFile) {
|
||||
|
||||
long duration = 0;
|
||||
if (CONFIG.blocksLoader().equals("")) {
|
||||
if (dumpFile == null) {
|
||||
ethereum.connect(SystemProperties.CONFIG.activePeerIP(),
|
||||
SystemProperties.CONFIG.activePeerPort(),
|
||||
SystemProperties.CONFIG.activePeerNodeid());
|
||||
} else {
|
||||
ethereum.getBlockLoader().loadBlocks();
|
||||
BlockLoader blockLoader = (BlockLoader)ethereum.getBlockLoader();
|
||||
blockLoader.loadBlocks(dumpFile);
|
||||
}
|
||||
return duration;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.j256.ormlite.stmt.DeleteBuilder;
|
|||
import com.j256.ormlite.support.ConnectionSource;
|
||||
import com.j256.ormlite.table.TableUtils;
|
||||
|
||||
import org.ethereum.config.SystemProperties;
|
||||
import org.ethereum.core.Block;
|
||||
import org.ethereum.core.TransactionReceipt;
|
||||
|
||||
|
@ -32,7 +33,7 @@ public class OrmLiteBlockStoreDatabase extends OrmLiteSqliteOpenHelper implement
|
|||
private Dao<TransactionReceiptVO, Integer> transactionDao = null;
|
||||
|
||||
public OrmLiteBlockStoreDatabase(Context context) {
|
||||
super(context, Environment.getExternalStorageDirectory().getAbsolutePath()
|
||||
super(context, SystemProperties.CONFIG.databaseDir()
|
||||
+ File.separator + DATABASE_NAME, null, DATABASE_VERSION);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,16 +29,15 @@ public class BlockLoader extends org.ethereum.manager.BlockLoader {
|
|||
super(blockchain);
|
||||
}
|
||||
|
||||
public void loadBlocks(){
|
||||
public void loadBlocks(String dumpFile){
|
||||
|
||||
String fileSrc = CONFIG.blocksLoader();
|
||||
try {
|
||||
long startTime = System.currentTimeMillis();
|
||||
FileInputStream inputStream = null;
|
||||
inputStream = new FileInputStream(fileSrc);
|
||||
inputStream = new FileInputStream(dumpFile);
|
||||
scanner = new Scanner(inputStream);
|
||||
|
||||
System.out.println("Loading blocks: " + fileSrc);
|
||||
System.out.println("Loading blocks: " + dumpFile);
|
||||
|
||||
while (scanner.hasNext()) {
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ samples.dir = samples
|
|||
database.reset = false
|
||||
|
||||
# place to save physical storage files
|
||||
database.dir = /mnt/sdcard
|
||||
database.dir = database
|
||||
|
||||
# this string is computed
|
||||
# to be eventually the address
|
||||
|
@ -198,5 +198,5 @@ blockchain.only=false
|
|||
# from a rlp lines
|
||||
# file and not for
|
||||
# the net
|
||||
blocks.loader=/mnt/sdcard/poc-9-492k.dmp
|
||||
blocks.loader=
|
||||
#E:\\temp\\_poc-9-blocks\\poc-9-492k_.dmp
|
||||
|
|
Loading…
Reference in New Issue