git://git.novaco.in
/
NovacoinLibrary.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
(parent:
308513d
)
VarInt: new GetEncodedSize() method
author
CryptoManiac
<balthazar@yandex.ru>
Fri, 28 Aug 2015 22:26:12 +0000 (
01:26
+0300)
committer
CryptoManiac
<balthazar@yandex.ru>
Fri, 28 Aug 2015 22:26:12 +0000 (
01:26
+0300)
Novacoin/VarInt.cs
patch
|
blob
|
history
diff --git
a/Novacoin/VarInt.cs
b/Novacoin/VarInt.cs
index
d376cae
..
e78d107
100644
(file)
--- a/
Novacoin/VarInt.cs
+++ b/
Novacoin/VarInt.cs
@@
-82,6
+82,26
@@
namespace Novacoin
return EncodeVarInt((ulong)n);
}
+ public static int GetEncodedSize(long n)
+ {
+ if (n <= 0xfc)
+ {
+ return 1;
+ }
+ else if (n <= ushort.MaxValue)
+ {
+ return 3;
+ }
+ else if (n <= uint.MaxValue)
+ {
+ return 5;
+ }
+ else
+ {
+ return 9;
+ }
+ }
+
/// <summary>
/// Decodes integer value from compact representation
///