Beispiel #1
0
        public int GetNearestIncomesForTransaction(Transaction transaction, DateTime transactionTime)
        {
            int total = 0;

            foreach (Block block in storedChain.GetBlocksReverse())
            {
                if (block.CreationTime < transactionTime)
                {
                    foreach (Transaction tr in block.Transactions)
                    {
                        if (tr.Recipient.SequenceEqual(transaction.Sender))
                        {
                            total += tr.Amount;

                            if (total >= transaction.Amount)
                            {
                                return(total);
                            }

                            continue;
                        }

                        if (tr.Sender.SequenceEqual(transaction.Sender) && !tr.Recipient.SequenceEqual(transaction.Sender))
                        {
                            total -= tr.Amount;
                        }
                    }
                }
            }

            return(total);
        }