bool rai_daemon::daemon_config::deserialize_json (bool & upgraded_a, boost::property_tree::ptree & tree_a) { auto error (false); try { if (!tree_a.empty ()) { auto version_l (tree_a.get_optional <std::string> ("version")); if (!version_l) { tree_a.put ("version", "1"); version_l = "1"; } upgraded_a |= upgrade_json (std::stoull (version_l.get ()), tree_a); rpc_enable = tree_a.get <bool> ("rpc_enable"); auto rpc_l (tree_a.get_child ("rpc")); error |= rpc.deserialize_json (rpc_l); auto & node_l (tree_a.get_child ("node")); error |= node.deserialize_json (upgraded_a, node_l); opencl_enable = tree_a.get <bool> ("opencl_enable"); auto & opencl_l (tree_a.get_child ("opencl")); error |= opencl.deserialize_json (opencl_l); } else { upgraded_a = true; serialize_json (tree_a); } } catch (std::runtime_error const &) { error = true; } return error; }
bool deserialize_json (bool & upgraded_a, boost::property_tree::ptree & tree_a) { auto error (false); if (!tree_a.empty ()) { auto version_l (tree_a.get_optional<std::string> ("version")); if (!version_l) { tree_a.put ("version", "1"); version_l = "1"; upgraded_a = true; } upgraded_a |= upgrade_json (std::stoull (version_l.get ()), tree_a); auto wallet_l (tree_a.get<std::string> ("wallet")); auto account_l (tree_a.get<std::string> ("account")); auto & node_l (tree_a.get_child ("node")); rpc_enable = tree_a.get<bool> ("rpc_enable"); auto & rpc_l (tree_a.get_child ("rpc")); opencl_enable = tree_a.get<bool> ("opencl_enable"); auto & opencl_l (tree_a.get_child ("opencl")); try { error |= wallet.decode_hex (wallet_l); error |= account.decode_account (account_l); error |= node.deserialize_json (upgraded_a, node_l); error |= rpc.deserialize_json (rpc_l); error |= opencl.deserialize_json (opencl_l); if (wallet.is_zero ()) { rai::random_pool.GenerateBlock (wallet.bytes.data (), wallet.bytes.size ()); upgraded_a = true; } } catch (std::logic_error const &) { error = true; } } else { serialize_json (tree_a); upgraded_a = true; } return error; }