Skip to content

Commit

Permalink
Pass headers by reference
Browse files Browse the repository at this point in the history
  • Loading branch information
Coding-Enthusiast committed Sep 18, 2024
1 parent e5372df commit 1fa1ce9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Src/Autarkysoft.Bitcoin/Blockchain/BlockVerifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public BlockVerifier(ITransactionVerifier txVerifier, IConsensus consensus)


/// <inheritdoc/>
public bool VerifyHeader(BlockHeader header, Target expectedTarget)
public bool VerifyHeader(in BlockHeader header, Target expectedTarget)
{
Digest256 tar = header.NBits.ToDigest256();
return header.Version >= consensus.MinBlockVersion &&
Expand Down
2 changes: 1 addition & 1 deletion Src/Autarkysoft.Bitcoin/Blockchain/Blocks/BlockHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public readonly struct BlockHeader
/// <param name="tip">The last valid block in the chain</param>
/// <param name="merkle">Merkle root hash</param>
/// <param name="nbits">Block target</param>
public BlockHeader(IConsensus consensus, BlockHeader tip, in Digest256 merkle, Target nbits)
public BlockHeader(IConsensus consensus, in BlockHeader tip, in Digest256 merkle, Target nbits)
: this(consensus.MinBlockVersion, tip.Hash, merkle, (uint)UnixTimeStamp.GetEpochUtcNow(), nbits, 0)
{
}
Expand Down
4 changes: 2 additions & 2 deletions Src/Autarkysoft.Bitcoin/Blockchain/IBlockVerifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public interface IBlockVerifier
/// The target that this header must have (calculated considering difficulty adjustment)
/// </param>
/// <returns>True if the given block header was valid; otherwise false.</returns>
bool VerifyHeader(BlockHeader header, Target expectedTarget);
bool VerifyHeader(in BlockHeader header, Target expectedTarget);

/// <summary>
/// Verifies validity of the given block. Return value indicates succcess.
/// <para/>Header has to be verified before using <see cref="VerifyHeader(BlockHeader, Target)"/> method.
/// <para/>Header has to be verified before using <see cref="VerifyHeader(in BlockHeader, Target)"/> method.
/// <para/><see cref="IConsensus"/> dependency has to be updated by the caller before calling this method.
/// </summary>
/// <param name="block">Block to use</param>
Expand Down

0 comments on commit 1fa1ce9

Please sign in to comment.