Search in sources :

Example 1 with PoolMiner

use of snowblossom.miner.PoolMiner 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 2 with PoolMiner

use of snowblossom.miner.PoolMiner 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)

Example 3 with PoolMiner

use of snowblossom.miner.PoolMiner in project snowblossom by snowblossomcoin.

the class SpoonTestPool method spoonPoolTest.

@Test
public void spoonPoolTest() throws Exception {
    File snow_path = setupSnow();
    Random rnd = new Random();
    int port = 20000 + rnd.nextInt(30000);
    SnowBlossomNode node = startNode(port);
    Thread.sleep(2000);
    KeyPair key_pair = KeyUtil.generateECCompressedKey();
    AddressSpec claim = AddressUtil.getSimpleSpecForKey(key_pair.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
    AddressSpecHash to_addr = AddressUtil.getHashForSpec(claim);
    KeyPair key_pair2 = KeyUtil.generateECCompressedKey();
    AddressSpec claim2 = AddressUtil.getSimpleSpecForKey(key_pair2.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
    AddressSpecHash to_addr2 = AddressUtil.getHashForSpec(claim2);
    KeyPair key_pair3 = KeyUtil.generateECCompressedKey();
    AddressSpec claim3 = AddressUtil.getSimpleSpecForKey(key_pair3.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
    AddressSpecHash to_addr3 = AddressUtil.getHashForSpec(claim3);
    SnowBlossomClient client = startClient(port);
    MrPlow plow = startMrPlow(port, to_addr2);
    Thread.sleep(4000);
    PoolMiner miner = startPoolMiner(plow.getGrpcPort(), to_addr, snow_path);
    Thread.sleep(25000);
    waitForMoreBlocks(node, 10);
    System.out.println("ShareMap: " + plow.getShareManager().getShareMap());
    System.out.println("ShareMap pay: " + plow.getShareManager().getPayRatios());
    // Pool getting paid
    waitForFunds(client, to_addr2, 10);
    // Miner getting paid
    waitForFunds(client, to_addr, 30);
    PoolMiner miner2 = startPoolMiner(plow.getGrpcPort(), to_addr3, snow_path);
    // Second miner getting paid
    waitForFunds(client, to_addr3, 30);
    miner.stop();
    miner2.stop();
    Thread.sleep(500);
    plow.stop();
    node.stop();
}
Also used : PoolMiner(snowblossom.miner.PoolMiner) KeyPair(java.security.KeyPair) SnowBlossomNode(snowblossom.node.SnowBlossomNode) SnowBlossomClient(snowblossom.client.SnowBlossomClient) MrPlow(snowblossom.miner.plow.MrPlow) File(java.io.File) AddressSpecHash(snowblossom.lib.AddressSpecHash) Test(org.junit.Test)

Example 4 with PoolMiner

use of snowblossom.miner.PoolMiner in project snowblossom by snowblossomcoin.

the class SpoonTestPoolTls method spoonPoolTest.

@Test
public void spoonPoolTest() throws Exception {
    File snow_path = setupSnow();
    Random rnd = new Random();
    int port = 20000 + rnd.nextInt(30000);
    SnowBlossomNode node = startNode(port);
    Thread.sleep(2000);
    KeyPair key_pair = KeyUtil.generateECCompressedKey();
    AddressSpec claim = AddressUtil.getSimpleSpecForKey(key_pair.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
    AddressSpecHash to_addr = AddressUtil.getHashForSpec(claim);
    KeyPair key_pair2 = KeyUtil.generateECCompressedKey();
    AddressSpec claim2 = AddressUtil.getSimpleSpecForKey(key_pair2.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
    AddressSpecHash to_addr2 = AddressUtil.getHashForSpec(claim2);
    KeyPair key_pair3 = KeyUtil.generateECCompressedKey();
    AddressSpec claim3 = AddressUtil.getSimpleSpecForKey(key_pair3.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
    AddressSpecHash to_addr3 = AddressUtil.getHashForSpec(claim3);
    SnowBlossomClient client = startClient(port);
    MrPlow plow = startMrPlow(port, to_addr2);
    Thread.sleep(4000);
    String uri = "grpc+tls://localhost:" + plow.getGrpcTlsPort();
    PoolMiner miner = startPoolMinerUri(uri, to_addr, snow_path, "spoon");
    Thread.sleep(25000);
    waitForMoreBlocks(node, 10);
    System.out.println("ShareMap: " + plow.getShareManager().getShareMap());
    System.out.println("ShareMap pay: " + plow.getShareManager().getPayRatios());
    // Pool getting paid
    waitForFunds(client, to_addr2, 10);
    // Miner getting paid
    waitForFunds(client, to_addr, 30);
    String uri_key = uri + "/?key=" + plow.getTlsKeyId();
    PoolMiner miner2 = startPoolMinerUri(uri_key, to_addr3, snow_path, "spoon");
    // Second miner getting paid
    waitForFunds(client, to_addr3, 30);
    miner.stop();
    miner2.stop();
    Thread.sleep(500);
    plow.stop();
    node.stop();
}
Also used : PoolMiner(snowblossom.miner.PoolMiner) KeyPair(java.security.KeyPair) SnowBlossomNode(snowblossom.node.SnowBlossomNode) SnowBlossomClient(snowblossom.client.SnowBlossomClient) MrPlow(snowblossom.miner.plow.MrPlow) File(java.io.File) AddressSpecHash(snowblossom.lib.AddressSpecHash) Test(org.junit.Test)

Example 5 with PoolMiner

use of snowblossom.miner.PoolMiner in project snowblossom by snowblossomcoin.

the class ShardTestPlow method shardTest.

/**
 * Run four nodes, each with some sub sets, with no overlap.
 * They have to use trust network to get anywhere.
 * node-0 has no miner and views entire network.
 * using it as an easy way to see that network status
 * and as a p2p networking gateway
 * Also only one miner using a MrPlow that talks to the four nodes.
 */
@Test
public void shardTest() throws Exception {
    File snow_path = setupSnow("regshard");
    String trust_folder_base = test_folder.newFolder().getPath();
    node0 = startNode(0, "regshard", ImmutableMap.of("shards", "0", "trustnet_key_path", trust_folder_base));
    AddressSpecHash trust_addr = node0.getTrustnetAddress();
    String trust_str = AddressUtil.getAddressString("node", trust_addr);
    node1 = startNode(0, "regshard", ImmutableMap.of("shards", "3", "trustnet_key_path", trust_folder_base, "trustnet_signers", trust_str));
    node2 = startNode(0, "regshard", ImmutableMap.of("shards", "4", "trustnet_key_path", trust_folder_base, "trustnet_signers", trust_str));
    node3 = startNode(0, "regshard", ImmutableMap.of("shards", "5", "trustnet_key_path", trust_folder_base, "trustnet_signers", trust_str));
    node4 = startNode(0, "regshard", ImmutableMap.of("shards", "6", "trustnet_key_path", trust_folder_base, "trustnet_signers", trust_str));
    int[] ports = new int[5];
    ports[0] = node0.getServicePorts().get(0);
    ports[1] = node1.getServicePorts().get(0);
    ports[2] = node2.getServicePorts().get(0);
    ports[3] = node3.getServicePorts().get(0);
    ports[4] = node4.getServicePorts().get(0);
    Thread.sleep(100);
    node1.getPeerage().connectPeer("localhost", ports[0]);
    node2.getPeerage().connectPeer("localhost", ports[0]);
    node3.getPeerage().connectPeer("localhost", ports[0]);
    node4.getPeerage().connectPeer("localhost", ports[0]);
    Thread.sleep(3000);
    KeyPair key_pair = KeyUtil.generateECCompressedKey();
    AddressSpec claim = AddressUtil.getSimpleSpecForKey(key_pair.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
    AddressSpecHash to_addr = AddressUtil.getHashForSpec(claim);
    KeyPair key_pair_pool = KeyUtil.generateECCompressedKey();
    AddressSpec claim_pool = AddressUtil.getSimpleSpecForKey(key_pair_pool.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
    AddressSpecHash to_addr_pool = AddressUtil.getHashForSpec(claim_pool);
    MrPlow plow = startMrPlow(ImmutableList.of(ports[1], ports[2], ports[3], ports[4]), to_addr_pool, "regshard");
    PoolMiner miner1 = startPoolMiner(plow.getGrpcPort(), to_addr, snow_path, "regshard");
    waitForHeight(node1, 3, 36, 100);
    waitForHeight(node2, 4, 36, 80);
    waitForHeight(node3, 5, 36, 80);
    waitForHeight(node4, 6, 36, 80);
    waitForHeight(node0, 3, 36, 100);
    waitForHeight(node0, 4, 36, 80);
    waitForHeight(node0, 5, 36, 80);
    waitForHeight(node0, 6, 36, 80);
    miner1.stop();
    Thread.sleep(500);
    node0.stop();
    node1.stop();
    node2.stop();
    node3.stop();
    node4.stop();
}
Also used : PoolMiner(snowblossom.miner.PoolMiner) KeyPair(java.security.KeyPair) MrPlow(snowblossom.miner.plow.MrPlow) File(java.io.File) AddressSpecHash(snowblossom.lib.AddressSpecHash) Test(org.junit.Test)

Aggregations

PoolMiner (snowblossom.miner.PoolMiner)5 File (java.io.File)3 KeyPair (java.security.KeyPair)3 Test (org.junit.Test)3 AddressSpecHash (snowblossom.lib.AddressSpecHash)3 MrPlow (snowblossom.miner.plow.MrPlow)3 ByteString (com.google.protobuf.ByteString)2 ConfigMem (duckutil.ConfigMem)2 SnowBlossomClient (snowblossom.client.SnowBlossomClient)2 NetworkParams (snowblossom.lib.NetworkParams)2 SnowBlossomNode (snowblossom.node.SnowBlossomNode)2