Skip to content

Commit

Permalink
fix block_cache_unverified
Browse files Browse the repository at this point in the history
  • Loading branch information
Qiao Jin committed Dec 1, 2020
1 parent fa147a4 commit 7b6c48f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions neo/Ledger/Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public class FillCompleted { }
private readonly List<UInt256> header_index = new List<UInt256>();
private uint stored_header_count = 0;
private readonly ConcurrentDictionary<UInt256, Block> block_cache = new ConcurrentDictionary<UInt256, Block>();
private readonly Dictionary<uint, LinkedList<Block>> block_cache_unverified = new Dictionary<uint, LinkedList<Block>>();
private readonly ConcurrentDictionary<uint, LinkedList<Block>> block_cache_unverified = new ConcurrentDictionary<uint, LinkedList<Block>>();
internal readonly RelayCache RelayCache = new RelayCache(100);
private Snapshot currentSnapshot;

Expand Down Expand Up @@ -244,7 +244,7 @@ private void AddUnverifiedBlockToCache(Block block)
if (!block_cache_unverified.TryGetValue(block.Index, out LinkedList<Block> blocks))
{
blocks = new LinkedList<Block>();
block_cache_unverified.Add(block.Index, blocks);
block_cache_unverified.TryAdd(block.Index, blocks);
}

blocks.AddLast(block);
Expand Down Expand Up @@ -313,7 +313,7 @@ private RelayResultReason OnNewBlock(Block block)
int blocksPersisted = 0;
foreach (Block blockToPersist in blocksToPersistList)
{
block_cache_unverified.Remove(blockToPersist.Index);
block_cache_unverified.TryRemove(blockToPersist.Index, out _);
Persist(blockToPersist);

if (blocksPersisted++ < blocksToPersistList.Count - (2 + Math.Max(0, (15 - SecondsPerBlock)))) continue;
Expand All @@ -329,7 +329,7 @@ private RelayResultReason OnNewBlock(Block block)
{
foreach (var unverifiedBlock in unverifiedBlocks)
Self.Tell(unverifiedBlock, ActorRefs.NoSender);
block_cache_unverified.Remove(Height + 1);
block_cache_unverified.TryRemove(Height + 1, out _);
}
}
else
Expand Down

0 comments on commit 7b6c48f

Please sign in to comment.