aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2019-10-25 13:38:21 -0500
committerluigi1111 <luigi1111w@gmail.com>2019-10-25 13:38:21 -0500
commit960c2158010d30a375207310a36a7a942b9285d2 (patch)
tree46d25ec0db661fd62fd1a683dea3b1ecbf620089 /contrib
parentMerge pull request #6002 (diff)
parentsimplewallet: add public_nodes command (diff)
downloadmonero-960c2158010d30a375207310a36a7a942b9285d2.tar.xz
Merge pull request #5357
b3a9a4d add a quick early out to get_blocks.bin when up to date (moneromooo-monero) 2899379 daemon, wallet: new pay for RPC use system (moneromooo-monero) ffa4602 simplewallet: add public_nodes command (moneromooo-monero)
Diffstat (limited to 'contrib')
-rw-r--r--contrib/epee/include/int-util.h17
-rw-r--r--contrib/epee/include/math_helper.h5
-rw-r--r--contrib/epee/include/serialization/keyvalue_serialization.h24
-rw-r--r--contrib/epee/include/storages/http_abstract_invoke.h11
-rw-r--r--contrib/epee/src/mlog.cpp2
5 files changed, 51 insertions, 8 deletions
diff --git a/contrib/epee/include/int-util.h b/contrib/epee/include/int-util.h
index 939c018ea..dcd58a8c4 100644
--- a/contrib/epee/include/int-util.h
+++ b/contrib/epee/include/int-util.h
@@ -132,6 +132,23 @@ static inline uint32_t div128_32(uint64_t dividend_hi, uint64_t dividend_lo, uin
// Long divisor with 2^64 base
void div128_64(uint64_t dividend_hi, uint64_t dividend_lo, uint64_t divisor, uint64_t* quotient_hi, uint64_t *quotient_lo, uint64_t *remainder_hi, uint64_t *remainder_lo);
+static inline void add64clamp(uint64_t *value, uint64_t add)
+{
+ static const uint64_t maxval = (uint64_t)-1;
+ if (*value > maxval - add)
+ *value = maxval;
+ else
+ *value += add;
+}
+
+static inline void sub64clamp(uint64_t *value, uint64_t sub)
+{
+ if (*value < sub)
+ *value = 0;
+ else
+ *value -= sub;
+}
+
#define IDENT16(x) ((uint16_t) (x))
#define IDENT32(x) ((uint32_t) (x))
#define IDENT64(x) ((uint64_t) (x))
diff --git a/contrib/epee/include/math_helper.h b/contrib/epee/include/math_helper.h
index ddc1f7f4b..604a04680 100644
--- a/contrib/epee/include/math_helper.h
+++ b/contrib/epee/include/math_helper.h
@@ -259,6 +259,11 @@ namespace math_helper
m_last_worked_time = get_time();
}
+ void trigger()
+ {
+ m_last_worked_time = 0;
+ }
+
template<class functor_t>
bool do_call(functor_t functr)
{
diff --git a/contrib/epee/include/serialization/keyvalue_serialization.h b/contrib/epee/include/serialization/keyvalue_serialization.h
index 5459c8409..78d294d05 100644
--- a/contrib/epee/include/serialization/keyvalue_serialization.h
+++ b/contrib/epee/include/serialization/keyvalue_serialization.h
@@ -26,6 +26,7 @@
#pragma once
+#include <type_traits>
#include <boost/utility/value_init.hpp>
#include <boost/foreach.hpp>
#include "misc_log_ex.h"
@@ -45,18 +46,20 @@ public: \
template<class t_storage> \
bool store( t_storage& st, typename t_storage::hsection hparent_section = nullptr) const\
{\
- return serialize_map<true>(*this, st, hparent_section);\
+ using type = typename std::remove_const<typename std::remove_reference<decltype(*this)>::type>::type; \
+ auto &self = const_cast<type&>(*this); \
+ return self.template serialize_map<true>(st, hparent_section); \
}\
template<class t_storage> \
bool _load( t_storage& stg, typename t_storage::hsection hparent_section = nullptr)\
{\
- return serialize_map<false>(*this, stg, hparent_section);\
+ return serialize_map<false>(stg, hparent_section);\
}\
template<class t_storage> \
bool load( t_storage& stg, typename t_storage::hsection hparent_section = nullptr)\
{\
try{\
- return serialize_map<false>(*this, stg, hparent_section);\
+ return serialize_map<false>(stg, hparent_section);\
}\
catch(const std::exception& err) \
{ \
@@ -65,13 +68,22 @@ public: \
return false; \
}\
}\
- template<bool is_store, class this_type, class t_storage> \
- static bool serialize_map(this_type& this_ref, t_storage& stg, typename t_storage::hsection hparent_section) \
- {
+ /*template<typename T> T& this_type_resolver() { return *this; }*/ \
+ /*using this_type = std::result_of<decltype(this_type_resolver)>::type;*/ \
+ template<bool is_store, class t_storage> \
+ bool serialize_map(t_storage& stg, typename t_storage::hsection hparent_section) \
+ { \
+ decltype(*this) &this_ref = *this;
#define KV_SERIALIZE_N(varialble, val_name) \
epee::serialization::selector<is_store>::serialize(this_ref.varialble, stg, hparent_section, val_name);
+#define KV_SERIALIZE_PARENT(type) \
+ do { \
+ if (!((type*)this)->serialize_map<is_store, t_storage>(stg, hparent_section)) \
+ return false; \
+ } while(0);
+
template<typename T> inline void serialize_default(const T &t, T v) { }
template<typename T> inline void serialize_default(T &t, T v) { t = v; }
diff --git a/contrib/epee/include/storages/http_abstract_invoke.h b/contrib/epee/include/storages/http_abstract_invoke.h
index 18b7f10c1..78e02c93a 100644
--- a/contrib/epee/include/storages/http_abstract_invoke.h
+++ b/contrib/epee/include/storages/http_abstract_invoke.h
@@ -101,7 +101,7 @@ namespace epee
}
template<class t_request, class t_response, class t_transport>
- bool invoke_http_json_rpc(const boost::string_ref uri, std::string method_name, const t_request& out_struct, t_response& result_struct, t_transport& transport, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref http_method = "GET", const std::string& req_id = "0")
+ bool invoke_http_json_rpc(const boost::string_ref uri, std::string method_name, const t_request& out_struct, t_response& result_struct, epee::json_rpc::error &error_struct, t_transport& transport, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref http_method = "GET", const std::string& req_id = "0")
{
epee::json_rpc::request<t_request> req_t = AUTO_VAL_INIT(req_t);
req_t.jsonrpc = "2.0";
@@ -111,10 +111,12 @@ namespace epee
epee::json_rpc::response<t_response, epee::json_rpc::error> resp_t = AUTO_VAL_INIT(resp_t);
if(!epee::net_utils::invoke_http_json(uri, req_t, resp_t, transport, timeout, http_method))
{
+ error_struct = {};
return false;
}
if(resp_t.error.code || resp_t.error.message.size())
{
+ error_struct = resp_t.error;
LOG_ERROR("RPC call of \"" << req_t.method << "\" returned error: " << resp_t.error.code << ", message: " << resp_t.error.message);
return false;
}
@@ -122,6 +124,13 @@ namespace epee
return true;
}
+ template<class t_request, class t_response, class t_transport>
+ bool invoke_http_json_rpc(const boost::string_ref uri, std::string method_name, const t_request& out_struct, t_response& result_struct, t_transport& transport, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref http_method = "GET", const std::string& req_id = "0")
+ {
+ epee::json_rpc::error error_struct;
+ return invoke_http_json_rpc(uri, method_name, out_struct, result_struct, error_struct, transport, timeout, http_method, req_id);
+ }
+
template<class t_command, class t_transport>
bool invoke_http_json_rpc(const boost::string_ref uri, typename t_command::request& out_struct, typename t_command::response& result_struct, t_transport& transport, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref http_method = "GET", const std::string& req_id = "0")
{
diff --git a/contrib/epee/src/mlog.cpp b/contrib/epee/src/mlog.cpp
index 66dfabcdf..e96bf627f 100644
--- a/contrib/epee/src/mlog.cpp
+++ b/contrib/epee/src/mlog.cpp
@@ -100,7 +100,7 @@ static const char *get_default_categories(int level)
switch (level)
{
case 0:
- categories = "*:WARNING,net:FATAL,net.http:FATAL,net.ssl:FATAL,net.p2p:FATAL,net.cn:FATAL,global:INFO,verify:FATAL,serialization:FATAL,stacktrace:INFO,logging:INFO,msgwriter:INFO";
+ categories = "*:WARNING,net:FATAL,net.http:FATAL,net.ssl:FATAL,net.p2p:FATAL,net.cn:FATAL,global:INFO,verify:FATAL,serialization:FATAL,daemon.rpc.payment:ERROR,stacktrace:INFO,logging:INFO,msgwriter:INFO";
break;
case 1:
categories = "*:INFO,global:INFO,stacktrace:INFO,logging:INFO,msgwriter:INFO,perf.*:DEBUG";