Created
April 6, 2014 13:35
-
-
Save qikcoin/10006167 to your computer and use it in GitHub Desktop.
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
from: | |
https://code.google.com/p/blockchain/source/browse/trunk/BlockChain.cpp | |
inline uint32_t readVariableLengthInteger(void) | |
{ | |
uint32_t ret = 0; | |
uint8_t v = readU8(); | |
if ( v < 0xFD ) // If it's less than 0xFD use this value as the unsigned integer | |
{ | |
ret = (uint32_t)v; | |
} | |
else | |
{ | |
uint16_t v = readU16(); | |
if ( v < 0xFFFF ) | |
{ | |
ret = (uint32_t)v; | |
} | |
else | |
{ | |
uint32_t v = readU32(); | |
if ( v < 0xFFFFFFFF ) | |
{ | |
ret = (uint32_t)v; | |
} | |
else | |
{ | |
assert(0); // never expect to actually encounter a 64bit integer in the block-chain stream; it's outside of any reasonable expected value | |
uint64_t v = readU64(); | |
ret = (uint32_t)v; | |
} | |
} | |
} | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment