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

Function simplicity_read_buffer8

src/simplicity/frame.c:104–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102 * 0 <= n < 16
103 */
104void simplicity_read_buffer8(unsigned char* buf, size_t* len, frameItem* src, int n) {
105 simplicity_debug_assert(0 <= n && n < 16);
106 *len = 0;
107
108 for (size_t i = (size_t)1 << n; 0 < i; i /= 2) {
109 if (readBit(src)) {
110 read8s(buf, i, src);
111 buf += i; *len += i;
112 } else {
113 forwardBits(src, i*8);
114 }
115 }
116}
117
118/* Write 'len' bytes to a Simplicity buffer of type (TWO^8)^<2^(n+1) from 'buf'.
119 * Advance the 'dst' frame to the end of the buffer type.

Calls 3

readBitFunction · 0.85
read8sFunction · 0.85
forwardBitsFunction · 0.85

Tested by

no test coverage detected