Skip to content

Commit

Permalink
Cache most recent block (#1592)
Browse files Browse the repository at this point in the history
  • Loading branch information
Qiao-Jin committed Apr 26, 2020
1 parent a5cf5b2 commit 55f2d7e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/neo/Ledger/Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ private VerifyResult OnNewBlock(Block block)
if (!block.Hash.Equals(header_index[(int)block.Index]))
return VerifyResult.Invalid;
}
block_cache.TryAdd(block.Hash, block);
if (block.Index == Height + 1)
{
Block block_persist = block;
Expand Down Expand Up @@ -370,7 +371,6 @@ private VerifyResult OnNewBlock(Block block)
}
else
{
block_cache.Add(block.Hash, block);
if (block.Index + 100 >= header_index.Count)
system.LocalNode.Tell(new LocalNode.RelayDirectly { Inventory = block });
if (block.Index == header_index.Count)
Expand Down Expand Up @@ -430,7 +430,7 @@ private VerifyResult OnNewTransaction(Transaction transaction)

private void OnPersistCompleted(Block block)
{
block_cache.Remove(block.Hash);
block_cache.Remove(block.PrevHash);
MemPool.UpdatePoolForBlockPersisted(block, currentSnapshot);
Context.System.EventStream.Publish(new PersistCompleted { Block = block });
}
Expand Down

0 comments on commit 55f2d7e

Please sign in to comment.