Skip to content

Commit

Permalink
fix block_cache (#2111)
Browse files Browse the repository at this point in the history
* fix block_cache

* fix block_cache_unverified

* Revert "fix block_cache_unverified"

This reverts commit ebb42e4.

Co-authored-by: Shargon <[email protected]>
  • Loading branch information
Qiao-Jin and shargon authored Dec 2, 2020
1 parent 2051fdc commit e835631
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/neo/Ledger/Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -62,7 +63,7 @@ public class RelayResult { public IInventory Inventory; public VerifyResult Resu
private readonly IActorRef txrouter;
private readonly List<UInt256> header_index = new List<UInt256>();
private uint stored_header_count = 0;
private readonly Dictionary<UInt256, Block> block_cache = new Dictionary<UInt256, Block>();
private readonly ConcurrentDictionary<UInt256, Block> block_cache = new ConcurrentDictionary<UInt256, Block>();
private readonly Dictionary<uint, UnverifiedBlocksList> block_cache_unverified = new Dictionary<uint, UnverifiedBlocksList>();
internal readonly RelayCache RelayCache = new RelayCache(100);
private SnapshotView currentSnapshot;
Expand Down Expand Up @@ -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 });
}
Expand Down

0 comments on commit e835631

Please sign in to comment.