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

Function decodePrimitive

src/simplicity/elements/primitive.c:66–78  ·  view source on GitHub ↗

Decode an Elements specific jet name from 'stream' into 'result'. * All jets begin with a bit prefix of '1' which needs to have already been consumed from the 'stream'. * Returns 'SIMPLICITY_ERR_DATA_OUT_OF_RANGE' if the stream's prefix doesn't match any valid code for a jet. * Returns 'SIMPLICITY_ERR_BITSTRING_EOF' if not enough bits are available in the 'stream'. * In the above error cases,

Source from the content-addressed store, hash-verified

64 * NULL != stream
65 */
66static simplicity_err decodePrimitive(jetName* result, bitstream* stream) {
67 int32_t bit = read1Bit(stream);
68 if (bit < 0) return (simplicity_err)bit;
69 if (!bit) {
70 /* Core jets */
71#include "../decodeCoreJets.inc"
72 return SIMPLICITY_ERR_DATA_OUT_OF_RANGE;
73 } else {
74 /* Elements jets */
75#include "decodeElementsJets.inc"
76 return SIMPLICITY_ERR_DATA_OUT_OF_RANGE;
77 }
78}
79
80/* Return a copy of the Simplicity node corresponding to the given Elements specific jet 'name'. */
81static dag_node jetNode(jetName name) {

Callers 1

Calls 1

read1BitFunction · 0.85

Tested by

no test coverage detected