예제 #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;
            }

            //Wow cool!!! Log it!
            share.DescribeYourselfSafely();

            // 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.
        }