static int parse_child_option(struct isl_arg *decl, char **arg, struct isl_prefixes *prefixes, void *opt) { void *child; int first, parsed; if (decl->offset == (size_t) -1) child = opt; else child = *(void **)(((char *)opt) + decl->offset); first = add_prefix(prefixes, decl->long_name); parsed = parse_option(decl->u.child.child->args, arg, prefixes, child); drop_prefix(prefixes, first); return parsed; }
void list_cmds_by_category(struct string_list *list, const char *cat) { int i, n = ARRAY_SIZE(command_list); uint32_t cat_id = 0; for (i = 0; category_names[i]; i++) { if (!strcmp(cat, category_names[i])) { cat_id = 1UL << i; break; } } if (!cat_id) die(_("unsupported command listing type '%s'"), cat); for (i = 0; i < n; i++) { struct cmdname_help *cmd = command_list + i; if (!(cmd->category & cat_id)) continue; string_list_append(list, drop_prefix(cmd->name, cmd->category)); } }
void history_scan_database::scan(const address_bitset& key, read_function read_func, size_t from_height) const { BITCOIN_ASSERT(key.size() >= settings_.sharded_bitsize); const hsdb_shard& shard = lookup(key); address_bitset sub_key = drop_prefix(key); auto read_wrapped = [&read_func](const uint8_t* data) { auto deserial = make_deserializer_unsafe(data); history_row row{ // output or spend? marker_to_id(deserial.read_byte()), // point deserial.read_hash(), deserial.read_4_bytes(), // height deserial.read_4_bytes(), // value or checksum deserial.read_8_bytes()}; read_func(row); }; shard.scan(sub_key, read_wrapped, from_height); }
void history_scan_database::add(const address_bitset& key, const uint8_t marker, const point_type& point, uint32_t block_height, uint64_t value) { BITCOIN_ASSERT(key.size() >= settings_.sharded_bitsize); // Both add() and sync() must have identical lookup of shards. hsdb_shard& shard = lookup(key); address_bitset sub_key = drop_prefix(key); BITCOIN_ASSERT(sub_key.size() == settings_.scan_bitsize()); #ifdef HSDB_DEBUG log_debug(LOG_HSDB) << "Sub key = " << sub_key; #endif data_chunk row_data(settings_.row_value_size); auto serial = make_serializer(row_data.begin()); serial.write_byte(marker); serial.write_hash(point.hash); serial.write_4_bytes(point.index); serial.write_4_bytes(block_height); serial.write_8_bytes(value); BITCOIN_ASSERT(serial.iterator() == row_data.begin() + settings_.row_value_size); shard.add(sub_key, row_data); }
static void extract_cmds(struct cmdname_help **p_cmds, uint32_t mask) { int i, nr = 0; struct cmdname_help *cmds; if (ARRAY_SIZE(command_list) == 0) BUG("empty command_list[] is a sign of broken generate-cmdlist.sh"); ALLOC_ARRAY(cmds, ARRAY_SIZE(command_list) + 1); for (i = 0; i < ARRAY_SIZE(command_list); i++) { const struct cmdname_help *cmd = command_list + i; if (!(cmd->category & mask)) continue; cmds[nr] = *cmd; cmds[nr].name = drop_prefix(cmd->name, cmd->category); nr++; } cmds[nr].name = NULL; *p_cmds = cmds; }
static void print_help(struct isl_arg *arg, struct isl_prefixes *prefixes, void *opt) { int i; int any = 0; for (i = 0; arg[i].type != isl_arg_end; ++i) { if (arg[i].flags & ISL_ARG_HIDDEN) continue; switch (arg[i].type) { case isl_arg_flags: print_flags_help(&arg[i], prefixes, opt); any = 1; break; case isl_arg_choice: print_choice_help(&arg[i], prefixes, opt); any = 1; break; case isl_arg_bool: print_bool_help(&arg[i], prefixes, opt); any = 1; break; case isl_arg_int: print_int_help(&arg[i], prefixes, opt); any = 1; break; case isl_arg_long: print_long_help(&arg[i], prefixes, opt); any = 1; break; case isl_arg_ulong: print_ulong_help(&arg[i], prefixes); any = 1; break; case isl_arg_str: print_str_help(&arg[i], prefixes, opt); any = 1; break; case isl_arg_str_list: print_str_list_help(&arg[i], prefixes); any = 1; break; case isl_arg_alias: case isl_arg_version: case isl_arg_arg: case isl_arg_footer: case isl_arg_child: case isl_arg_user: case isl_arg_end: break; } } for (i = 0; arg[i].type != isl_arg_end; ++i) { void *child; int first; if (arg[i].type != isl_arg_child) continue; if (arg[i].flags & ISL_ARG_HIDDEN) continue; if (any) printf("\n"); if (arg[i].help_msg) printf(" %s\n", arg[i].help_msg); if (arg[i].offset == (size_t) -1) child = opt; else child = *(void **)(((char *) opt) + arg[i].offset); first = add_prefix(prefixes, arg[i].long_name); print_help(arg[i].u.child.child->args, prefixes, child); drop_prefix(prefixes, first); any = 1; } }