diff --git a/src/Neo.VM/ReferenceCounterV2.cs b/src/Neo.VM/ReferenceCounterV2.cs deleted file mode 100644 index 42a81cf8d2..0000000000 --- a/src/Neo.VM/ReferenceCounterV2.cs +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (C) 2015-2024 The Neo Project. -// -// ReferenceCounterV2.cs file belongs to the neo project and is free -// software distributed under the MIT software license, see the -// accompanying file LICENSE in the main directory of the -// repository or http://www.opensource.org/licenses/mit-license.php -// for more details. -// -// Redistribution and use in source and binary forms with or without -// modifications are permitted. - -using Neo.VM.Types; -using System; -using System.Collections.Generic; - -namespace Neo.VM -{ - /// - /// Used for reference counting of objects in the VM. - /// - public sealed class ReferenceCounterV2 : IReferenceCounter - { - private class Counter - { - public int Count; - } - - private readonly Dictionary _items = new(ReferenceEqualityComparer.Instance); - - /// - /// Gets the count of references. - /// - public int Count { get; private set; } - - /// - /// Adds item to Reference Counter - /// - /// The item to add. - /// Number of similar entries - public void AddStackReference(StackItem item, int count = 1) - { - if (!_items.TryGetValue(item, out var referencesCount)) - { - _items[item] = new Counter() { Count = count }; - } - else - { - referencesCount.Count += count; - } - - // Increment the reference count. - Count += count; - } - - /// - /// Removes item from Reference Counter - /// - /// The item to remove. - public void RemoveStackReference(StackItem item) - { - if (!_items.TryGetValue(item, out var referencesCount)) - { - throw new InvalidOperationException("Reference was not added"); - } - else - { - referencesCount.Count--; - - if (referencesCount.Count < 0) - { - throw new InvalidOperationException("Reference was not added"); - } - } - - // Decrement the reference count. - Count--; - } - - public void AddReference(StackItem item, CompoundType parent) - { - AddStackReference(item); - } - - public void RemoveReference(StackItem item, CompoundType parent) - { - RemoveStackReference(item); - } - - public void AddZeroReferred(StackItem item) - { - // This version don't use this method - // AddStackReference(item); - } - - /// - /// Checks and processes items that have zero references. - /// - /// The current reference count. - public int CheckZeroReferred() - { - return Count; - } - } -}