compiling with SerializedStruct and refactored dependencies

This commit is contained in:
woodser
2019-06-07 11:51:56 -04:00
parent 78eb67d4cb
commit f5fd35be54
5 changed files with 39 additions and 20 deletions
+1
View File
@@ -292,6 +292,7 @@ target_link_libraries(scratchpad
set(
LIBRARY_SRC_FILES
src/daemon/MoneroDaemon.cpp
src/wallet/MoneroWallet.cpp
src/utils/MoneroUtils.cpp
)
+11 -9
View File
@@ -1,24 +1,26 @@
#include "MoneroDaemon.h"
#include "utils/MoneroUtils.h"
#include <stdio.h>
#include <iostream>
#include "mnemonics/electrum-words.h"
#include "mnemonics/english.h"
using namespace cryptonote;
using namespace epee;
#include "include_base_utils.h"
#include "common/util.h"
/**
* Public interface for libmonero-cpp library.
*/
namespace monero {
string SerializableStruct::serialize() {
// -------------------------- MODEL SERIALIZATION ---------------------------
string SerializableStruct::serialize() const {
boost::property_tree::ptree node;
toPropertyTree(node);
return MoneroUtils::serialize(node);
}
void MoneroTx::toPropertyTree(boost::property_tree::ptree& node) const {
throw runtime_error("Not implemented");
}
// ---------------------------- PRIVATE HELPERS -----------------------------
}
+8 -9
View File
@@ -1,7 +1,5 @@
#include "utils/MoneroUtils.h"
#include "include_base_utils.h"
#include "common/util.h"
#include "wallet/wallet2.h" // TODO: this is imported so BEGIN_KV_SERIALIZE_MAP works; more precise import?
#pragma once
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
@@ -13,7 +11,7 @@ using namespace std;
namespace monero {
/**
* Base struct model which is serializable.
* Base struct which can be serialized.
*/
struct SerializableStruct {
@@ -22,14 +20,14 @@ namespace monero {
*
* @return the struct serialized to a json string
*/
string serialize();
string serialize() const;
/**
* Initializes a property tree node from this struct.
*
* @param node is the node to initialize
*/
virtual void toPropertyTree(boost::property_tree::ptree& node);
virtual void toPropertyTree(boost::property_tree::ptree& node) const = 0;
};
/**
@@ -44,7 +42,7 @@ namespace monero {
/**
* Models a connection to a daemon.
*
* TODO: boost::optional<string>?
* TODO: switch to boost::optional<string>
*/
struct MoneroRpcConnection {
string uri;
@@ -61,7 +59,7 @@ namespace monero {
/**
* Models a Monero transaction on the blockchain.
*/
struct MoneroTx {
struct MoneroTx : public SerializableStruct {
boost::optional<shared_ptr<MoneroBlock>> block;
boost::optional<string> id;
boost::optional<string> version;
@@ -100,6 +98,7 @@ namespace monero {
boost::optional<uint32_t> maxUsedBlockHeight;
boost::optional<string> maxUsedBlockId;
vector<string> signatures;
virtual void toPropertyTree(boost::property_tree::ptree& node) const;
};
/**
+12 -1
View File
@@ -1,5 +1,6 @@
#include "utils/MoneroUtils.h"
#include "wallet/MoneroWallet.h"
#include "utils/MoneroUtils.h"
#include <stdio.h>
#include <iostream>
#include "mnemonics/electrum-words.h"
@@ -13,6 +14,16 @@ using namespace epee;
*/
namespace monero {
// -------------------------- MODEL SERIALIZATION ---------------------------
void MoneroTxWallet::toPropertyTree(boost::property_tree::ptree& node) const {
throw runtime_error("Not implemented");
}
void MoneroTxRequest::toPropertyTree(boost::property_tree::ptree& node) const {
throw runtime_error("Not implemented");
}
// ---------------------------- PRIVATE HELPERS -----------------------------
bool boolEquals(bool val, const boost::optional<bool>& optVal) {
+7 -1
View File
@@ -1,8 +1,11 @@
#pragma once
#include "daemon/MoneroDaemon.h"
#include "wallet/wallet2.h"
using namespace std;
using namespace monero;
using namespace crypto;
using namespace monero;
/**
* Public interface for libmonero-cpp library.
@@ -129,6 +132,8 @@ namespace monero {
boost::optional<MoneroOutgoingTransfer> outgoingTransfer;
boost::optional<uint32_t> numSuggestedConfirmations;
boost::optional<string> note;
virtual void toPropertyTree(boost::property_tree::ptree& node) const;
};
/**
@@ -169,6 +174,7 @@ namespace monero {
boost::optional<MoneroTransferRequest> transferRequest;
boost::optional<uint64_t> getHeight() { return block == boost::none ? boost::none : (*block)->height; }
virtual void toPropertyTree(boost::property_tree::ptree& node) const;
};
/**