Created
February 20, 2018 12:09
-
-
Save mingodad/d7dcbad61630eeabc51eff88fa806a60 to your computer and use it in GitHub Desktop.
Raiblocks dump database extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/rai/rai_node/entry.cpp b/rai/rai_node/entry.cpp | |
index f480a68..62d8900 100644 | |
--- a/rai/rai_node/entry.cpp | |
+++ b/rai/rai_node/entry.cpp | |
@@ -121,6 +121,14 @@ int main (int argc, char * const * argv) | |
("debug_bootstrap_generate", "Generate bootstrap sequence of blocks") | |
("debug_dump_representatives", "List representatives and weights") | |
("debug_frontier_count", "Display the number of accounts") | |
+ ("debug_accounts_list", "Display the accounts list") | |
+ ("debug_block_info_list", "Display the block_info list") | |
+ ("debug_change_list", "Display the change list") | |
+ ("debug_frontier_list", "Display the frontier list") | |
+ ("debug_open_list", "Display the open list") | |
+ ("debug_pending_list", "Display the pending list") | |
+ ("debug_receive_list", "Display the receive list") | |
+ ("debug_send_list", "Display the send list") | |
("debug_mass_activity", "Generates fake debug activity") | |
("debug_profile_generate", "Profile work generation") | |
("debug_opencl", "OpenCL work generation") | |
@@ -241,6 +249,190 @@ int main (int argc, char * const * argv) | |
rai::transaction transaction (node.node->store.environment, nullptr, false); | |
std::cout << boost::str (boost::format ("Frontier count: %1%\n") % node.node->store.frontier_count (transaction)); | |
} | |
+ else if (vm.count ("debug_accounts_list")) | |
+ { | |
+ rai::inactive_node node (data_path); | |
+ rai::transaction transaction (node.node->store.environment, nullptr, false); | |
+ //int xcount = 0; | |
+ for (auto i (node.node->store.latest_begin (transaction)), n (node.node->store.latest_end ()); i != n; ++i) | |
+ { | |
+ rai::account account (i->first.uint256 ()); | |
+ rai::account_info info (i->second); | |
+ std::cout << "--" << std::endl; | |
+ std::cout << account.to_string() << std::endl; | |
+ std::cout << info.head.to_string() << std::endl; | |
+ std::cout << info.open_block.to_string() << std::endl; | |
+ std::cout << info.rep_block.to_string() << std::endl; | |
+ //std::cout << info.balance.format_balance (rai::Mxrb_ratio, 0, false) << " XRB" << std::endl; | |
+ std::cout << info.balance.number().convert_to<std::string>() << std::endl; | |
+ std::cout << info.modified << std::endl; | |
+ std::cout << info.block_count << std::endl; | |
+ //if(++xcount > 10) break; | |
+ } | |
+ } | |
+ else if (vm.count ("debug_block_info_list")) | |
+ { | |
+ rai::inactive_node node (data_path); | |
+ rai::transaction transaction (node.node->store.environment, nullptr, false); | |
+ //int xcount = 0; | |
+ for (auto i (node.node->store.block_info_begin (transaction)), n (node.node->store.block_info_end()); i != n; ++i) | |
+ { | |
+ rai::block_hash block_id (i->first.uint256 ()); | |
+ rai::block_info info (i->second); | |
+ std::cout << "--" << std::endl; | |
+ std::cout << block_id.to_string() << std::endl; | |
+ std::cout << info.account.to_string() << std::endl; | |
+ std::cout << info.balance.number().convert_to<std::string>() << std::endl; | |
+ //if(++xcount > 10) break; | |
+ } | |
+ } | |
+ else if (vm.count ("debug_change_list")) | |
+ { | |
+ rai::inactive_node node (data_path); | |
+ rai::transaction transaction (node.node->store.environment, nullptr, false); | |
+ //int xcount = 0; | |
+ for (rai::store_iterator i (transaction, node.node->store.change_blocks), n (nullptr); i != n; ++i) | |
+ { | |
+ rai::block_hash change_id (i->first.uint256 ()); | |
+ uint8_t *data = (uint8_t*)(i->second.data()); | |
+ size_t data_size = i->second.size(); | |
+ | |
+ rai::block_hash *previous = (rai::block_hash*)data; | |
+ rai::account *representative = (rai::account*)(previous + sizeof(rai::block_hash)); | |
+ rai::signature *signature = (rai::signature*)((representative + sizeof(rai::account))); | |
+ uint64_t *work = (uint64_t*)(signature + sizeof(rai::signature)); | |
+ | |
+ std::cout << "--" << std::endl; | |
+ std::cout << change_id.to_string() << std::endl; | |
+ std::cout << previous->to_string() << std::endl; | |
+ std::cout << representative->to_string() << std::endl; | |
+ std::cout << signature->to_string() << std::endl; | |
+ std::cout << *work << std::endl; | |
+ //if(++xcount > 10) break; | |
+ } | |
+ } | |
+ else if (vm.count ("debug_frontier_list")) | |
+ { | |
+ rai::inactive_node node (data_path); | |
+ rai::transaction transaction (node.node->store.environment, nullptr, false); | |
+ //int xcount = 0; | |
+ for (rai::store_iterator i (transaction, node.node->store.frontiers), n (nullptr); i != n; ++i) | |
+ { | |
+ rai::block_hash frontier_id (i->first.uint256 ()); | |
+ uint8_t *data = (uint8_t*)(i->second.data()); | |
+ size_t data_size = i->second.size(); | |
+ | |
+ rai::account *acount = (rai::account*)data; | |
+ rai::account *acount_info = (rai::account*)(acount + sizeof(rai::account)); | |
+ | |
+ std::cout << "--" << std::endl; | |
+ std::cout << frontier_id.to_string() << std::endl; | |
+ std::cout << acount->to_string() << std::endl; | |
+ std::cout << acount_info->to_string() << std::endl; | |
+ //if(++xcount > 10) break; | |
+ } | |
+ } | |
+ else if (vm.count ("debug_open_list")) | |
+ { | |
+ rai::inactive_node node (data_path); | |
+ rai::transaction transaction (node.node->store.environment, nullptr, false); | |
+ //int xcount = 0; | |
+ for (rai::store_iterator i (transaction, node.node->store.open_blocks), n (nullptr); i != n; ++i) | |
+ { | |
+ rai::block_hash open_id (i->first.uint256 ()); | |
+ uint8_t *data = (uint8_t*)(i->second.data()); | |
+ size_t data_size = i->second.size(); | |
+ | |
+ rai::block_hash *source = (rai::block_hash*)data; | |
+ rai::account *representative = (rai::account*)(source + sizeof(rai::block_hash)); | |
+ rai::account *account = (rai::account*)(representative + sizeof(rai::account)); | |
+ rai::signature *signature = (rai::signature*)((account + sizeof(rai::account))); | |
+ uint64_t *work = (uint64_t*)(signature + sizeof(rai::signature)); | |
+ | |
+ std::cout << "--" << std::endl; | |
+ std::cout << open_id.to_string() << std::endl; | |
+ std::cout << source->to_string() << std::endl; | |
+ std::cout << representative->to_string() << std::endl; | |
+ std::cout << account->to_string() << std::endl; | |
+ std::cout << signature->to_string() << std::endl; | |
+ std::cout << *work << std::endl; | |
+ //if(++xcount > 10) break; | |
+ } | |
+ } | |
+ else if (vm.count ("debug_pending_list")) | |
+ { | |
+ rai::inactive_node node (data_path); | |
+ rai::transaction transaction (node.node->store.environment, nullptr, false); | |
+ //int xcount = 0; | |
+ for (rai::store_iterator i (transaction, node.node->store.pending), n (nullptr); i != n; ++i) | |
+ { | |
+ rai::pending_key pending_id (i->first); | |
+ uint8_t *data = (uint8_t*)(i->second.data()); | |
+ size_t data_size = i->second.size(); | |
+ | |
+ rai::account *source = (rai::account*)data; | |
+ rai::amount *amount = (rai::amount*)(source + sizeof(rai::account)); | |
+ | |
+ std::cout << "--" << std::endl; | |
+ std::cout << pending_id.account.to_string() << std::endl; | |
+ std::cout << pending_id.hash.to_string() << std::endl; | |
+ std::cout << source->to_string() << std::endl; | |
+ std::cout << amount->number().convert_to<std::string>() << std::endl; | |
+ //if(++xcount > 10) break; | |
+ } | |
+ } | |
+ else if (vm.count ("debug_receive_list")) | |
+ { | |
+ rai::inactive_node node (data_path); | |
+ rai::transaction transaction (node.node->store.environment, nullptr, false); | |
+ //int xcount = 0; | |
+ for (rai::store_iterator i (transaction, node.node->store.receive_blocks), n (nullptr); i != n; ++i) | |
+ { | |
+ rai::block_hash receive_id (i->first.uint256 ()); | |
+ uint8_t *data = (uint8_t*)(i->second.data()); | |
+ size_t data_size = i->second.size(); | |
+ | |
+ rai::block_hash *previous = (rai::block_hash*)data; | |
+ rai::block_hash *source = (rai::block_hash*)(previous + sizeof(rai::block_hash)); | |
+ rai::signature *signature = (rai::signature*)((source + sizeof(rai::block_hash))); | |
+ uint64_t *work = (uint64_t*)(signature + sizeof(rai::signature)); | |
+ | |
+ std::cout << "--" << std::endl; | |
+ std::cout << receive_id.to_string() << std::endl; | |
+ std::cout << previous->to_string() << std::endl; | |
+ std::cout << source->to_string() << std::endl; | |
+ std::cout << signature->to_string() << std::endl; | |
+ std::cout << *work << std::endl; | |
+ //if(++xcount > 10) break; | |
+ } | |
+ } | |
+ else if (vm.count ("debug_send_list")) | |
+ { | |
+ rai::inactive_node node (data_path); | |
+ rai::transaction transaction (node.node->store.environment, nullptr, false); | |
+ //int xcount = 0; | |
+ for (rai::store_iterator i (transaction, node.node->store.send_blocks), n (nullptr); i != n; ++i) | |
+ { | |
+ rai::block_hash send_id (i->first.uint256 ()); | |
+ uint8_t *data = (uint8_t*)(i->second.data()); | |
+ size_t data_size = i->second.size(); | |
+ | |
+ rai::block_hash *previous = (rai::block_hash*)data; | |
+ rai::account *destination = (rai::account*)(previous + sizeof(rai::block_hash)); | |
+ rai::amount *balance = (rai::amount*)(destination + sizeof(rai::account)); | |
+ rai::signature *signature = (rai::signature*)((balance + sizeof(rai::amount))); | |
+ uint64_t *work = (uint64_t*)(signature + sizeof(rai::signature)); | |
+ | |
+ std::cout << "--" << std::endl; | |
+ std::cout << send_id.to_string() << std::endl; | |
+ std::cout << previous->to_string() << std::endl; | |
+ std::cout << destination->to_string() << std::endl; | |
+ std::cout << balance->number().convert_to<std::string>() << std::endl; | |
+ std::cout << signature->to_string() << std::endl; | |
+ std::cout << *work << std::endl; | |
+ //if(++xcount > 10) break; | |
+ } | |
+ } | |
else if (vm.count ("debug_mass_activity")) | |
{ | |
rai::system system (24000, 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment