MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / GetSizeOfCompactSize

Function GetSizeOfCompactSize

src/serialize.h:242–248  ·  view source on GitHub ↗

* Compact Size * size < 253 -- 1 byte * size <= USHRT_MAX -- 3 bytes (253 + 2 bytes) * size <= UINT_MAX -- 5 bytes (254 + 4 bytes) * size > UINT_MAX -- 9 bytes (255 + 8 bytes) */

Source from the content-addressed store, hash-verified

240 * size > UINT_MAX -- 9 bytes (255 + 8 bytes)
241 */
242inline unsigned int GetSizeOfCompactSize(uint64_t nSize)
243{
244 if (nSize < 253) return sizeof(unsigned char);
245 else if (nSize <= std::numeric_limits<unsigned short>::max()) return sizeof(unsigned char) + sizeof(unsigned short);
246 else if (nSize <= std::numeric_limits<unsigned int>::max()) return sizeof(unsigned char) + sizeof(unsigned int);
247 else return sizeof(unsigned char) + sizeof(uint64_t);
248}
249
250inline void WriteCompactSize(CSizeComputer& os, uint64_t nSize);
251

Callers 2

WriteCompactSizeFunction · 0.85
WriteBlockMethod · 0.85

Calls 1

maxFunction · 0.85

Tested by

no test coverage detected