Пример #1
0
        private void CheckCandidates(IHashCandidate candidate)
        {
            try
            {
                // get the transaction.
                var transaction = _daemonClient.GetTransaction(candidate.TransactionHash);

                // total amount of coins contained in the block.
                candidate.Amount = transaction.Details.Sum(output => (decimal)output.Amount);

                // get the output transaction that targets pools central wallet.
                var poolOutput = transaction.Details.FirstOrDefault(output => output.Address == _walletConfig.Adress);

                // make sure output for the pool central wallet exists
                if (poolOutput == null)
                {
                    candidate.Status = BlockStatus.Kicked; // kick the hash.
                    candidate.Reward = 0;
                }
                else
                {
                    switch (poolOutput.Category)
                    {
                        case "immature":
                            candidate.Status = BlockStatus.Pending;
                            break;
                        case "orphan":
                            candidate.Status = BlockStatus.Orphaned;
                            break;
                        case "generate":
                            candidate.Status = BlockStatus.Confirmed;
                            break;
                        default:
                            candidate.Status = BlockStatus.Pending;
                            break;
                    }

                    candidate.Reward = (decimal) poolOutput.Amount;
                }
            }
            catch (RpcException)
            {
                candidate.Status = BlockStatus.Kicked; // kick the hash.
                candidate.Reward = 0;
            }
        }
Пример #2
0
 public KickedBlock(uint height, IHashCandidate candidate)
     : this(height, candidate.BlockHash, candidate.TransactionHash, candidate.Amount, candidate.Reward)
 {
 }
Пример #3
0
 public void AddHashCandidate(IHashCandidate hash)
 {
     Candidates.Add(hash);
 }