Search in sources :

Example 16 with ConfigMem

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;
}
Also used : SnowMerkle(snowblossom.lib.SnowMerkle) SnowFieldInfo(snowblossom.lib.SnowFieldInfo) ByteString(com.google.protobuf.ByteString) NetworkParams(snowblossom.lib.NetworkParams) SnowFall(snowblossom.lib.SnowFall) ByteString(com.google.protobuf.ByteString) ConfigMem(duckutil.ConfigMem) File(java.io.File)

Example 17 with ConfigMem

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));
}
Also used : SnowBlossomClient(snowblossom.client.SnowBlossomClient) ByteString(com.google.protobuf.ByteString) ConfigMem(duckutil.ConfigMem)

Example 18 with ConfigMem

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");
}
Also used : Config(duckutil.Config) ByteString(com.google.protobuf.ByteString) JRocksDB(snowblossom.lib.db.rocksdb.JRocksDB) ByteString(com.google.protobuf.ByteString) TreeMap(java.util.TreeMap) AtomicFileDB(snowblossom.lib.db.atomicfile.AtomicFileDB) ConfigMem(duckutil.ConfigMem) DB(snowblossom.lib.db.DB) AtomicFileDB(snowblossom.lib.db.atomicfile.AtomicFileDB) JRocksDB(snowblossom.lib.db.rocksdb.JRocksDB) LobstackDB(snowblossom.lib.db.lobstack.LobstackDB)

Aggregations

ConfigMem (duckutil.ConfigMem)18 ByteString (com.google.protobuf.ByteString)12 TreeMap (java.util.TreeMap)8 File (java.io.File)6 Test (org.junit.Test)5 NetworkParams (snowblossom.lib.NetworkParams)5 Purse (snowblossom.client.Purse)3 SnowBlossomClient (snowblossom.client.SnowBlossomClient)3 Config (duckutil.Config)2 TaskMaster (duckutil.TaskMaster)2 HashSet (java.util.HashSet)2 Callable (java.util.concurrent.Callable)2 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)2 NetworkParamsRegtest (snowblossom.lib.NetworkParamsRegtest)2 PoolMiner (snowblossom.miner.PoolMiner)2 SnowBlossomNode (snowblossom.node.SnowBlossomNode)2 AtomicFileOutputStream (duckutil.AtomicFileOutputStream)1 ConfigCat (duckutil.ConfigCat)1 ConfigFile (duckutil.ConfigFile)1 FileOutputStream (java.io.FileOutputStream)1