Skip to content
Merged
Changes from 4 commits
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
17 changes: 5 additions & 12 deletions src/Nethermind/Nethermind.Facade/Eth/BlockForRpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,21 @@ namespace Nethermind.Facade.Eth;
public class BlockForRpc
{
private static readonly BlockDecoder _blockDecoder = new();
private readonly bool _isAuRaBlock;

public BlockForRpc() { }

[SkipLocalsInit]
public BlockForRpc(Block block, bool includeFullTransactionData, ISpecProvider specProvider, bool skipTxs = false)
{
_isAuRaBlock = block.Header.AuRaSignature is not null;
bool isAuRaBlock = block.Header.AuRaSignature is not null;
Difficulty = block.Difficulty;
ExtraData = block.ExtraData;
GasLimit = block.GasLimit;
GasUsed = block.GasUsed;
Hash = block.Hash;
LogsBloom = block.Bloom;
Miner = block.Beneficiary;
if (!_isAuRaBlock)
if (!isAuRaBlock)
{
MixHash = block.MixHash;
Nonce = new byte[8];
Expand Down Expand Up @@ -106,29 +105,23 @@ public BlockForRpc(Block block, bool includeFullTransactionData, ISpecProvider s
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public Bloom LogsBloom { get; set; }
public Address Miner { get; set; }
public Hash256 MixHash { get; set; }

public bool ShouldSerializeMixHash() => !_isAuRaBlock && MixHash is not null;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it makes sense to keep _isAuRaBlock as field then?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it makes sense to keep _isAuRaBlock as field then?

I think no

public Hash256? MixHash { get; set; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public byte[] Nonce { get; set; }

public bool ShouldSerializeNonce() => !_isAuRaBlock;
public byte[]? Nonce { get; set; }

[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public long? Number { get; set; }
public Hash256 ParentHash { get; set; }
public Hash256 ReceiptsRoot { get; set; }
public Hash256 Sha3Uncles { get; set; }
public byte[] Signature { get; set; }
public bool ShouldSerializeSignature() => _isAuRaBlock;
public byte[]? Signature { get; set; }
public long Size { get; set; }
public Hash256 StateRoot { get; set; }
[JsonConverter(typeof(NullableRawLongConverter))]
public long? Step { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public UInt256? TotalDifficulty { get; set; }
public bool ShouldSerializeStep() => _isAuRaBlock;
public UInt256 Timestamp { get; set; }

public UInt256? BaseFeePerGas { get; set; }
Expand Down
Loading