Esempio n. 1
0
 public void AddChannel(IPeer peer, LocalChannel channel)
 {
     lock (_syncLock)
     {
         _logger.LogInformation($"Add Channel {channel.ChannelId}");
         channel.PersistentPeer = _dbContext.Peers.SingleOrDefault(p => p.Address == peer.NodeAddress.Address) ?? new PersistentPeer(peer.NodeAddress.Address, true);
         _dbContext.Add(channel);
         _dbContext.SaveChanges();
         _channels.Add(channel);
         _channelAddedProvider.NotifyOn(_taskScheduler).OnNext(channel);
     }
 }
 private void Save(LocalChannelLogEntry entry)
 {
     lock (_syncObject)
     {
         _localPersistenceContext.Add(entry);
         _localPersistenceContext.SaveChanges();
     }
 }
        private SpendingTransactionLookup FindOrCreateLookup(string transactionId, ushort outputIndex)
        {
            lock (_syncLock)
            {
                var lookup = _dbContext.SpendingTransactionLookups.SingleOrDefault(existingLookup =>
                                                                                   existingLookup.TransactionId == transactionId && existingLookup.OutputIndex == outputIndex);

                if (lookup == null)
                {
                    lookup = new SpendingTransactionLookup
                    {
                        TransactionId   = transactionId,
                        OutputIndex     = outputIndex,
                        LastBlockHeight = (uint)_clientService.GetBlockCount()
                    };

                    _dbContext.SpendingTransactionLookups.Add(lookup);
                    _dbContext.SaveChanges();
                }

                return(lookup);
            }
        }