MCPcopy Create free account
hub / github.com/ElementsProject/elements / GetSizeOfCompactSize

Function GetSizeOfCompactSize

src/serialize.h:233–239  ·  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

231 * size > UINT_MAX -- 9 bytes (255 + 8 bytes)
232 */
233inline unsigned int GetSizeOfCompactSize(uint64_t nSize)
234{
235 if (nSize < 253) return sizeof(unsigned char);
236 else if (nSize <= std::numeric_limits<uint16_t>::max()) return sizeof(unsigned char) + sizeof(uint16_t);
237 else if (nSize <= std::numeric_limits<unsigned int>::max()) return sizeof(unsigned char) + sizeof(unsigned int);
238 else return sizeof(unsigned char) + sizeof(uint64_t);
239}
240
241inline void WriteCompactSize(CSizeComputer& os, uint64_t nSize);
242

Callers 4

WriteCompactSizeFunction · 0.85
FillInputToWeightFunction · 0.85
FUZZ_TARGET_INITFunction · 0.85
WriteBlockMethod · 0.85

Calls

no outgoing calls

Tested by 1

FUZZ_TARGET_INITFunction · 0.68