MCPcopy Create free account
hub / github.com/category-labs/monad / set_table

Method set_table

cmd/monad_cli.cpp:286–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284 }
285
286 void set_table(unsigned char const table_id)
287 {
288 if (state != DbState::proposal_or_finalize) {
289 fmt::println("Error: at wrong part of trie, only allow set table "
290 "when cursor is set to a specific version number.");
291 return;
292 }
293 MONAD_ASSERT(curr_section_prefix.nibble_size() > 0);
294
295 if (table_id == STATE_NIBBLE || table_id == CODE_NIBBLE ||
296 table_id == RECEIPT_NIBBLE) {
297 fmt::println(
298 "Setting cursor to version {}, table {} ...",
299 curr_version,
300 table_as_string(table_id));
301 auto const res =
302 db.find(concat(curr_section_prefix, table_id), curr_version);
303 if (res.has_value()) {
304 NodeCursor const cursor = res.assume_value();
305 state = DbState::table;
306 curr_table_id = table_id;
307 if (curr_table_id != CODE_NIBBLE) {
308 bytes32_t merkle_root = cursor.node->data().empty()
309 ? NULL_ROOT
310 : to_bytes(cursor.node->data());
311 fmt::println(" * Merkle root is {}", merkle_root);
312 }
313 fmt::println(" * \"node_stats\" will display a summary of node "
314 "metadata");
315 fmt::println(" * Next, try look up a key in this table using "
316 "\"get [key]\"");
317 }
318 else {
319 fmt::println(
320 "Couldn't find root node for {} -- {}",
321 table_as_string(table_id),
322 res.error().message().c_str());
323 }
324 }
325 else {
326 fmt::println("Invalid table id: choose table id from 0: state, "
327 "1: code, 2: receipt.");
328 }
329 }
330
331 Result<NodeCursor> lookup(NibblesView const key) const
332 {

Callers 1

do_tableFunction · 0.80

Calls 10

table_as_stringFunction · 0.85
concatFunction · 0.85
to_bytesFunction · 0.85
has_valueMethod · 0.80
errorMethod · 0.80
nibble_sizeMethod · 0.45
findMethod · 0.45
emptyMethod · 0.45
dataMethod · 0.45
messageMethod · 0.45

Tested by

no test coverage detected