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

Function WriteCompactSize

src/serialize.h:244–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

242
243template<typename Stream>
244void WriteCompactSize(Stream& os, uint64_t nSize)
245{
246 if (nSize < 253)
247 {
248 ser_writedata8(os, nSize);
249 }
250 else if (nSize <= std::numeric_limits<uint16_t>::max())
251 {
252 ser_writedata8(os, 253);
253 ser_writedata16(os, nSize);
254 }
255 else if (nSize <= std::numeric_limits<unsigned int>::max())
256 {
257 ser_writedata8(os, 254);
258 ser_writedata32(os, nSize);
259 }
260 else
261 {
262 ser_writedata8(os, 255);
263 ser_writedata64(os, nSize);
264 }
265 return;
266}
267
268/**
269 * Decode a CompactSize-encoded variable-length integer.

Callers 14

SerMethod · 0.85
SerMethod · 0.85
SerializeFunction · 0.85
Serialize_implFunction · 0.85
SerializeToVectorFunction · 0.85
SerializeHDKeypathFunction · 0.85
GCSFilterMethod · 0.85
SerializeMethod · 0.85
SerializeScriptCodeMethod · 0.85
SerializeMethod · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 6

ser_writedata8Function · 0.85
ser_writedata16Function · 0.85
ser_writedata32Function · 0.85
ser_writedata64Function · 0.85
GetSizeOfCompactSizeFunction · 0.85
seekMethod · 0.45

Tested by 4

BOOST_AUTO_TEST_CASEFunction · 0.68
BOOST_AUTO_TEST_CASEFunction · 0.68
FUZZ_TARGET_INITFunction · 0.68
FUZZ_TARGETFunction · 0.68