use of duckutil.ConfigMem in project snowblossom by snowblossomcoin.
the class SpoonTest method setupSnow.
protected File setupSnow(String network) throws Exception {
TreeMap<String, String> config_map = new TreeMap<>();
config_map.put("network", network);
NetworkParams params = NetworkParams.loadFromConfig(new ConfigMem(config_map));
String test_folder_base = test_folder.newFolder().getPath();
File snow_path = new File(test_folder.newFolder(), "snow");
for (int i = 0; i < 4; i++) {
SnowFieldInfo info = params.getSnowFieldInfo(i);
String name = network + "." + i;
File field_path = new File(snow_path, name);
field_path.mkdirs();
File field = new File(field_path, name + ".snow");
new SnowFall(field.getPath(), name, info.getLength());
ByteString root_hash = new SnowMerkle(field_path, name, true).getRootHash();
Assert.assertEquals(info.getMerkleRootHash(), root_hash);
}
return snow_path;
}
use of duckutil.ConfigMem in project snowblossom by snowblossomcoin.
the class SpoonTest method startClient.
protected SnowBlossomClient startClient(int port) throws Exception {
Map<String, String> config_map = new TreeMap<>();
config_map.put("node_uri", "grpc://localhost:" + port);
config_map.put("network", "spoon");
return new SnowBlossomClient(new ConfigMem(config_map));
}
use of duckutil.ConfigMem in project snowblossom by snowblossomcoin.
the class DataMigrate method main.
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.out.println("Expected parameters:");
System.out.println("DataMigrate <rocksdb_path> <atomic_file_path>");
System.exit(1);
}
Globals.addCryptoProvider();
String rocksdb_path = args[0];
String atomic_file_path = args[1];
System.out.println("Migrating data from rocksdb: " + rocksdb_path);
System.out.println("Migrating data to atomic file db: " + atomic_file_path);
DB src = null;
DB dst = null;
{
TreeMap<String, String> config_map = new TreeMap<>();
config_map.put("db_path", rocksdb_path);
Config config = new ConfigMem(config_map);
src = new DB(config, new JRocksDB(config));
}
{
TreeMap<String, String> config_map = new TreeMap<>();
config_map.put("db_path", atomic_file_path);
Config config = new ConfigMem(config_map);
dst = new DB(config, new AtomicFileDB(config));
}
if (src.getSpecialMap().get(MrPlow.PPLNS_STATE_KEY) == null) {
logger.severe("Source does not have PPLNS State. Aborting");
System.exit(1);
}
if (dst.getSpecialMap().get(MrPlow.PPLNS_STATE_KEY) != null) {
logger.severe("Destination already has PPLNS State. Aborting");
System.exit(1);
}
PPLNSState pplns_state = PPLNSState.parseFrom(src.getSpecialMap().get(MrPlow.PPLNS_STATE_KEY));
logger.info(String.format("Have source PPLNS state with %d entries", pplns_state.getShareEntriesCount()));
List<ByteString> lst = src.getSpecialMapSet().getSet(MrPlow.BLOCK_KEY, 100000);
for (ByteString bs : lst) {
dst.getSpecialMapSet().add(MrPlow.BLOCK_KEY, bs);
}
logger.info("Saved found block list: " + lst.size());
// Saving state
dst.getSpecialMap().put(MrPlow.PPLNS_STATE_KEY, pplns_state.toByteString());
logger.info("PPLNS state saved");
logger.info("Migration complete");
}
Aggregations