-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* add GetFullBlocks P2P logic * add missing new line * allow request genesis block * Optimization * Update MessageCommand.cs * - rename command - fix protocol handler cast - fix payload deserialization for default value * change to ushort per review * remove default count, rename class * typo + failed refactor coverage ¯\_(ツ)_/¯
- Loading branch information
Showing
4 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Neo.IO; | ||
using System; | ||
using System.IO; | ||
|
||
namespace Neo.Network.P2P.Payloads | ||
{ | ||
public class GetBlockDataPayload : ISerializable | ||
{ | ||
private const ushort MaxBlocksCount = 500; | ||
public uint IndexStart; | ||
public ushort Count; | ||
|
||
public int Size => sizeof(uint) + sizeof(ushort); | ||
|
||
public static GetBlockDataPayload Create(uint index_start, ushort count) | ||
{ | ||
return new GetBlockDataPayload | ||
{ | ||
IndexStart = index_start, | ||
Count = count | ||
}; | ||
} | ||
|
||
void ISerializable.Deserialize(BinaryReader reader) | ||
{ | ||
IndexStart = reader.ReadUInt32(); | ||
Count = reader.ReadUInt16(); | ||
if (Count == 0 || Count > MaxBlocksCount) throw new FormatException(); | ||
} | ||
|
||
void ISerializable.Serialize(BinaryWriter writer) | ||
{ | ||
writer.Write(IndexStart); | ||
writer.Write(Count); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters