Search in sources :

Example 1 with NetworkParams

use of snowblossom.lib.NetworkParams in project snowblossom by snowblossomcoin.

the class BlockIngestorTest method testFirstBlockSummary.

@Test
public void testFirstBlockSummary() {
    NetworkParams params = new NetworkParamsTestnet();
    BlockHeader header = BlockHeader.newBuilder().setTarget(BlockchainUtil.targetBigIntegerToBytes(params.getMaxTarget())).setTimestamp(System.currentTimeMillis()).build();
    BlockSummary prev_summary;
    prev_summary = BlockSummary.newBuilder().build();
    System.out.println(prev_summary);
    BlockSummary s = BlockchainUtil.getNewSummary(header, prev_summary, params, 1L, 600L, new LinkedList());
    Assert.assertNotNull(s.getHeader());
    Assert.assertEquals("1024", s.getWorkSum());
    Assert.assertEquals(params.getMaxTarget().toString(), s.getTargetAverage());
    Assert.assertEquals(params.getBlockTimeTarget(), s.getBlocktimeAverageMs());
}
Also used : NetworkParamsTestnet(snowblossom.lib.NetworkParamsTestnet) NetworkParams(snowblossom.lib.NetworkParams) BlockHeader(snowblossom.proto.BlockHeader) BlockSummary(snowblossom.proto.BlockSummary) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 2 with NetworkParams

use of snowblossom.lib.NetworkParams in project snowblossom by snowblossomcoin.

the class SpoonTest method startMrPlow.

protected MrPlow startMrPlow(List<Integer> node_ports, AddressSpecHash pool_addr, String network) throws Exception {
    NetworkParams params = NetworkParams.loadFromName(network);
    String plow_db_path = test_folder.newFolder().getPath();
    Map<String, String> config_map = new TreeMap<>();
    StringBuilder uris = new StringBuilder();
    boolean first = true;
    for (int port : node_ports) {
        if (!first)
            uris.append(",");
        uris.append("grpc://localhost:" + port + "/");
        first = false;
    }
    config_map.put("node_uri", uris.toString());
    config_map.put("db_type", "rocksdb");
    config_map.put("db_type", "atomic_file");
    config_map.put("db_path", plow_db_path + "/plowdb");
    config_map.put("pool_fee", "0.01");
    config_map.put("pool_address", pool_addr.toAddressString(params));
    config_map.put("mining_pool_port", "0");
    config_map.put("tls_mining_pool_port", "0");
    config_map.put("tls_key_path", plow_db_path + "/plow_tls");
    config_map.put("network", network);
    config_map.put("min_diff", "11");
    return new MrPlow(new ConfigMem(config_map));
}
Also used : NetworkParams(snowblossom.lib.NetworkParams) MrPlow(snowblossom.miner.plow.MrPlow) ByteString(com.google.protobuf.ByteString) ConfigMem(duckutil.ConfigMem)

Example 3 with NetworkParams

use of snowblossom.lib.NetworkParams in project snowblossom by snowblossomcoin.

the class SpoonTest method startPoolMiner.

protected PoolMiner startPoolMiner(int port, AddressSpecHash mine_to, File snow_path, String network) throws Exception {
    NetworkParams params = NetworkParams.loadFromName(network);
    String addr = mine_to.toAddressString(params);
    System.out.println("Starting miner with " + addr);
    Map<String, String> config_map = new TreeMap<>();
    config_map.put("pool_host", "localhost");
    config_map.put("pool_port", "" + port);
    config_map.put("threads", "1");
    config_map.put("mine_to_address", addr);
    config_map.put("snow_path", snow_path.getPath());
    config_map.put("network", network);
    config_map.put("rate_limit", "10000.0");
    if (port % 2 == 1) {
        config_map.put("memfield", "true");
    }
    return new PoolMiner(new ConfigMem(config_map));
}
Also used : PoolMiner(snowblossom.miner.PoolMiner) NetworkParams(snowblossom.lib.NetworkParams) ByteString(com.google.protobuf.ByteString) ConfigMem(duckutil.ConfigMem)

Example 4 with NetworkParams

use of snowblossom.lib.NetworkParams in project snowblossom by snowblossomcoin.

the class SpoonTest method startMiner.

protected SnowBlossomMiner startMiner(int port, AddressSpecHash mine_to, File snow_path, String network) throws Exception {
    Map<String, String> config_map = new TreeMap<>();
    config_map.put("node_host", "localhost");
    config_map.put("node_port", "" + port);
    config_map.put("threads", "1");
    config_map.put("snow_path", snow_path.getPath());
    config_map.put("network", network);
    NetworkParams params = NetworkParams.loadFromConfig(new ConfigMem(config_map));
    config_map.put("mine_to_address", mine_to.toAddressString(params));
    config_map.put("rate_limit", "10000.0");
    if (port % 2 == 1) {
        config_map.put("memfield", "true");
    }
    return new SnowBlossomMiner(new ConfigMem(config_map));
}
Also used : SnowBlossomMiner(snowblossom.miner.SnowBlossomMiner) NetworkParams(snowblossom.lib.NetworkParams) ByteString(com.google.protobuf.ByteString) ConfigMem(duckutil.ConfigMem)

Example 5 with NetworkParams

use of snowblossom.lib.NetworkParams in project snowblossom by snowblossomcoin.

the class SpoonTest method startPoolMinerUri.

protected PoolMiner startPoolMinerUri(String uri, AddressSpecHash mine_to, File snow_path, String network) throws Exception {
    NetworkParams params = NetworkParams.loadFromName(network);
    String addr = mine_to.toAddressString(params);
    System.out.println("Starting miner with " + addr);
    Map<String, String> config_map = new TreeMap<>();
    config_map.put("pool_uri", uri);
    config_map.put("threads", "1");
    config_map.put("mine_to_address", addr);
    config_map.put("snow_path", snow_path.getPath());
    config_map.put("network", network);
    config_map.put("rate_limit", "10000.0");
    return new PoolMiner(new ConfigMem(config_map));
}
Also used : PoolMiner(snowblossom.miner.PoolMiner) NetworkParams(snowblossom.lib.NetworkParams) ByteString(com.google.protobuf.ByteString) ConfigMem(duckutil.ConfigMem)

Aggregations

NetworkParams (snowblossom.lib.NetworkParams)16 Test (org.junit.Test)11 NetworkParamsRegtest (snowblossom.lib.NetworkParamsRegtest)8 ByteString (com.google.protobuf.ByteString)6 BigInteger (java.math.BigInteger)6 ConfigMem (duckutil.ConfigMem)5 LinkedList (java.util.LinkedList)3 NetworkParamsTestnet (snowblossom.lib.NetworkParamsTestnet)3 BlockHeader (snowblossom.proto.BlockHeader)3 NetworkParamsProd (snowblossom.lib.NetworkParamsProd)2 PoolMiner (snowblossom.miner.PoolMiner)2 BlockSummary (snowblossom.proto.BlockSummary)2 ImmutableList (com.google.common.collect.ImmutableList)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Random (java.util.Random)1 AddressSpecHash (snowblossom.lib.AddressSpecHash)1 SnowFall (snowblossom.lib.SnowFall)1 SnowFieldInfo (snowblossom.lib.SnowFieldInfo)1