diff --git a/src/neo/Ledger/Blockchain.cs b/src/neo/Ledger/Blockchain.cs index 4418e461d8..b5af18af84 100644 --- a/src/neo/Ledger/Blockchain.cs +++ b/src/neo/Ledger/Blockchain.cs @@ -13,6 +13,7 @@ using Neo.SmartContract.Native; using Neo.VM; using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -62,7 +63,7 @@ public class RelayResult { public IInventory Inventory; public VerifyResult Resu private readonly IActorRef txrouter; private readonly List header_index = new List(); private uint stored_header_count = 0; - private readonly Dictionary block_cache = new Dictionary(); + private readonly ConcurrentDictionary block_cache = new ConcurrentDictionary(); private readonly Dictionary block_cache_unverified = new Dictionary(); internal readonly RelayCache RelayCache = new RelayCache(100); private SnapshotView currentSnapshot; @@ -509,7 +510,7 @@ private void Persist(Block block) if (commitExceptions != null) throw new AggregateException(commitExceptions); } UpdateCurrentSnapshot(); - block_cache.Remove(block.PrevHash); + block_cache.TryRemove(block.PrevHash, out _); MemPool.UpdatePoolForBlockPersisted(block, currentSnapshot); Context.System.EventStream.Publish(new PersistCompleted { Block = block }); }