Skip to content

Commit

Permalink
Sort unrelated grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
erikzhang committed Jul 26, 2019
1 parent 50c51da commit 41ce918
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions neo/IO/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,16 @@ public static byte[] ReadBytesWithGrouping(this BinaryReader reader)
{
using (MemoryStream ms = new MemoryStream())
{
int padding = 0;
int count;
do
{
byte[] group = reader.ReadBytes(GroupingSizeInBytes);
padding = reader.ReadByte();
if (padding > GroupingSizeInBytes)
count = reader.ReadByte();
if (count > GroupingSizeInBytes)
throw new FormatException();
int count = GroupingSizeInBytes - padding;
if (count > 0)
ms.Write(group, 0, count);
} while (padding == 0);
} while (count == GroupingSizeInBytes);
return ms.ToArray();
}
}
Expand Down Expand Up @@ -200,7 +199,7 @@ public static void WriteBytesWithGrouping(this BinaryWriter writer, byte[] value
while (remain >= GroupingSizeInBytes)
{
writer.Write(value, index, GroupingSizeInBytes);
writer.Write((byte)0);
writer.Write((byte)GroupingSizeInBytes);
index += GroupingSizeInBytes;
remain -= GroupingSizeInBytes;
}
Expand All @@ -209,7 +208,7 @@ public static void WriteBytesWithGrouping(this BinaryWriter writer, byte[] value
int padding = GroupingSizeInBytes - remain;
for (int i = 0; i < padding; i++)
writer.Write((byte)0);
writer.Write((byte)padding);
writer.Write((byte)remain);
}

public static void WriteFixedString(this BinaryWriter writer, string value, int length)
Expand Down
2 changes: 1 addition & 1 deletion neo/SmartContract/InteropService.NEO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ private static bool Storage_Find(ApplicationEngine engine)
while (remain >= 16)
{
ms.Write(prefix, index, 16);
ms.WriteByte(0);
ms.WriteByte(16);
index += 16;
remain -= 16;
}
Expand Down

0 comments on commit 41ce918

Please sign in to comment.