Esempio n. 1
0
        public void NonCandicateShareTest()
        {
            /*
                handleSubmit: {"params":["mn4jUMneEBjZuDPEdFuj6BmFPmehmrT2Zc","2","07000000","53aaa331","87500200"],"id":118,"method":"mining.submit"}

                process-share:
                jobId: 2 previousDifficulty: undefined difficulty: 32 extraNonce1: 58000000 extraNonce2: 07000000 nTime: 53aaa331 nonce		: 87500200 ipAddress: 10.0.0.40 port: 3333 workerName: mn4jUMneEBjZuDPEdFuj6BmFPmehmrT2Zc
                nTimeInt: 1403691825
                coinbaseBuffer: 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff270310cf04062f503253482f0430a3aa530858000000070000000d2f6e6f64655374726174756d2f000000000280010b27010000001976a914329035234168b8da5af106ceb20560401236849888ac80f0fa02000000001976a9147d576fbfca48b899dc750167dd2a2a6572fff49588ac00000000
                coinbaseHash: 76a3f30f9dfdb980bf08a153f097c6456d5e0d290a41f760ce380c4b9c73f5d0
                merkleRoot: 7875fb5effb2f631634523f777090ba1568ec4c4ceee35a9b1c6832d24a23217
                headerBuffer: 0200000062804ac7aa2748b16841fc12ac15721dc5be748c64c6b596b74c56478eb84e1c1732a2242d83c6b1a935eecec4c48e56a10b0977f723456331f6b2ff5efb757831a3aa53f7d4481d00025087
                headerHash: 83011ba79aa48eefd2fccef32ebe190f538c1d188fecf764d2aca2259c060000
                headerBigNum: 45620193236259201373579162993315268294283759910880625924204234612081027
                shareDiff: 38.72890444987063 diff1: 2.695953529101131e+67 shareMultiplier: 65536
                blockDiffAdjusted : 899.811835904 job.difficulty: 0.013730039
                job.target: 1963543975774994773269086777481374456547162842587540503781935641788416
                candicate: false
                blockHashInvalid: 87776a72cedf7467ef78c0dc8a7181340342888e33bd19e6ff48d579299d38c1
                shareDiff / difficulty: 1.2102782640584573
                2014-06-25 13:23:45 [Pool]	[litecoin] (Thread 1) Share accepted at diff 32/38.72890445 by mn4jUMneEBjZuDPEdFuj6BmFPmehmrT2Zc [10.0.0.40]
                emit: {"job":"2","ip":"10.0.0.40","port":3333,"worker":"mn4jUMneEBjZuDPEdFuj6BmFPmehmrT2Zc","height":315152,"blockReward":5000000000,"difficulty":32,"shareDiff":"38.72890445","blockDiff":899.811835904,"blockDiffActual":0.013730039,"blockHashInvalid":"87776a72cedf7467ef78c0dc8a7181340342888e33bd19e6ff48d579299d38c1"} blockHex: undefined
             */

            // submitted share json
            const string shareJson = "{\"params\":[\"mn4jUMneEBjZuDPEdFuj6BmFPmehmrT2Zc\",\"2\",\"07000000\",\"53aaa331\",\"87500200\"],\"id\":118,\"method\":\"mining.submit\"}";
            dynamic shareObject = JsonConvert.DeserializeObject(shareJson);
            dynamic shareData = shareObject.@params;

            string minerName = shareData[0];
            string jobId = shareData[1];
            string extraNonce2 = shareData[2];
            string nTime = shareData[3];
            string nonce = shareData[4];

            minerName.Should().Equal("mn4jUMneEBjZuDPEdFuj6BmFPmehmrT2Zc");
            jobId.Should().Equal("2");
            extraNonce2.Should().Equal("07000000");
            nTime.Should().Equal("53aaa331");
            nonce.Should().Equal("87500200");

            // create the share
            var id = Convert.ToUInt64(jobId, 16);
            var job = _jobTracker.Get(id);

            var share = new Share(_miner, id, job, extraNonce2, nTime, nonce);

            // test miner provided nonce and ntime
            share.NTime.Should().Equal((UInt32)0x53aaa331);
            share.Nonce.Should().Equal((UInt32)0x87500200);

            // test job provided extraNonce1 and extraNonce2
            share.ExtraNonce1.Should().Equal((UInt32)0x58000000);
            share.ExtraNonce2.Should().Equal((UInt32)0x07000000);

            // test coinbase
            share.CoinbaseBuffer.ToHexString().Should().Equal("01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff270310cf04062f503253482f0430a3aa530858000000070000000d2f6e6f64655374726174756d2f000000000280010b27010000001976a914329035234168b8da5af106ceb20560401236849888ac80f0fa02000000001976a9147d576fbfca48b899dc750167dd2a2a6572fff49588ac00000000");
            share.CoinbaseHash.Bytes.ToHexString().Should().Equal("76a3f30f9dfdb980bf08a153f097c6456d5e0d290a41f760ce380c4b9c73f5d0");

            // test merkle-root.
            share.MerkleRoot.ToHexString().Should().Equal("7875fb5effb2f631634523f777090ba1568ec4c4ceee35a9b1c6832d24a23217");

            // test the block header
            share.HeaderBuffer.ToHexString().Should().Equal("0100000062804ac7aa2748b16841fc12ac15721dc5be748c64c6b596b74c56478eb84e1c1732a2242d83c6b1a935eecec4c48e56a10b0977f723456331f6b2ff5efb757831a3aa53f7d4481d00025087");

            // test the block hash.
            share.HeaderHash.ToHexString().Should().Equal("b709d849b2079e41018d7838eaabcb21e1d0e8da9f0b0aa9ea2ec19a276a0a58");
            share.HeaderValue.Should().Equal(BigInteger.Parse("39821931798823469742770006186359742132221210135666296384521732031216086419895"));

            // test the job
            share.Job.Target.Should().Equal(BigInteger.Parse("1963543975774994773269086777481374456547162842587540503781935641788416"));
            //share.Job.Difficulty.Should().Equal(0.013730039);

            // test the difficulty
            //share.Difficulty.Should().Equal(38.72890444987063);
            //share.BlockDiffAdjusted.Should().Equal(899.811835904);

            // check the block hex & block hash
            share.BlockHex.Should().Be.Null();
            share.BlockHash.ToHexString().Should().Equal("f701c5561c8a6aba30d5ab691cdddb4ae40f97644714b7c0bb10ee545e73d8c4");

            // check the share itself.
            share.IsValid.Should().Equal(true);
            share.IsBlockCandidate.Should().Equal(false);
        }
Esempio n. 2
0
        /// <summary>
        /// Processes the share.
        /// </summary>
        /// <param name="miner">The miner.</param>
        /// <param name="jobId">The job identifier.</param>
        /// <param name="extraNonce2">The extra nonce2.</param>
        /// <param name="nTimeString">The n time string.</param>
        /// <param name="nonceString">The nonce string.</param>
        /// <returns></returns>
        public IShare ProcessShare(IStratumMiner miner, string jobId, string extraNonce2, string nTimeString, string nonceString)
        {
            // check if the job exists
            var id = Convert.ToUInt64(jobId, 16);
            var job = _jobTracker.Get(id);

            // create the share
            var share = new Share(miner, id, job, extraNonce2, nTimeString, nonceString);

            if (share.IsValid)
                HandleValidShare(share);
            else
                HandleInvalidShare(share);

            OnShareSubmitted(new ShareEventArgs(miner));  // notify the listeners about the share.

            return share;
        }
Esempio n. 3
0
        public void CandicateShareTest()
        {
            /*
                handleSubmit: {"params":["mn4jUMneEBjZuDPEdFuj6BmFPmehmrT2Zc","2","07000000","53aaa331","44725000"],"id":120,"method":"mining.submit"}

                processShare: jobId: 2 previousDifficulty: undefined difficulty: 32 extraNonce1: 58000000 extraNonce2: 07000000 nTime: 53aaa331 nonce		: 44725000 ipAddress: 10.0.0.40 port: 3333 workerName: mn4jUMneEBjZuDPEdFuj6BmFPmehmrT2Zc
                nTimeInt: 1403691825
                coinbaseBuffer: 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff270310cf04062f503253482f0430a3aa530858000000070000000d2f6e6f64655374726174756d2f000000000280010b27010000001976a914329035234168b8da5af106ceb20560401236849888ac80f0fa02000000001976a9147d576fbfca48b899dc750167dd2a2a6572fff49588ac00000000
                coinbaseHash: 76a3f30f9dfdb980bf08a153f097c6456d5e0d290a41f760ce380c4b9c73f5d0
                merkleRoot: 7875fb5effb2f631634523f777090ba1568ec4c4ceee35a9b1c6832d24a23217
                headerBuffer: 0200000062804ac7aa2748b16841fc12ac15721dc5be748c64c6b596b74c56478eb84e1c1732a2242d83c6b1a935eecec4c48e56a10b0977f723456331f6b2ff5efb757831a3aa53f7d4481d00507244
                headerHash: da8b1ccf43b05a9fcea33f5ca15b0c3498a89bd764e07c7486620ccb15000000
                headerBigNum: 587542370056468750648693126335067486740543774422516057325819970489306
                shareDiff: 3007.1364975123547 diff1: 2.695953529101131e+67 shareMultiplier: 65536
                blockDiffAdjusted : 899.811835904 job.difficulty: 0.013730039
                job.target: 1963543975774994773269086777481374456547162842587540503781935641788416
                candicate: true
                blockHex: 0200000062804ac7aa2748b16841fc12ac15721dc5be748c64c6b596b74c56478eb84e1c1732a2242d83c6b1a935eecec4c48e56a10b0977f723456331f6b2ff5efb757831a3aa53f7d4481d005072440201000000010000000000000000000000000000000000000000000000000000000000000000ffffffff270310cf04062f503253482f0430a3aa530858000000070000000d2f6e6f64655374726174756d2f000000000280010b27010000001976a914329035234168b8da5af106ceb20560401236849888ac80f0fa02000000001976a9147d576fbfca48b899dc750167dd2a2a6572fff49588ac00000000010000000332a82e92f522deee69b09e27858ba9b87585f2a4913ef71018df40909032fdc3000000006a473044022019ca05cb880a04f0d842268b7e75ac6d2695fc544df033e3daeb29239251a8970220031f6336767f2ea617347484e1290ec0bdcc71056ea2d3084e75384905250ec50121030dd394118fb66ca288bff71d8ea762678783b005770f7f9ba4128233191e0847ffffffff086747cbd339b21b950774186091653a7b8f5751b00a906ff6f5561b3a6fcee6010000006b4830450221009ae1ba9a216d313cc592fc2c1ef08f1e0e555a32b6c1b305f685ac882d38356b0220243106bbb5bb76dde142e574cba8f30c1e2f7059e8e9161770396fbd2b50420f0121030dd394118fb66ca288bff71d8ea762678783b005770f7f9ba4128233191e0847ffffffffe2f15804b1e41c36c925c6f64f219b2bdb3c9fbff4c97a4f0e8c7f31d7e6f2af000000006b48304502200be8894fdd7f5c19be248a979c08bbf2395f606e038c3e02c0266474c03699ab022100ff5de87086e487410f5d7b68012655ca6d814f0caeb9ca42d9c425a90f68b3030121030dd394118fb66ca288bff71d8ea762678783b005770f7f9ba4128233191e0847ffffffff02a0f01900000000001976a9141c50209a1dfdf53313d237b75e9aeb553ca1dfda88ac00e1f505000000001976a914cbb9a3e7a7c1651b1006f876f08b40be85b274f588ac00000000
                blockHash: e242093d92f4c98bfd5dd1f9f6489652d1165f5ce4eed1f28747d2b8e3efd8b6
                emit: {"job":"2","ip":"10.0.0.40","port":3333,"worker":"mn4jUMneEBjZuDPEdFuj6BmFPmehmrT2Zc","height":315152,"blockReward":5000000000,"difficulty":32,"shareDiff":"3007.13649751","blockDiff":899.811835904,"blockDiffActual":0.013730039,"blockHash":"e242093d92f4c98bfd5dd1f9f6489652d1165f5ce4eed1f28747d2b8e3efd8b6"} blockHex: 0200000062804ac7aa2748b16841fc12ac15721dc5be748c64c6b596b74c56478eb84e1c1732a2242d83c6b1a935eecec4c48e56a10b0977f723456331f6b2ff5efb757831a3aa53f7d4481d005072440201000000010000000000000000000000000000000000000000000000000000000000000000ffffffff270310cf04062f503253482f0430a3aa530858000000070000000d2f6e6f64655374726174756d2f000000000280010b27010000001976a914329035234168b8da5af106ceb20560401236849888ac80f0fa02000000001976a9147d576fbfca48b899dc750167dd2a2a6572fff49588ac00000000010000000332a82e92f522deee69b09e27858ba9b87585f2a4913ef71018df40909032fdc3000000006a473044022019ca05cb880a04f0d842268b7e75ac6d2695fc544df033e3daeb29239251a8970220031f6336767f2ea617347484e1290ec0bdcc71056ea2d3084e75384905250ec50121030dd394118fb66ca288bff71d8ea762678783b005770f7f9ba4128233191e0847ffffffff086747cbd339b21b950774186091653a7b8f5751b00a906ff6f5561b3a6fcee6010000006b4830450221009ae1ba9a216d313cc592fc2c1ef08f1e0e555a32b6c1b305f685ac882d38356b0220243106bbb5bb76dde142e574cba8f30c1e2f7059e8e9161770396fbd2b50420f0121030dd394118fb66ca288bff71d8ea762678783b005770f7f9ba4128233191e0847ffffffffe2f15804b1e41c36c925c6f64f219b2bdb3c9fbff4c97a4f0e8c7f31d7e6f2af000000006b48304502200be8894fdd7f5c19be248a979c08bbf2395f606e038c3e02c0266474c03699ab022100ff5de87086e487410f5d7b68012655ca6d814f0caeb9ca42d9c425a90f68b3030121030dd394118fb66ca288bff71d8ea762678783b005770f7f9ba4128233191e0847ffffffff02a0f01900000000001976a9141c50209a1dfdf53313d237b75e9aeb553ca1dfda88ac00e1f505000000001976a914cbb9a3e7a7c1651b1006f876f08b40be85b274f588ac00000000
                2014-06-25 13:24:04 [Pool]	[litecoin] (Thread 1) Submitted Block using submitblock successfully to daemon instance(s)
                2014-06-25 13:24:04 [Pool]	[litecoin] (Thread 1) Block found: e242093d92f4c98bfd5dd1f9f6489652d1165f5ce4eed1f28747d2b8e3efd8b6
             */

            // submitted share json
            const string shareJson = "{\"params\":[\"mn4jUMneEBjZuDPEdFuj6BmFPmehmrT2Zc\",\"2\",\"07000000\",\"53aaa331\",\"44725000\"],\"id\":120,\"method\":\"mining.submit\"}";
            dynamic shareObject = JsonConvert.DeserializeObject(shareJson);
            dynamic shareData = shareObject.@params;

            string minerName = shareData[0];
            string jobId = shareData[1];
            string extraNonce2 = shareData[2];
            string nTime = shareData[3];
            string nonce = shareData[4];

            minerName.Should().Equal("mn4jUMneEBjZuDPEdFuj6BmFPmehmrT2Zc");
            jobId.Should().Equal("2");
            extraNonce2.Should().Equal("07000000");
            nTime.Should().Equal("53aaa331");
            nonce.Should().Equal("44725000");

            // create the share
            var id = Convert.ToUInt64(jobId, 16);
            var job = _jobTracker.Get(id);

            var share = new Share(_miner, id, job, extraNonce2, nTime, nonce);

            // test miner provided nonce and ntime
            share.NTime.Should().Equal((UInt32)0x53aaa331);
            share.Nonce.Should().Equal((UInt32)0x44725000);

            // test job provided extraNonce1 and extraNonce2
            share.ExtraNonce1.Should().Equal((UInt32)0x58000000);
            share.ExtraNonce2.Should().Equal((UInt32)0x07000000);

            // test coinbase
            share.CoinbaseBuffer.ToHexString().Should().Equal("01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff270310cf04062f503253482f0430a3aa530858000000070000000d2f6e6f64655374726174756d2f000000000280010b27010000001976a914329035234168b8da5af106ceb20560401236849888ac80f0fa02000000001976a9147d576fbfca48b899dc750167dd2a2a6572fff49588ac00000000");
            share.CoinbaseHash.Bytes.ToHexString().Should().Equal("76a3f30f9dfdb980bf08a153f097c6456d5e0d290a41f760ce380c4b9c73f5d0");

            // test merkle-root.
            share.MerkleRoot.ToHexString().Should().Equal("7875fb5effb2f631634523f777090ba1568ec4c4ceee35a9b1c6832d24a23217");

            // test the block header
            share.HeaderBuffer.ToHexString().Should().Equal("0100000062804ac7aa2748b16841fc12ac15721dc5be748c64c6b596b74c56478eb84e1c1732a2242d83c6b1a935eecec4c48e56a10b0977f723456331f6b2ff5efb757831a3aa53f7d4481d00507244");

            // test the block hash.
            share.HeaderHash.ToHexString().Should().Equal("49c71381f71301c86b429ef1c731fb34bf4b06f566b12ef66de9b53efef61f7d");
            share.HeaderValue.Should().Equal(BigInteger.Parse("56595583015948388667310925439783538703284674723883721372476934843162971850569"));

            // test the job
            share.Job.Target.Should().Equal(BigInteger.Parse("1963543975774994773269086777481374456547162842587540503781935641788416"));
            //share.Job.Difficulty.Should().Equal(0.013730039);

            // test the difficulty
            //share.Difficulty.Should().Equal(3007.1364975123547);
            //share.BlockDiffAdjusted.Should().Equal(899.811835904);

            // check the block hex & block hash
            // TODO: fix the test - it's not a valid share (job.target <= header-value) data.
            //share.BlockHex.ToHexString().Should().Equal("0200000062804ac7aa2748b16841fc12ac15721dc5be748c64c6b596b74c56478eb84e1c1732a2242d83c6b1a935eecec4c48e56a10b0977f723456331f6b2ff5efb757831a3aa53f7d4481d005072440201000000010000000000000000000000000000000000000000000000000000000000000000ffffffff270310cf04062f503253482f0430a3aa530858000000070000000d2f6e6f64655374726174756d2f000000000280010b27010000001976a914329035234168b8da5af106ceb20560401236849888ac80f0fa02000000001976a9147d576fbfca48b899dc750167dd2a2a6572fff49588ac00000000010000000332a82e92f522deee69b09e27858ba9b87585f2a4913ef71018df40909032fdc3000000006a473044022019ca05cb880a04f0d842268b7e75ac6d2695fc544df033e3daeb29239251a8970220031f6336767f2ea617347484e1290ec0bdcc71056ea2d3084e75384905250ec50121030dd394118fb66ca288bff71d8ea762678783b005770f7f9ba4128233191e0847ffffffff086747cbd339b21b950774186091653a7b8f5751b00a906ff6f5561b3a6fcee6010000006b4830450221009ae1ba9a216d313cc592fc2c1ef08f1e0e555a32b6c1b305f685ac882d38356b0220243106bbb5bb76dde142e574cba8f30c1e2f7059e8e9161770396fbd2b50420f0121030dd394118fb66ca288bff71d8ea762678783b005770f7f9ba4128233191e0847ffffffffe2f15804b1e41c36c925c6f64f219b2bdb3c9fbff4c97a4f0e8c7f31d7e6f2af000000006b48304502200be8894fdd7f5c19be248a979c08bbf2395f606e038c3e02c0266474c03699ab022100ff5de87086e487410f5d7b68012655ca6d814f0caeb9ca42d9c425a90f68b3030121030dd394118fb66ca288bff71d8ea762678783b005770f7f9ba4128233191e0847ffffffff02a0f01900000000001976a9141c50209a1dfdf53313d237b75e9aeb553ca1dfda88ac00e1f505000000001976a914cbb9a3e7a7c1651b1006f876f08b40be85b274f588ac00000000");
            //share.BlockHash.ToHexString().Should().Equal("e242093d92f4c98bfd5dd1f9f6489652d1165f5ce4eed1f28747d2b8e3efd8b6");

            // check the share itself.
            share.IsValid.Should().Equal(true);
            // share.IsBlockCandidate.Should().Equal(true);
        }