X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=Novacoin%2FVarInt.cs;h=4ebab9de16545fb17a60a92c416dbcc640fb6bd8;hb=0aa2d5cb7cdb5813440e7afcdbe6014e9b8deeee;hp=edca418c8b4795deca5c29a7b63d308231057711;hpb=1edac525d07f68f781fea5d5fcc91c548623d912;p=NovacoinLibrary.git
diff --git a/Novacoin/VarInt.cs b/Novacoin/VarInt.cs
index edca418..4ebab9d 100644
--- a/Novacoin/VarInt.cs
+++ b/Novacoin/VarInt.cs
@@ -31,9 +31,9 @@ namespace Novacoin
///
/// Unsigned integer value
/// Byte sequence
- public static IList EncodeVarInt(ulong n)
+ public static byte[] EncodeVarInt(ulong n)
{
- List resultBytes = new List();
+ var resultBytes = new List();
if (n <= 0xfc)
{
@@ -68,7 +68,7 @@ namespace Novacoin
resultBytes.AddRange(valueBytes);
}
- return resultBytes;
+ return resultBytes.ToArray();
}
///
@@ -78,7 +78,7 @@ namespace Novacoin
///
/// Integer value
/// Byte sequence
- public static IList EncodeVarInt(long n)
+ public static byte[] EncodeVarInt(long n)
{
return EncodeVarInt((ulong)n);
}
@@ -90,13 +90,12 @@ namespace Novacoin
///
/// Byte sequence
/// Integer value
- public static ulong DecodeVarInt(IList bytes)
+ public static ulong DecodeVarInt(byte[] bytes)
{
- byte prefix = bytes[0];
+ var prefix = bytes[0];
+ var bytesArray = new byte[bytes.Length - 1];
- bytes.RemoveAt(0); // Remove prefix
-
- byte[] bytesArray = bytes.ToArray();
+ bytes.CopyTo(bytesArray, 1); // Get rid of prefix
switch (prefix)
{