Example #1
0
 public AccountEntry PushAccountEntry(AccountEntry entry)
 {
     if (Process(entry) != null)
     {
         _Entries.WriteNext(entry);
         _NextToProcess++;
     }
     return(entry);
 }
Example #2
0
 private void PushAccountEntry(AccountEntry entry)
 {
     if (entry.Spendable.TxOut.Value < Money.Zero)
     {
         Available.PushAccountEntry(entry);
     }
     if (entry.Block != null)
     {
         Available.PushAccountEntry(entry);
         Confirmed.PushAccountEntry(entry);
     }
 }
Example #3
0
 private void PushAccountEntry(AccountEntry entry)
 {
     if(entry.Spendable.TxOut.Value < Money.Zero)
         Available.PushAccountEntry(entry);
     if(entry.Block != null)
     {
         Available.PushAccountEntry(entry);
         Confirmed.PushAccountEntry(entry);
     }
 }
Example #4
0
        AccountEntry Process(AccountEntry entry)
        {
            if (entry.Spendable._Account != null && entry.Spendable._Account != this)
            {
                throw new InvalidOperationException("Entry already processed by another account");
            }
            entry.Spendable._Account = this;
            try
            {
                if (entry.Reason == AccountEntryReason.Income || entry.Reason == AccountEntryReason.Outcome)
                {
                    if (entry.BalanceChange < Money.Zero)
                    {
                        if (!_Unspent.Remove(entry.Spendable.OutPoint))
                        {
                            return(null);
                        }
                    }
                    if (entry.BalanceChange > Money.Zero)
                    {
                        if (!_Unspent.TryAdd(entry.Spendable.OutPoint, entry.Spendable))
                        {
                            return(null);
                        }
                    }
                    if (entry.BalanceChange == Money.Zero)
                    {
                        return(null);
                    }
                }
                else if (entry.Reason == AccountEntryReason.Lock || entry.Reason == AccountEntryReason.Unlock)
                {
                    if (entry.Reason == AccountEntryReason.Lock)
                    {
                        _Locked.Add(entry.Spendable.OutPoint);
                    }
                    else
                    {
                        _Locked.Remove(entry.Spendable.OutPoint);
                    }
                }
                else if (entry.Reason == AccountEntryReason.ChainBlockChanged)
                {
                    if (entry.BalanceChange < Money.Zero)
                    {
                        if (!_Unspent.Remove(entry.Spendable.OutPoint))
                        {
                            return(null);
                        }
                    }
                    if (entry.BalanceChange > Money.Zero)
                    {
                        if (!_Unspent.TryAdd(entry.Spendable.OutPoint, entry.Spendable))
                        {
                            return(null);
                        }
                    }
                }
                _Balance += entry.BalanceChange;
                return(entry);
            }
            finally
            {
#if DEBUG
                if (_Balance != Unspent.Select(o => o.TxOut.Value).Sum())
                {
                    throw new NotSupportedException("Something is going wrong");
                }
#endif
            }
        }
Example #5
0
 internal AccountEntry Process(AccountEntry entry)
 {
     if(entry.Spendable._Account != null && entry.Spendable._Account != this)
         throw new InvalidOperationException("Entry already processed by another account");
     entry.Spendable._Account = this;
     try
     {
         if(entry.Reason == AccountEntryReason.Income || entry.Reason == AccountEntryReason.Outcome)
         {
             if(entry.BalanceChange < Money.Zero)
             {
                 if(!_Unspent.Remove(entry.Spendable.OutPoint))
                     return null;
             }
             if(entry.BalanceChange > Money.Zero)
             {
                 if(!_Unspent.TryAdd(entry.Spendable.OutPoint, entry.Spendable))
                     return null;
             }
             if(entry.BalanceChange == Money.Zero)
                 return null;
         }
         else if(entry.Reason == AccountEntryReason.Lock || entry.Reason == AccountEntryReason.Unlock)
         {
             if(entry.Reason == AccountEntryReason.Lock)
             {
                 _Locked.Add(entry.Spendable.OutPoint);
             }
             else
             {
                 _Locked.Remove(entry.Spendable.OutPoint);
             }
         }
         else if(entry.Reason == AccountEntryReason.ChainBlockChanged)
         {
             if(entry.BalanceChange < Money.Zero)
             {
                 if(!_Unspent.Remove(entry.Spendable.OutPoint))
                     return null;
             }
             if(entry.BalanceChange > Money.Zero)
             {
                 if(!_Unspent.TryAdd(entry.Spendable.OutPoint, entry.Spendable))
                     return null;
             }
         }
         _Balance += entry.BalanceChange;
         return entry;
     }
     finally
     {
     #if DEBUG
         if(_Balance != Unspent.Select(o => o.TxOut.Value).Sum())
             throw new NotSupportedException("Something is going wrong");
     #endif
     }
 }
Example #6
0
 public AccountEntry PushAccountEntry(AccountEntry entry)
 {
     if(Process(entry) != null)
     {
         _Entries.WriteNext(entry);
         _NextToProcess++;
     }
     return entry;
 }