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

Optimize GetHeader() and GetBlock() #1039

Merged
merged 2 commits into from
Aug 20, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions neo/Persistence/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public static bool ContainsTransaction(this IPersistence persistence, UInt256 ha

public static Block GetBlock(this IPersistence persistence, uint index)
{
if (index == 0) return Blockchain.GenesisBlock;
UInt256 hash = Blockchain.Singleton.GetBlockHash(index);
if (hash == null) return null;
return persistence.GetBlock(hash);
Expand All @@ -35,6 +36,7 @@ public static Block GetBlock(this IPersistence persistence, UInt256 hash)

public static Header GetHeader(this IPersistence persistence, uint index)
{
if (index == 0) return Blockchain.GenesisBlock.Header;
UInt256 hash = Blockchain.Singleton.GetBlockHash(index);
if (hash == null) return null;
return persistence.GetHeader(hash);
Expand Down