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

Function decodeDag

src/simplicity/deserialize.c:155–163  ·  view source on GitHub ↗

Decode a Simplicity DAG consisting of 'len' nodes from 'stream' into 'dag'. * Returns 'SIMPLICITY_ERR_DATA_OUT_OF_RANGE' if some node's child isn't a reference to one of the preceding nodes. * Returns 'SIMPLICITY_ERR_FAIL_CODE' if the encoding of a fail expression is encountered * (all fail subexpressions ought to have been pruned prior to deserialization). * Returns 'SIMPLICITY_ERR_RESERVED

Source from the content-addressed store, hash-verified

153 * NULL != stream
154 */
155static simplicity_err decodeDag(dag_node* dag, simplicity_callback_decodeJet decodeJet, const uint_fast32_t len, combinator_counters* census, bitstream* stream) {
156 for (uint_fast32_t i = 0; i < len; ++i) {
157 simplicity_err error = decodeNode(dag, decodeJet, i, stream);
158 if (!IS_OK(error)) return error;
159
160 enumerator(census, dag[i].tag);
161 }
162 return SIMPLICITY_NO_ERROR;
163}
164
165/* Decode a length-prefixed Simplicity DAG from 'stream'.
166 * Returns 'SIMPLICITY_ERR_DATA_OUT_OF_RANGE' the length prefix's value is too large.

Callers 1

Calls 3

decodeNodeFunction · 0.85
IS_OKFunction · 0.85
enumeratorFunction · 0.85

Tested by

no test coverage detected