示例#1
0
        private void HandleValidShare(IShare share)
        {
            var miner = (IStratumMiner)share.Miner;

            miner.ValidShareCount++;

            _storageLayer.AddShare(share); // commit the share.
            _logger.Debug("Share accepted at {0:0.00}/{1} by miner {2:l}", share.Difficulty, miner.Difficulty, miner.Username);

            // check if share is a block candidate
            if (!share.IsBlockCandidate)
            {
                return;
            }

            // submit block candidate to daemon.
            var accepted = SubmitBlock(share);

            if (!accepted)                                 // if block wasn't accepted
            {
                return;                                    // just return as we don't need to notify about it and store it.
            }
            OnBlockFound(EventArgs.Empty);                 // notify the listeners about the new block.

            _storageLayer.AddBlock(share);                 // commit the block details to storage.
            _storageLayer.MoveCurrentShares(share.Height); // move associated shares to new key.
        }
示例#2
0
        private void HandleValidShare(IShare share)
        {
            var miner = (IStratumMiner)share.Miner;

            miner.ValidShares++;

            _storageLayer.AddShare(share); // commit the share.
            _logger.Debug("Share accepted at {0:0.00}/{1} by miner {2:l}", share.Difficulty, miner.Difficulty, miner.Username);

            // check if share is a block candidate
            if (!share.IsBlockCandidate)
            {
                return;
            }

            // submit block candidate to daemon.
            var accepted = SubmitBlock(share);

            // log about the acceptance status of the block.
            _logger.Information(
                accepted
                    ? "Found block [{0}] with hash: {1:l}"
                    : "Submit block [{0}] failed with hash: {1:l}",
                share.Height, share.BlockHash.ToHexString());

            if (!accepted)                   // if block wasn't accepted
            {
                return;                      // just return as we don't need to notify about it and store it.
            }
            OnBlockFound(EventArgs.Empty);   // notify the listeners about the new block.

            _storageLayer.AddBlock(share);   // commit the block details to storage.
            _storageLayer.MoveShares(share); // move associated shares.
        }