Ejemplo n.º 1
0
        public void RemoveVertex(string vertexName)
        {
            if (_nameVertexDictionary.TryGetValue(vertexName, out TVertex vertex))
            {
                _nameVertexDictionary.Remove(vertexName);

                if (_vertexEdgeDictionary.TryGetValue(vertex, out IReadOnlyCollection <EdgeBase <TVertex> > vertexEdges))
                {
                    foreach (var vertexEdge in vertexEdges)
                    {
                        TVertex otherVertex;
                        if (vertexEdge.Source != vertex)
                        {
                            otherVertex = vertexEdge.Source;
                        }
                        else if (vertexEdge.Target != vertex)
                        {
                            otherVertex = vertexEdge.Target;
                        }
                        else
                        {
                            continue;
                        }

                        _vertexEdgeDictionary.Remove(otherVertex, vertexEdge);
                        _edgeList.Remove(vertexEdge);
                    }
                    _vertexEdgeDictionary.Remove(vertex);
                }
            }
        }
Ejemplo n.º 2
0
        public void TestMultiValueDictionary()
        {
            var dict = new MultiValueDictionary<int, int>();

            dict.Add(1, 1);
            dict.Add(1, 2);

            int val;

            Assert.IsTrue(dict.TryRemove(1, out val));
            Assert.AreEqual(2, val);

            Assert.IsTrue(dict.TryRemove(1, out val));
            Assert.AreEqual(1, val);

            Assert.IsFalse(dict.TryRemove(1, out val));

            dict.Add(2, 1);
            dict.Add(2, 2);
            dict.Remove(2, 3);
            dict.Remove(2, 2);

            Assert.IsTrue(dict.TryRemove(2, out val));
            Assert.AreEqual(1, val);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Dereference a fingerprint from all table for GC to collect
 /// <para>returns 0 if removal success, -1 otherwise</para>
 /// </summary>
 /// <param name="Fingname">Name of fingerprint to be removed</param>
 /// <returns>0 if removed, -1 if failed</returns>
 public static int DelFing(string Fingname)
 {
     lock (MacDict)
     {
         lock (FingDict)
         {
             int         returncode = -1;
             Fingerprint finger     = GetFingObject(Fingname);
             string[]    MacList    = new string[10];
             if (finger != null)
             {
                 MacList = finger.FingRemove();
                 foreach (string delref in MacList)
                 {
                     if (delref == null)
                     {
                         break;
                     }
                     MacDict.Remove(delref, finger);
                 }
                 FingDict.Remove(Fingname);
                 returncode = 0;
             }
             return(returncode);
         }
     }
 }
Ejemplo n.º 4
0
        private void OnHostName(IPAddress remoteAddress, string hostName, NameSources source, int processId = 0)
        {
            CloneableList <HostObserveJob> Jobs = ObserverJobs.GetValues(remoteAddress, false);

            if (Jobs == null)
            {
                return;
            }

            foreach (HostObserveJob curJob in Jobs.Clone())
            {
                if (processId == 0 || curJob.processId == processId)
                {
                    if (hostName != null)
                    {
                        curJob.SetHostName(hostName, source);
                    }
                    curJob.Await &= ~source; // clear the await
                }

                if (!curJob.IsValid())
                {
                    ObserverJobs.Remove(remoteAddress, curJob);
                }
            }
        }
Ejemplo n.º 5
0
        public void TestMultiValueDictionary()
        {
            var dict = new MultiValueDictionary <int, int>();

            dict.Add(1, 1);
            dict.Add(1, 2);

            int val;

            Assert.IsTrue(dict.TryRemove(1, out val));
            Assert.AreEqual(2, val);

            Assert.IsTrue(dict.TryRemove(1, out val));
            Assert.AreEqual(1, val);

            Assert.IsFalse(dict.TryRemove(1, out val));

            dict.Add(2, 1);
            dict.Add(2, 2);
            dict.Remove(2, 3);
            dict.Remove(2, 2);

            Assert.IsTrue(dict.TryRemove(2, out val));
            Assert.AreEqual(1, val);
        }
Ejemplo n.º 6
0
 /**
  * Add sharding value for database.
  *
  * <p>The sharding operator is {@code =}</p>
  *
  * @param logicTable logic table name
  * @param value sharding value
  */
 public void AddDatabaseShardingValue(String logicTable, IComparable value)
 {
     if (databaseShardingOnly)
     {
         databaseShardingValues.Remove("");
     }
     databaseShardingValues.Add(logicTable, value);
     databaseShardingOnly = false;
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Removes an entry from the list.
        /// If after removing this entry, the opcode list is empty,
        /// the opcode is then removed from the list as well.
        /// </summary>
        /// <param name="opCode">The opcode of the packet.</param>
        /// <param name="size">The size of the packet, in bytes.</param>
        public void Remove(int opCode, int size)
        {
            m_ignoredPackets.Remove(opCode, size);

            if (m_ignoredPackets.ContainsKey(opCode))
            {
                if (m_ignoredPackets[opCode].Count <= 0)
                {
                    m_ignoredPackets.Remove(opCode);
                }
            }
        }
        public void Remove_ShouldRemoveTheSpecifiedValueFromTheMultiValueCollection()
        {
            _target.Add("A", "B");
            _target.Add("A", "C");

            _target.Remove("A", "B");

            var result = _target["A"];

            Assert.Contains("C", result);
            Assert.DoesNotContain("B", result);
        }
Ejemplo n.º 9
0
        bool Remove(RegisterType registerType, Type type, object key)
        {
            var compoundKey = CompoundKey(type, key);

            if (!_refs.TryGetValue(compoundKey, out var entries))
            {
                return(false);
            }

            var entry = entries.LastOrDefault(e => (e.Type & registerType) != 0);

            return(entry != null && _refs.Remove(compoundKey, entry));
        }
Ejemplo n.º 10
0
        public void RemoveAll <T>() where T : Component
        {
            IReadOnlyCollection <Component> components;

            if (_components.TryGetValue(typeof(T), out components))
            {
                foreach (Component c in components)
                {
                    c.InternalRemoved(_registry);
                }

                _components.Remove(typeof(T));
            }
        }
        public void RemoveTest()
        {
            var t = new MultiValueDictionary <int, int>();

            t.Add(1, 3);
            t.Add(1, 4);
            t.Add(1, 5);
            t.Add(2, 3);
            t.Add(2, 4);

            t.Remove(1);
            Assert.False(t.ContainsKey(1));
            t.Remove(2);
            Assert.False(t.ContainsKey(1));
            Assert.True(!t.Any());
        }
Ejemplo n.º 12
0
 private void Unsubscribe(IComponentIntern component)
 {
     foreach (var type in GetComponentHandledMessageTypes(component))
     {
         _messageHandlers.Remove(type, component);
     }
 }
        public async Task WaitSettingsChanged <T>(CancellationToken cancellation)
        {
            var tcs = new TaskCompletionSource <bool>();

            using (cancellation.Register(() =>
            {
                try
                {
                    tcs.TrySetCanceled();
                }
                catch { }
            }))
            {
                lock (_Subscriptions)
                {
                    _Subscriptions.Add(typeof(T), tcs);
                }
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                tcs.Task.ContinueWith(_ =>
                {
                    lock (_Subscriptions)
                    {
                        _Subscriptions.Remove(typeof(T), tcs);
                    }
                }, TaskScheduler.Default);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                await tcs.Task;
            }
        }
Ejemplo n.º 14
0
            /// <summary>
            /// This function filters out symbols with the same intervals perserving the most important ones.
            /// </summary>
            private IEnumerable <Symbol> SelectDistinctViaImportance(IEnumerable <Symbol> symbolSet)
            {
                var distinctSymbols = new MultiValueDictionary <int, Symbol>();
                IReadOnlyCollection <Symbol> symbolsWithSameHash;
                int hashCode;

                foreach (var symbol in symbolSet)
                {
                    hashCode = comparer.GetHashCode(symbol);
                    if (distinctSymbols.TryGetValue(hashCode, out symbolsWithSameHash))
                    {
                        //Replace all exisiting copies (interval-wise) of the symbol which that are less important.
                        //There should be only one and we have to break after modification of the collection.
                        foreach (var existingSymbol in symbolsWithSameHash)
                        {
                            if (comparer.Equals(symbol, existingSymbol) && symbol.IsMoreImportantThan(existingSymbol))
                            {
                                distinctSymbols.Remove(hashCode, existingSymbol);
                                distinctSymbols.Add(hashCode, symbol);
                                break;
                            }
                        }
                    }
                    else
                    {
                        distinctSymbols.Add(hashCode, symbol);
                    }
                }
                return(distinctSymbols);
            }
Ejemplo n.º 15
0
        public void Remove_SinglePair()
        {
            sut.Add("a", "1");
            sut.Add("a", "2");
            sut.Add("b", "3");
            sut.Remove("a", "2");

            sut.Should().BeEquivalentTo(
                new KeyValuePair <string, IReadOnlyCollection <string> >("a", new List <string>()
            {
                "1"
            }),
                new KeyValuePair <string, IReadOnlyCollection <string> >("b", new List <string>()
            {
                "3"
            }));
        }
        public void RemovingItemsShouldDecreaseCount()
        {
            var dict = new MultiValueDictionary <int, string>(() => new HashSet <string>())
            {
                { 1, "one" },
                { 1, "een" },
                { 2, "two" },
                { 2, "twee" },
                { 2, "deux" }
            };

            dict.Remove(2, "twee");
            dict.Remove(1);

            Assert.Equal(2, dict.Count);
            Assert.Equal(2, dict[2].Count);
        }
Ejemplo n.º 17
0
 ///<summary>Removes a light source of the given radius at the given point, updating surrounding light values.</summary>
 public void RemoveLightSource(Point sourceCell, int radius)
 {
     if (!lightSources.Remove(sourceCell, radius))
     {
         throw new InvalidOperationException("No light source of this radius at this cell");
     }
     UpdateBrightnessWithinRadius(sourceCell, radius, -1);
 }
Ejemplo n.º 18
0
    public void RemoveKey()
    {
        var dictionary = new MultiValueDictionary<string, string>();
        dictionary.AddValue("Key", "Value");

        dictionary.Remove("Key");

        Assert.DoesNotContain("Key", dictionary.Keys);
    }
Ejemplo n.º 19
0
        private void PushTransactions(MultiValueDictionary <string, TransactionEntry.Entity> buckets,
                                      IEnumerable <TransactionEntry.Entity> indexedTransactions,
                                      BlockingCollection <TransactionEntry.Entity[]> transactions)
        {
            var array = indexedTransactions.ToArray();

            transactions.Add(array);
            buckets.Remove(array[0].PartitionKey);
        }
Ejemplo n.º 20
0
        public void CanAddAndRemoveItems()
        {
            var multRange = Enumerable.Range(0, 10);
            var multTable = multRange.
                            SelectMany(l => multRange.Select(r => (Index: l, Value: l * r)));
            var multDict = new MultiValueDictionary <int, int>();

            foreach (var item in multTable)
            {
                multDict.Add(item.Index, item.Value);
            }

            Assert.True(multDict.Count == 10);
            multDict.Remove(1, 1);
            Assert.True(multDict.Count == 10);
            Assert.DoesNotContain(1, multDict[1]);
            multDict.Remove(2);
            Assert.True(multDict.Count == 9);
        }
    public void RemoveKey()
    {
        var dictionary = new MultiValueDictionary <string, string>();

        dictionary.AddValue("Key", "Value");

        dictionary.Remove("Key");

        Assert.DoesNotContain("Key", dictionary.Keys);
    }
Ejemplo n.º 22
0
 private void RemovePolyline(InternalPolyline polyline)
 {
     foreach (InternalPolyline item in (from pairs in tablePolyline
                                        from line in pairs.Value
                                        where line.Id == polyline.Id
                                        select line).ToList())
     {
         tablePolyline.Remove(item.Points.Last(), item);
     }
 }
Ejemplo n.º 23
0
        public HashSet <Entity> GetEntitiesWaitingForManagedPacket(ulong commandPacketId)
        {
            if (m_entitiesWaitingForManagedRpcCommandResult.TryGetValue(commandPacketId, out var result))
            {
                m_entitiesWaitingForManagedRpcCommandResult.Remove(commandPacketId);
                return(result);
            }

            return(null);
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Removes a header from the article with the given key and value. If no
 /// value is provided all headers with the given key are removed.
 /// </summary>
 /// <param name="key">The key of the header(s) to remove.</param>
 /// <param name="value">The value of the header to remove.</param>
 /// <returns>The <see cref="NntpArticleBuilder"/> so that additional calls can be chained.</returns>
 public NntpArticleBuilder RemoveHeader(string key, string value = null)
 {
     Guard.ThrowIfNullOrWhiteSpace(key, nameof(key));
     if (reservedHeaderKeys.Contains(key))
     {
         throw new NntpException(Resources.Nntp.ReservedHeaderKeyNotAllowed);
     }
     headers.Remove(key, value);
     return(this);
 }
        public void RemoveTest2()
        {
            var t = new MultiValueDictionary <int, int>();

            t.Add(1, 3);
            t.Add(1, 4);
            t.Add(1, 5);
            t.Add(2, 3);
            t.Add(2, 4);

            t.Remove(1, 3);
            Assert.Equal(new[] { 4, 5 }, t[1].OrderBy(x => x));
            t.Remove(1, 5);
            Assert.Equal(new[] { 4 }, t[1].OrderBy(x => x));
            t.Remove(2, 4);
            Assert.Equal(new[] { 3 }, t[2].OrderBy(x => x));
            t.Remove(1, 4);
            Assert.False(t.ContainsKey(1));
        }
Ejemplo n.º 26
0
        private static IList <string> ExtractTraitValues(MultiValueDictionary <string, string> traits, string traitName)
        {
            var values = from key in traits.Keys
                         where string.Compare(key, traitName, StringComparison.OrdinalIgnoreCase) == 0
                         from value in traits[key]
                         select value;

            traits.Remove(traitName);

            return(values.ToList());
        }
Ejemplo n.º 27
0
        protected void SetSagaKey(string name, string value)
        {
            var newKeys = new MultiValueDictionary <string, string>(keys);

            newKeys.Remove(name);
            newKeys.Add(name, value);

            Publish(new SagaKeysChangedEvent(
                        newKeys
                        .Select(x => new KeyValuePair <string, ImmutableList <string> >(x.Key, x.Value.ToImmutableList()))
                        .ToImmutableDictionary()));
        }
Ejemplo n.º 28
0
 private void RemoveSchedulingForInitiative(InternalEventScheduling es)
 {
     if (es?.Initiative is InternalInitiative init)
     {
         scheduledEventsForInitiatives.Remove(init, es);
         if (init.AutoRemove && !scheduledEventsForInitiatives.AnyValues(init))
         {
             // Get rid of an AutoRemove Initiative when there are no more scheduled events referencing it
             scheduledEventsForInitiatives.Clear(init);
             oc.Remove(init);
         }
     }
 }
Ejemplo n.º 29
0
            public void DeleteEvents(string titleToDelete)
            {
                string title   = titleToDelete.ToLower();
                int    removed = 0;

                foreach (var eventToRemove in byTitle[title])
                {
                    removed++;
                    byDate.Remove(eventToRemove);
                }
                byTitle.Remove(title);
                Messages.EventDeleted(removed);
            }
        public void FullCountTest()
        {
            var t = new MultiValueDictionary <int, int>();

            Assert.Equal(0, t.FullCount);
            t.Add(1, 3);
            t.Add(1, 3);
            t.Add(2, 3);
            Assert.Equal(3, t.FullCount);
            t.Add(1, 4);
            Assert.Equal(4, t.FullCount);
            t.Remove(1, 3);
            Assert.Equal(3, t.FullCount);
        }
Ejemplo n.º 31
0
        public void AddTile(Tile tile)
        {
            if (!PointInRectangle(MinGridPosition, MaxGridPosition - MinGridPosition, tile.BaseData.GridPosition))
            {
                return;
            }

            var tileType     = TileTypes[tile.BaseData.TileTypeId];
            var gridPos      = tile.BaseData.GridPosition;
            var superGridPos = GridToSuperGrid(gridPos);

            var superGridTiles = GetPointNeighbors(superGridPos).Select(item => (item, GetTiles(item).ToArray()));

            foreach (var(pos, tiles) in superGridTiles)
            {
                foreach (var otherTile in tiles.Where(item => TilesOverlap(tile, item)))
                {
                    var result = _superGrid.Remove(pos, otherTile);
                    DebugEx.Assert(result, "We should be able to remove the tile from the place we just found it in.");
                }
            }

            FastAddTile(tile);
        }
Ejemplo n.º 32
0
        public void MultiValueDictionaryRemoveTest()
        {
            MultiValueDictionary <Int32, String> dictionary = new MultiValueDictionary <Int32, String>();

            foreach (KeyValuePair <Int32, List <String> > value in this.values)
            {
                dictionary.Add(value.Key, value.Value);
            }

            dictionary.Remove(0, "0").ShouldBeFalse();
            dictionary.Remove(1, "1").ShouldBeTrue();
            dictionary.Remove(1, "1").ShouldBeFalse();
            dictionary.Remove(1, "11").ShouldBeTrue();
            dictionary.Remove(1, "11").ShouldBeFalse();

            dictionary = new MultiValueDictionary <Int32, String>();

            foreach (KeyValuePair <Int32, List <String> > value in this.values)
            {
                dictionary.Add(value.Key, value.Value);
            }

            dictionary.Remove(0).ShouldBeFalse();
            dictionary.Remove(1).ShouldBeTrue();
            dictionary.Remove(1).ShouldBeFalse();

            (dictionary as ICollection <KeyValuePair <Int32, ICollection <String> > >).Add(new KeyValuePair <Int32, ICollection <String> >(3, new List <String> {
                "3"
            } as ICollection <String>));
            (dictionary as ICollection <KeyValuePair <Int32, ICollection <String> > >).Remove(new KeyValuePair <Int32, ICollection <String> >(3, new List <String> {
                "3"
            } as ICollection <String>)).ShouldBeTrue();
            (dictionary as ICollection <KeyValuePair <Int32, ICollection <String> > >).Remove(new KeyValuePair <Int32, ICollection <String> >(3, new List <String> {
                "3"
            } as ICollection <String>)).ShouldBeFalse();
        }
Ejemplo n.º 33
0
        public void Remove(int size)
        {
            MultiValueDictionary<int, int> dict = new MultiValueDictionary<int, int>();
            for (int i = 0; i < size; i++)
                for (int j = 0; j < 100; j++)
                    dict.Add(i, j);

            foreach (var iteration in Benchmark.Iterations)
            {
                MultiValueDictionary<int, int> copyDict = new MultiValueDictionary<int, int>(dict);
                using (iteration.StartMeasurement())
                    for (int i = 0; i <= size; i++)
                    {
                        copyDict.Remove(i);
                    }
            }
        }
Ejemplo n.º 34
0
    public void RemoveKeyForUnknownKeyDoesNotThrow()
    {
        var dictionary = new MultiValueDictionary<string, string>();

        Assert.DoesNotThrow(() => dictionary.Remove("Key"));
    }
Ejemplo n.º 35
0
 private void Persist(Block block)
 {
     MultiValueDictionary<UInt256, ushort> unspents = new MultiValueDictionary<UInt256, ushort>(p =>
     {
         Slice value = new byte[0];
         db.TryGet(ReadOptions.Default, SliceBuilder.Begin(DataEntryPrefix.IX_Unspent).Add(p), out value);
         return new HashSet<ushort>(value.ToArray().GetUInt16Array());
     });
     MultiValueDictionary<UInt256, ushort> unspent_antshares = new MultiValueDictionary<UInt256, ushort>(p =>
     {
         Slice value = new byte[0];
         db.TryGet(ReadOptions.Default, SliceBuilder.Begin(DataEntryPrefix.IX_AntShare).Add(p), out value);
         return new HashSet<ushort>(value.ToArray().GetUInt16Array());
     });
     MultiValueDictionary<UInt256, ushort> unspent_votes = new MultiValueDictionary<UInt256, ushort>(p =>
     {
         Slice value = new byte[0];
         db.TryGet(ReadOptions.Default, SliceBuilder.Begin(DataEntryPrefix.IX_Vote).Add(p), out value);
         return new HashSet<ushort>(value.ToArray().GetUInt16Array());
     });
     Dictionary<UInt256, Fixed8> quantities = new Dictionary<UInt256, Fixed8>();
     WriteBatch batch = new WriteBatch();
     batch.Put(SliceBuilder.Begin(DataEntryPrefix.DATA_Block).Add(block.Hash), block.Trim());
     foreach (Transaction tx in block.Transactions)
     {
         batch.Put(SliceBuilder.Begin(DataEntryPrefix.DATA_Transaction).Add(tx.Hash), tx.ToArray());
         switch (tx.Type)
         {
             case TransactionType.IssueTransaction:
                 foreach (TransactionResult result in tx.GetTransactionResults().Where(p => p.Amount < Fixed8.Zero))
                 {
                     if (quantities.ContainsKey(result.AssetId))
                     {
                         quantities[result.AssetId] -= result.Amount;
                     }
                     else
                     {
                         quantities.Add(result.AssetId, -result.Amount);
                     }
                 }
                 break;
             case TransactionType.EnrollmentTransaction:
                 {
                     EnrollmentTransaction enroll_tx = (EnrollmentTransaction)tx;
                     batch.Put(SliceBuilder.Begin(DataEntryPrefix.IX_Enrollment).Add(tx.Hash), true);
                 }
                 break;
             case TransactionType.VotingTransaction:
                 unspent_votes.AddEmpty(tx.Hash);
                 for (ushort index = 0; index < tx.Outputs.Length; index++)
                 {
                     if (tx.Outputs[index].AssetId == AntShare.Hash)
                     {
                         unspent_votes.Add(tx.Hash, index);
                     }
                 }
                 break;
             case TransactionType.RegisterTransaction:
                 {
                     RegisterTransaction reg_tx = (RegisterTransaction)tx;
                     batch.Put(SliceBuilder.Begin(DataEntryPrefix.IX_Asset).Add(reg_tx.Hash), true);
                 }
                 break;
         }
         unspents.AddEmpty(tx.Hash);
         unspent_antshares.AddEmpty(tx.Hash);
         for (ushort index = 0; index < tx.Outputs.Length; index++)
         {
             unspents.Add(tx.Hash, index);
             if (tx.Outputs[index].AssetId == AntShare.Hash)
             {
                 unspent_antshares.Add(tx.Hash, index);
             }
         }
     }
     foreach (TransactionInput input in block.Transactions.SelectMany(p => p.GetAllInputs()))
     {
         if (input.PrevIndex == 0)
         {
             batch.Delete(SliceBuilder.Begin(DataEntryPrefix.IX_Enrollment).Add(input.PrevHash));
         }
         unspents.Remove(input.PrevHash, input.PrevIndex);
         unspent_antshares.Remove(input.PrevHash, input.PrevIndex);
         unspent_votes.Remove(input.PrevHash, input.PrevIndex);
     }
     //统计AntCoin的发行量
     {
         Fixed8 amount_in = block.Transactions.SelectMany(p => p.References.Values.Where(o => o.AssetId == AntCoin.Hash)).Sum(p => p.Value);
         Fixed8 amount_out = block.Transactions.SelectMany(p => p.Outputs.Where(o => o.AssetId == AntCoin.Hash)).Sum(p => p.Value);
         if (amount_in != amount_out)
         {
             quantities.Add(AntCoin.Hash, amount_out - amount_in);
         }
     }
     foreach (var unspent in unspents)
     {
         if (unspent.Value.Count == 0)
         {
             batch.Delete(SliceBuilder.Begin(DataEntryPrefix.IX_Unspent).Add(unspent.Key));
         }
         else
         {
             batch.Put(SliceBuilder.Begin(DataEntryPrefix.IX_Unspent).Add(unspent.Key), unspent.Value.ToByteArray());
         }
     }
     foreach (var unspent in unspent_antshares)
     {
         if (unspent.Value.Count == 0)
         {
             batch.Delete(SliceBuilder.Begin(DataEntryPrefix.IX_AntShare).Add(unspent.Key));
         }
         else
         {
             batch.Put(SliceBuilder.Begin(DataEntryPrefix.IX_AntShare).Add(unspent.Key), unspent.Value.ToByteArray());
         }
     }
     foreach (var unspent in unspent_votes)
     {
         if (unspent.Value.Count == 0)
         {
             batch.Delete(SliceBuilder.Begin(DataEntryPrefix.IX_Vote).Add(unspent.Key));
         }
         else
         {
             batch.Put(SliceBuilder.Begin(DataEntryPrefix.IX_Vote).Add(unspent.Key), unspent.Value.ToByteArray());
         }
     }
     foreach (var quantity in quantities)
     {
         batch.Put(SliceBuilder.Begin(DataEntryPrefix.ST_QuantityIssued).Add(quantity.Key), (GetQuantityIssued(quantity.Key) + quantity.Value).GetData());
     }
     current_block_hash = block.Hash;
     current_block_height = block.Hash == GenesisBlock.Hash ? 0 : current_block_height + 1;
     batch.Put(SliceBuilder.Begin(DataEntryPrefix.SYS_CurrentBlock), SliceBuilder.Begin().Add(block.Hash).Add(current_block_height));
     db.Write(WriteOptions.Default, batch);
 }
Ejemplo n.º 36
0
 private void PushTransactions(MultiValueDictionary<string, TransactionEntry.Entity> buckets,
                                 IEnumerable<TransactionEntry.Entity> indexedTransactions,
                             BlockingCollection<TransactionEntry.Entity[]> transactions)
 {
     var array = indexedTransactions.ToArray();
     transactions.Add(array);
     buckets.Remove(array[0].PartitionKey);
 }