move nlohmann all to rpc

This commit is contained in:
Sean Darcy 2021-11-15 16:11:18 +11:00
parent 43489af3b5
commit 09aefc37c1
12 changed files with 40 additions and 36 deletions

View File

@ -39,7 +39,6 @@ target_link_libraries(blockchain_db
lmdb
filesystem
Boost::thread
nlohmann_json::nlohmann_json
extra)
target_compile_definitions(blockchain_db PRIVATE

View File

@ -37,6 +37,5 @@ target_link_libraries(checkpoints
cryptonote_basic
Boost::program_options
Boost::serialization
nlohmann_json::nlohmann_json
filesystem
extra)

View File

@ -36,7 +36,6 @@
#include "epee/serialization/keyvalue_serialization.h"
#include "cryptonote_core/service_node_rules.h"
#include <vector>
#include <nlohmann/json.hpp>
#include "blockchain_db/blockchain_db.h"
#include "cryptonote_basic/cryptonote_format_utils.h"
@ -57,19 +56,6 @@ namespace cryptonote
return result;
};
void to_json(nlohmann::json& j, const checkpoint_t& c)
{
j = nlohmann::json
{
{"version", c.version},
{"type", c.type},
{"height", c.height},
{"block_hash", tools::type_to_hex(c.block_hash)},
{"signatures", c.signatures},
{"prev_height", c.prev_height},
};
};
height_to_hash const HARDCODED_MAINNET_CHECKPOINTS[] =
{
{0, "08ff156d993012b0bdf2816c4bee47c9bbc7930593b70ee02574edddf15ee933"},

View File

@ -79,8 +79,6 @@ namespace cryptonote
FIELD(prev_height)
END_SERIALIZE()
};
void to_json(nlohmann::json& j, const checkpoint_t& c);
struct height_to_hash
{

View File

@ -44,5 +44,4 @@ target_link_libraries(cryptonote_basic
Boost::program_options
Boost::serialization
filesystem
nlohmann_json::nlohmann_json
extra)

View File

@ -45,7 +45,6 @@
#include "ringct/rctTypes.h"
#include "device/device.hpp"
#include "txtypes.h"
#include <nlohmann/json.hpp>
namespace service_nodes
{
@ -66,15 +65,6 @@ namespace service_nodes
FIELD(signature)
END_SERIALIZE()
};
inline void to_json(nlohmann::json& j, const quorum_signature& s)
{
j = nlohmann::json
{
{"voter_index", s.voter_index},
{"signature", tools::type_to_hex(s.signature)},
};
};
};
namespace cryptonote

View File

@ -39,7 +39,6 @@
#include "cryptonote_core/service_node_quorum_cop.h"
#include "common/util.h"
#include "uptime_proof.h"
#include <nlohmann/json.hpp>
namespace cryptonote
{
@ -373,7 +372,6 @@ namespace service_nodes
END_SERIALIZE()
};
inline void to_json(nlohmann::json& j, const key_image_blacklist_entry& b) { j = nlohmann::json{{"key_image", tools::type_to_hex(b.key_image)}, {"unlock_height", b.unlock_height}, {"amount", b.amount} }; };
struct payout_entry
{

View File

@ -42,7 +42,6 @@ target_link_libraries(device
Boost::serialization
PRIVATE
version
nlohmann_json::nlohmann_json
extra)
option(HWDEVICE_DEBUG "Enable hardware wallet debugging (requires also using a debug build of the Ledger wallet)" OFF)

View File

@ -35,5 +35,4 @@ target_link_libraries(multisig
ringct
cryptonote_basic
common
nlohmann_json::nlohmann_json
extra)

View File

@ -40,7 +40,6 @@ target_link_libraries(ringct_basic
PRIVATE
OpenSSL::SSL
OpenSSL::Crypto
nlohmann_json::nlohmann_json
extra)
add_library(ringct
@ -54,5 +53,4 @@ target_link_libraries(ringct
PRIVATE
OpenSSL::SSL
OpenSSL::Crypto
nlohmann_json::nlohmann_json
extra)

View File

@ -24,6 +24,35 @@ namespace nlohmann {
}
namespace cryptonote {
void to_json(nlohmann::json& j, const checkpoint_t& c)
{
j = nlohmann::json
{
{"version", c.version},
{"type", c.type},
{"height", c.height},
{"block_hash", tools::type_to_hex(c.block_hash)},
{"signatures", c.signatures},
{"prev_height", c.prev_height},
};
};
}
namespace service_nodes {
void to_json(nlohmann::json& j, const key_image_blacklist_entry& b) { j = nlohmann::json{{"key_image", tools::type_to_hex(b.key_image)}, {"unlock_height", b.unlock_height}, {"amount", b.amount} }; };
void to_json(nlohmann::json& j, const quorum_signature& s)
{
j = nlohmann::json
{
{"voter_index", s.voter_index},
{"signature", tools::type_to_hex(s.signature)},
};
};
}
namespace cryptonote::rpc {
void RPC_COMMAND::set_bt() {

View File

@ -55,6 +55,7 @@
#include "crypto/hash.h"
#include "cryptonote_config.h"
#include "cryptonote_core/service_node_voting.h"
#include "cryptonote_core/service_node_list.h"
#include "common/varint.h"
#include "common/perf_timer.h"
#include "common/meta.h"
@ -72,9 +73,18 @@
#include <type_traits>
#include <unordered_set>
namespace cryptonote {
void to_json(nlohmann::json& j, const checkpoint_t& c);
}
namespace service_nodes {
void to_json(nlohmann::json& j, const key_image_blacklist_entry& b);
void to_json(nlohmann::json& j, const quorum_signature& s);
}
/// Namespace for core RPC commands. Every RPC commands gets defined here (including its name(s),
/// access, and data type), and added to `core_rpc_types` list at the bottom of the file.
namespace cryptonote::rpc {
using version_t = std::pair<uint16_t, uint16_t>;