Lookup the assetFee from a sorted array of feeOutputs by the given assetid, returning 0 if no entry is found. * * Precondition: NULL != assetid; * feeOutputs is uniquely sorted by it asset.data.s field, which is to say * for all 0 <= i < j < len, * 0 < memcmp(feeOutputs[j]->asset.data.s, feeOutputs[i]->asset.data.s, sizeof(feeOutputs[i]->asset.data.
| 174 | * 0 < memcmp(feeOutputs[j]->asset.data.s, feeOutputs[i]->asset.data.s, sizeof(feeOutputs[i]->asset.data.s)); |
| 175 | */ |
| 176 | static uint_fast64_t lookup_fee(const sha256_midstate* assetid, const sigOutput* const * feeOutputs, uint_fast32_t len) { |
| 177 | /* This loop runs in O(log(len)) time. */ |
| 178 | while(len) { |
| 179 | int cmp = memcmp(assetid->s, feeOutputs[len/2]->asset.data.s, sizeof(assetid->s)); |
| 180 | if (0 == cmp) return feeOutputs[len/2]->assetFee; |
| 181 | if (0 < cmp) { |
| 182 | feeOutputs += len/2 + 1; |
| 183 | len -= len/2 + 1; |
| 184 | } else { |
| 185 | len /= 2; |
| 186 | } |
| 187 | } |
| 188 | return 0; |
| 189 | } |
| 190 | |
| 191 | /* version : ONE |- TWO^32 */ |
| 192 | bool simplicity_version(frameItem* dst, frameItem src, const txEnv* env) { |
no outgoing calls
no test coverage detected