forked from lthn/blockchain
another good iteration on auto documenting feature
This commit is contained in:
parent
63d4bde2d9
commit
7f0b99c25e
10 changed files with 95 additions and 51 deletions
|
|
@ -66,8 +66,8 @@ bool auto_doc_t(const std::string& prefix_name, std::string& generate_reference)
|
|||
|
||||
std::stringstream ss;
|
||||
ss << prefix_name << ENDL
|
||||
<< "REQUEST: " << ENDL << req_str << ENDL << "--------------------------------" << ENDL
|
||||
<< "RESPONSE: " << ENDL << res_str << ENDL << "################################" << ENDL;
|
||||
<< "REQUEST: " << ENDL << req_str << ENDL << req_str_descr << "--------------------------------" << ENDL
|
||||
<< "RESPONSE: " << ENDL << res_str << ENDL << res_str_descr << "################################" << ENDL;
|
||||
generate_reference += ss.str();
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,17 +65,33 @@ public: \
|
|||
static bool serialize_map(this_type& this_ref, t_storage& stg, typename t_storage::hsection hparent_section) \
|
||||
{
|
||||
|
||||
|
||||
#define KV_CAT_(a, b) a ## b
|
||||
#define KV_CAT(a, b) KV_CAT_(a, b)
|
||||
#define VARNAME(Var) KV_CAT(Var, __LINE__)
|
||||
|
||||
#define KV_MAKE_ALIAS_NAME() VARNAME(alias_tmp_name)
|
||||
#define KV_MAKE_VAR_NAME() VARNAME(val_tmp_name)
|
||||
|
||||
#define KV_SERIALIZE_N(varialble, val_name) \
|
||||
using KV_MAKE_ALIAS_NAME() = decltype(this_ref.varialble); \
|
||||
const char* KV_MAKE_VAR_NAME() = val_name;\
|
||||
epee::serialization::selector<is_store>::serialize(this_ref.varialble, stg, hparent_section, val_name);
|
||||
|
||||
#define KV_SERIALIZE_N_DOC(varialble, val_name) \
|
||||
{ using var_type = decltype(this_ref.varialble); \
|
||||
epee::serialization::selector<is_store>::serialize(this_ref.varialble, stg, hparent_section, val_name); \
|
||||
if constexpr (t_storage::use_descriptions::value) \
|
||||
{ \
|
||||
epee::serialization::selector<is_store>::template serialize_and_doc<var_type>(stg, hparent_section, val_name
|
||||
//#define KV_SERIALIZE_N_DOC(varialble, val_name) \
|
||||
// using KV_MAKE_ALIAS_NAME() = decltype(this_ref.varialble); \
|
||||
// epee::serialization::selector<is_store>::serialize(this_ref.varialble, stg, hparent_section, val_name); \
|
||||
// if constexpr (t_storage::use_descriptions::value) \
|
||||
// { \
|
||||
// epee::serialization::selector<is_store>::template serialize_and_doc<KV_MAKE_ALIAS_NAME()>(stg, hparent_section, val_name
|
||||
|
||||
|
||||
/*
|
||||
#define DOC_DSCR(description) if constexpr (t_storage::use_descriptions::value) \
|
||||
{ \
|
||||
epee::serialization::selector<is_store>::template serialize_and_doc<KV_MAKE_ALIAS_NAME()>(stg, hparent_section, KV_MAKE_VAR_NAME(), description
|
||||
|
||||
|
||||
/*
|
||||
{using var_type = decltype(this_ref.varialble); \
|
||||
epee::serialization::selector<is_store>::serialize(this_ref.varialble, stg, hparent_section, val_name); \
|
||||
if constexpr (t_storage::use_descriptions::value) \
|
||||
|
|
@ -84,15 +100,16 @@ public: \
|
|||
} \
|
||||
}
|
||||
*/
|
||||
#define DOC_DSCR(description) , description
|
||||
|
||||
//#define DOC_DSCR(description) , description
|
||||
#define DOC_EXMP(substitute) , substitute
|
||||
#define DOC_EXMP_AUTO_1(arg_1) , var_type(arg_1)
|
||||
#define DOC_EXMP_AUTO_2(arg_1, arg_2) , var_type(arg_1, arg_2)
|
||||
#define DOC_END ); } }
|
||||
#define DOC_EXMP_AUTO_1(arg_1) , KV_MAKE_ALIAS_NAME() (arg_1)
|
||||
#define DOC_EXMP_AUTO_2(arg_1, arg_2) , KV_MAKE_ALIAS_NAME() (arg_1, arg_2)
|
||||
#define DOC_END ); }
|
||||
|
||||
|
||||
|
||||
#define DOC_EXMP_AUTO(...) , epee::create_t_object<var_type>(__VA_ARGS__)
|
||||
#define DOC_EXMP_AUTO(...) , epee::create_t_object<KV_MAKE_ALIAS_NAME() >(__VA_ARGS__)
|
||||
|
||||
|
||||
// Function template to create an object with forwarded constructor arguments
|
||||
|
|
@ -109,9 +126,13 @@ public: \
|
|||
|
||||
|
||||
#define KV_SERIALIZE_CUSTOM_N(varialble, stored_type, from_v_to_stored, from_stored_to_v, val_name) \
|
||||
using KV_MAKE_ALIAS_NAME() = stored_type; \
|
||||
const char* VARNAME(val_tmp_name) = val_name;\
|
||||
epee::serialization::selector<is_store>::template serialize_custom<stored_type>(this_ref.varialble, stg, hparent_section, val_name, from_v_to_stored, from_stored_to_v);
|
||||
|
||||
#define KV_SERIALIZE_EPHEMERAL_N(stored_type, from_v_to_stored, val_name) \
|
||||
using KV_MAKE_ALIAS_NAME() = stored_type; \
|
||||
const char* VARNAME(val_tmp_name) = val_name;\
|
||||
epee::serialization::selector<is_store>::template serialize_ephemeral<stored_type>(this_ref, stg, hparent_section, val_name, from_v_to_stored);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -317,12 +317,12 @@ namespace epee
|
|||
template<class t_type, class t_storage>
|
||||
static bool serialize(const t_type& d, t_storage& stg, [[maybe_unused]] typename t_storage::hsection hparent_section, [[maybe_unused]] const char* pname)
|
||||
{
|
||||
if constexpr (!t_storage::use_descriptions::value)
|
||||
{
|
||||
//if constexpr (!t_storage::use_descriptions::value)
|
||||
//{
|
||||
return kv_serialize(d, stg, hparent_section, pname);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
//}
|
||||
//else
|
||||
// return false;
|
||||
|
||||
}
|
||||
//const t_type& doc_substitute = t_type(), const std::string& description = std::string()
|
||||
|
|
|
|||
|
|
@ -732,14 +732,14 @@ namespace currency
|
|||
END_BOOST_SERIALIZATION()
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(total_max_supply)
|
||||
KV_SERIALIZE(current_supply)
|
||||
KV_SERIALIZE(decimal_point)
|
||||
KV_SERIALIZE(ticker)
|
||||
KV_SERIALIZE(full_name)
|
||||
KV_SERIALIZE(meta_info)
|
||||
KV_SERIALIZE_POD_AS_HEX_STRING(owner)
|
||||
KV_SERIALIZE(hidden_supply)
|
||||
KV_SERIALIZE(total_max_supply) DOC_DSCR("Maximum possible supply for given asset, can't be changed after deployment") DOC_EXMP(1000000000000000000) DOC_END
|
||||
KV_SERIALIZE(current_supply) DOC_DSCR("Currently emitted supply for given asset") DOC_EXMP(500000000000000000) DOC_END
|
||||
KV_SERIALIZE(decimal_point) DOC_DSCR("Decimal point") DOC_EXMP(12) DOC_END
|
||||
KV_SERIALIZE(ticker) DOC_DSCR("Ticker associated with asset") DOC_EXMP("ZUSD") DOC_END
|
||||
KV_SERIALIZE(full_name) DOC_DSCR("Full name of the asset") DOC_EXMP("Zano wrapped USD") DOC_END
|
||||
KV_SERIALIZE(meta_info) DOC_DSCR("Any other information assetiaded with asset in a free form") DOC_EXMP("Stable and private") DOC_END
|
||||
KV_SERIALIZE_POD_AS_HEX_STRING(owner) DOC_DSCR("Owner's key, used to validate any operations on the asset altering, could be changed in case of transfer ownership") DOC_EXMP("f74bb56a5b4fa562e679ccaadd697463498a66de4f1760b2cd40f11c3a00a7a8") DOC_END
|
||||
KV_SERIALIZE(hidden_supply) DOC_DSCR("This one reserved for future use, will be documented later") DOC_END
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
|
@ -757,7 +757,7 @@ namespace currency
|
|||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_CHAIN_BASE(asset_descriptor_base)
|
||||
KV_SERIALIZE_POD_AS_HEX_STRING(asset_id)
|
||||
KV_SERIALIZE_POD_AS_HEX_STRING(asset_id) DOC_DSCR("Asset ID") DOC_EXMP("f74bb56a5b4fa562e679ccaadd697463498a66de4f1760b2cd40f11c3a00a7a8") DOC_END
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -281,12 +281,12 @@ int main(int argc, char* argv[])
|
|||
std::string generate_reference = std::string("RPC_COMMANDS_LIST:\n");
|
||||
bool call_found = false;
|
||||
rpc_server.handle_http_request_map(query_info, response_info, conn_context, call_found, generate_reference);
|
||||
std::string json_rpc_reference;
|
||||
query_info.m_URI = JSON_RPC_REFERENCE_MARKER;
|
||||
query_info.m_body = "{\"jsonrpc\": \"2.0\", \"method\": \"nonexisting_method\", \"params\": {}},";
|
||||
rpc_server.handle_http_request_map(query_info, response_info, conn_context, call_found, json_rpc_reference);
|
||||
//std::string json_rpc_reference;
|
||||
//query_info.m_URI = JSON_RPC_REFERENCE_MARKER;
|
||||
//query_info.m_body = "{\"jsonrpc\": \"2.0\", \"method\": \"nonexisting_method\", \"params\": {}},";
|
||||
//rpc_server.handle_http_request_map(query_info, response_info, conn_context, call_found, json_rpc_reference);
|
||||
|
||||
LOG_PRINT_L0(generate_reference << ENDL << "----------------------------------------" << ENDL << json_rpc_reference);
|
||||
LOG_PRINT_L0(generate_reference);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,12 +152,12 @@ namespace currency
|
|||
std::string status;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE_DOC(height) DOC_DSCR("Some height of the block") DOC_EXMP(11111) DOC_END
|
||||
KV_SERIALIZE_DOC(status) DOC_DSCR("Status of the operation") DOC_EXMP("OK") DOC_END
|
||||
KV_SERIALIZE(height) DOC_DSCR("Some height of the block") DOC_EXMP(11111) DOC_END
|
||||
KV_SERIALIZE(status) DOC_DSCR("Status of the operation") DOC_EXMP("OK") DOC_END
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<class t_block_complete_entry>
|
||||
struct COMMAND_RPC_GET_BLOCKS_FAST_T
|
||||
|
|
@ -212,9 +212,9 @@ namespace currency
|
|||
std::string status;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE_DOC(txs_as_hex) DOC_DSCR("Transactions stored as blobs") DOC_EXMP_AUTO(1, "7d914497d91442f8f3c2268397d914497d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc2f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc") DOC_END
|
||||
KV_SERIALIZE_DOC(missed_tx) DOC_DSCR("Missed transactions hashes") DOC_EXMP_AUTO(1, "97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc") DOC_END
|
||||
KV_SERIALIZE_DOC(status) DOC_DSCR("Command response status") DOC_EXMP_AUTO("OK") DOC_END
|
||||
KV_SERIALIZE(txs_as_hex) DOC_DSCR("Transactions stored as blobs") DOC_EXMP_AUTO(1, "7d914497d91442f8f3c2268397d914497d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc2f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc") DOC_END
|
||||
KV_SERIALIZE(missed_tx) DOC_DSCR("Missed transactions hashes") DOC_EXMP_AUTO(1, "97d91442f8f3c22683585eaa60b53757d49bf046a96269cef45c1bc9ff7300cc") DOC_END
|
||||
KV_SERIALIZE(status) DOC_DSCR("Command response status") DOC_EXMP_AUTO("OK") DOC_END
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2807,7 +2807,7 @@ int main(int argc, char* argv[])
|
|||
command_line::add_arg(desc_params, arg_set_timeout);
|
||||
command_line::add_arg(desc_params, arg_voting_config_file);
|
||||
command_line::add_arg(desc_params, arg_no_password_confirmations);
|
||||
|
||||
command_line::add_arg(desc_params, command_line::arg_show_rpc_autodoc);
|
||||
|
||||
tools::wallet_rpc_server::init_options(desc_params);
|
||||
|
||||
|
|
@ -2863,6 +2863,29 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
|
||||
if (command_line::get_arg(vm, command_line::arg_show_rpc_autodoc))
|
||||
{
|
||||
LOG_PRINT_L0("Dumping RPC auto-generated documents!");
|
||||
epee::net_utils::http::http_request_info query_info;
|
||||
epee::net_utils::http::http_response_info response_info;
|
||||
epee::net_utils::connection_context_base conn_context;
|
||||
std::string generate_reference = std::string("WALLET_RPC_COMMANDS_LIST:\n");
|
||||
bool call_found = false;
|
||||
tools::wallet_rpc_server wallet_rpc_server(std::shared_ptr<tools::wallet2>(new tools::wallet2()));
|
||||
//wallet_rpc_server.handle_http_request_map(query_info, response_info, conn_context, call_found, generate_reference);
|
||||
|
||||
std::string json_rpc_reference = generate_reference;
|
||||
query_info.m_URI = JSON_RPC_REFERENCE_MARKER;
|
||||
query_info.m_body = "{\"jsonrpc\": \"2.0\", \"method\": \"nonexisting_method\", \"params\": {}},";
|
||||
wallet_rpc_server.handle_http_request_map(query_info, response_info, conn_context, call_found, json_rpc_reference);
|
||||
|
||||
|
||||
LOG_PRINT_L0(json_rpc_reference);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (command_line::has_arg(vm, arg_scan_for_wallet))
|
||||
{
|
||||
log_space::log_singletone::add_logger(LOGGER_CONSOLE, nullptr, nullptr, LOG_LEVEL_4);
|
||||
|
|
|
|||
|
|
@ -451,7 +451,7 @@ public:
|
|||
uint64_t wallet_id;
|
||||
transfers_array recent_history;
|
||||
wallet_info wi;
|
||||
//std::string seed;
|
||||
std::string seed;
|
||||
bool recovered;
|
||||
uint64_t wallet_local_bc_size;
|
||||
uint64_t wallet_file_size;
|
||||
|
|
@ -462,7 +462,7 @@ public:
|
|||
KV_SERIALIZE(wallet_id)
|
||||
KV_SERIALIZE(recent_history)
|
||||
KV_SERIALIZE(wi)
|
||||
//KV_SERIALIZE(seed)
|
||||
KV_SERIALIZE(seed)
|
||||
KV_SERIALIZE(recovered)
|
||||
KV_SERIALIZE(wallet_local_bc_size)
|
||||
KV_SERIALIZE(wallet_file_size)
|
||||
|
|
|
|||
|
|
@ -312,10 +312,10 @@ namespace wallet_public
|
|||
|
||||
//v2
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(total)
|
||||
KV_SERIALIZE(unlocked)
|
||||
KV_SERIALIZE(awaiting_in)
|
||||
KV_SERIALIZE(awaiting_out)
|
||||
KV_SERIALIZE(total) DOC_DSCR("Total coins available(including locked)") DOC_EXMP(100000000000000) DOC_END
|
||||
KV_SERIALIZE(unlocked) DOC_DSCR("Unlocked coins available(the ones that could be used right now)") DOC_EXMP(50000000000000) DOC_END
|
||||
KV_SERIALIZE(awaiting_in) DOC_DSCR("Unconfirmed amount for receive") DOC_EXMP(1000000000000) DOC_END
|
||||
KV_SERIALIZE(awaiting_out) DOC_DSCR("Unconfirmed amount for send") DOC_EXMP(2000000000000) DOC_END
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
|
@ -324,7 +324,7 @@ namespace wallet_public
|
|||
currency::asset_descriptor_with_id asset_info;
|
||||
//v2
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(asset_info)
|
||||
KV_SERIALIZE(asset_info) DOC_DSCR("Asset info details") DOC_END
|
||||
KV_CHAIN_BASE(asset_balance_entry_base)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
|
@ -403,9 +403,9 @@ namespace wallet_public
|
|||
std::list<asset_balance_entry> balances;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(balance)
|
||||
KV_SERIALIZE(unlocked_balance)
|
||||
KV_SERIALIZE(balances)
|
||||
KV_SERIALIZE(balance) DOC_DSCR("Native coins total amount") DOC_EXMP(10000000000) DOC_END
|
||||
KV_SERIALIZE(unlocked_balance) DOC_DSCR("Native coins total unlocked amount") DOC_EXMP(11000000000) DOC_END
|
||||
KV_SERIALIZE(balances) DOC_DSCR("Balances groupped by it's asset_id") DOC_EXMP_AUTO(1) DOC_END
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1078,7 +1078,7 @@ std::string wallets_manager::open_wallet(const std::wstring& path, const std::st
|
|||
owr.wallet_local_bc_size = w->get_blockchain_current_size();
|
||||
|
||||
//workaround for missed fee
|
||||
//owr.seed = w->get_account().get_seed_phrase();
|
||||
owr.seed = w->get_account().get_seed_phrase("");
|
||||
break;
|
||||
}
|
||||
catch (const tools::error::file_not_found& /**/)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue