Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache most recent block #1592

Merged
merged 12 commits into from
Apr 26, 2020
4 changes: 2 additions & 2 deletions src/neo/Ledger/Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,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 All @@ -386,6 +385,7 @@ private VerifyResult OnNewBlock(Block block)
UpdateCurrentSnapshot();
}
}
block_cache[block.Hash] = block;
return VerifyResult.Succeed;
}

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