Skip to content

Commit

Permalink
Fix calculation size for RecoveryMessage
Browse files Browse the repository at this point in the history
Original from @jsolman but moved to a separated Pull Request
#665
  • Loading branch information
shargon committed Mar 29, 2019
1 parent 30fd1a5 commit ada7419
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions neo/Consensus/RecoveryMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ public partial class RecoveryMessage : ConsensusMessage
public UInt256 PreparationHash;
public Dictionary<int, PreparationPayloadCompact> PreparationMessages;
public Dictionary<int, CommitPayloadCompact> CommitMessages;

public override int Size => base.Size
+ /* ChangeViewMessages */ IO.Helper.GetVarSize(ChangeViewMessages?.Count ?? 0) + ChangeViewMessages?.Values.Sum(p => ((ISerializable)p).Size) ?? 0
+ /* PrepareRequestMessage */ 1 + ((ISerializable) PrepareRequestMessage)?.Size ?? 0
+ /* PreparationHash */ PreparationHash?.Size ?? 0
+ /* PreparationMessages */IO.Helper.GetVarSize(PreparationMessages?.Count ?? 0) + PreparationMessages?.Values.Sum(p => ((ISerializable)p).Size) ?? 0
+ /* CommitMessages */IO.Helper.GetVarSize(CommitMessages?.Count ?? 0) + CommitMessages?.Values.Sum(p => ((ISerializable)p).Size) ?? 0;

public RecoveryMessage() : base(ConsensusMessageType.RecoveryMessage)
{
Expand Down

0 comments on commit ada7419

Please sign in to comment.