aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/CMakeLists.txt7
-rw-r--r--src/common/base58.cpp3
-rw-r--r--src/common/base58.h2
-rw-r--r--src/common/combinator.cpp50
-rw-r--r--src/common/combinator.h96
-rw-r--r--src/common/command_line.cpp3
-rw-r--r--src/common/dns_utils.cpp4
-rw-r--r--src/common/download.cpp3
-rw-r--r--src/common/http_connection.h3
-rw-r--r--src/common/i18n.cpp2
-rw-r--r--src/common/int-util.h258
-rw-r--r--src/common/password.cpp3
-rw-r--r--src/common/scoped_message_writer.h2
-rw-r--r--src/common/threadpool.cpp4
-rw-r--r--src/common/util.cpp12
-rw-r--r--src/common/util.h2
16 files changed, 170 insertions, 284 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 1aaab555d..3b1eb6d23 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -43,7 +43,8 @@ set(common_sources
spawn.cpp
threadpool.cpp
updates.cpp
- aligned.c)
+ aligned.c
+ combinator.cpp)
if (STACK_TRACE)
list(APPEND common_sources stack_trace.cpp)
@@ -66,7 +67,6 @@ set(common_private_headers
error.h
expect.h
http_connection.h
- int-util.h
notify.h
pod-class.h
rpc_client.h
@@ -81,7 +81,8 @@ set(common_private_headers
stack_trace.h
threadpool.h
updates.h
- aligned.h)
+ aligned.h
+ combinator.h)
monero_private_headers(common
${common_private_headers})
diff --git a/src/common/base58.cpp b/src/common/base58.cpp
index b28a04f20..3562af486 100644
--- a/src/common/base58.cpp
+++ b/src/common/base58.cpp
@@ -36,7 +36,6 @@
#include "crypto/hash.h"
#include "int-util.h"
-#include "util.h"
#include "varint.h"
namespace tools
@@ -235,7 +234,7 @@ namespace tools
return encode(buf);
}
- bool decode_addr(std::string addr, uint64_t& tag, std::string& data)
+ bool decode_addr(const std::string &addr, uint64_t& tag, std::string& data)
{
std::string addr_data;
bool r = decode(addr, addr_data);
diff --git a/src/common/base58.h b/src/common/base58.h
index 02ca96956..69611859d 100644
--- a/src/common/base58.h
+++ b/src/common/base58.h
@@ -41,6 +41,6 @@ namespace tools
bool decode(const std::string& enc, std::string& data);
std::string encode_addr(uint64_t tag, const std::string& data);
- bool decode_addr(std::string addr, uint64_t& tag, std::string& data);
+ bool decode_addr(const std::string &addr, uint64_t& tag, std::string& data);
}
}
diff --git a/src/common/combinator.cpp b/src/common/combinator.cpp
new file mode 100644
index 000000000..cb4fbc908
--- /dev/null
+++ b/src/common/combinator.cpp
@@ -0,0 +1,50 @@
+// Copyright (c) 2018, The Monero Project
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without modification, are
+// permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this list of
+// conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice, this list
+// of conditions and the following disclaimer in the documentation and/or other
+// materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its contributors may be
+// used to endorse or promote products derived from this software without specific
+// prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
+
+#include "combinator.h"
+
+namespace tools {
+
+uint64_t combinations_count(uint32_t k, uint32_t n)
+{
+ if (k > n) {
+ throw std::runtime_error("k must not be greater than n");
+ }
+
+ uint64_t c = 1;
+ for (uint64_t i = 1; i <= k; ++i) {
+ c *= n--;
+ c /= i;
+ }
+
+ return c;
+}
+
+}
diff --git a/src/common/combinator.h b/src/common/combinator.h
new file mode 100644
index 000000000..72c6800d5
--- /dev/null
+++ b/src/common/combinator.h
@@ -0,0 +1,96 @@
+// Copyright (c) 2018, The Monero Project
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without modification, are
+// permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this list of
+// conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice, this list
+// of conditions and the following disclaimer in the documentation and/or other
+// materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its contributors may be
+// used to endorse or promote products derived from this software without specific
+// prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
+
+#pragma once
+
+#include <iostream>
+#include <vector>
+
+namespace tools {
+
+uint64_t combinations_count(uint32_t k, uint32_t n);
+
+template<typename T>
+class Combinator {
+public:
+ Combinator(const std::vector<T>& v) : origin(v) { }
+
+ std::vector<std::vector<T>> combine(size_t k);
+
+private:
+ void doCombine(size_t from, size_t k);
+
+ std::vector<T> origin;
+ std::vector<std::vector<T>> combinations;
+ std::vector<size_t> current;
+};
+
+template<typename T>
+std::vector<std::vector<T>> Combinator<T>::combine(size_t k)
+{
+ if (k > origin.size())
+ {
+ throw std::runtime_error("k must be smaller than elements number");
+ }
+
+ if (k == 0)
+ {
+ throw std::runtime_error("k must be greater than zero");
+ }
+
+ combinations.clear();
+ doCombine(0, k);
+ return combinations;
+}
+
+template<typename T>
+void Combinator<T>::doCombine(size_t from, size_t k)
+{
+ current.push_back(0);
+
+ for (size_t i = from; i <= origin.size() - k; ++i)
+ {
+ current.back() = i;
+
+ if (k > 1) {
+ doCombine(i + 1, k - 1);
+ } else {
+ std::vector<T> comb;
+ for (auto ind: current) {
+ comb.push_back(origin[ind]);
+ }
+ combinations.push_back(comb);
+ }
+ }
+
+ current.pop_back();
+}
+
+} //namespace tools
diff --git a/src/common/command_line.cpp b/src/common/command_line.cpp
index 7980b381f..35135ea18 100644
--- a/src/common/command_line.cpp
+++ b/src/common/command_line.cpp
@@ -31,10 +31,7 @@
#include "command_line.h"
#include <boost/algorithm/string/compare.hpp>
#include <boost/algorithm/string/predicate.hpp>
-#include <unordered_set>
#include "common/i18n.h"
-#include "cryptonote_config.h"
-#include "string_tools.h"
namespace command_line
{
diff --git a/src/common/dns_utils.cpp b/src/common/dns_utils.cpp
index 606a2c7b7..417b5b4ac 100644
--- a/src/common/dns_utils.cpp
+++ b/src/common/dns_utils.cpp
@@ -33,13 +33,11 @@
#include <stdlib.h>
#include "include_base_utils.h"
#include <random>
-#include <boost/filesystem/fstream.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/optional.hpp>
using namespace epee;
-namespace bf = boost::filesystem;
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net.dns"
@@ -305,7 +303,7 @@ std::vector<std::string> DNSResolver::get_record(const std::string& url, int rec
// call DNS resolver, blocking. if return value not zero, something went wrong
if (!ub_resolve(m_data->m_ub_context, string_copy(url.c_str()), record_type, DNS_CLASS_IN, &result))
{
- dnssec_available = (result->secure || (!result->secure && result->bogus));
+ dnssec_available = (result->secure || result->bogus);
dnssec_valid = result->secure && !result->bogus;
if (result->havedata)
{
diff --git a/src/common/download.cpp b/src/common/download.cpp
index 6698a5abf..58ce0595f 100644
--- a/src/common/download.cpp
+++ b/src/common/download.cpp
@@ -29,10 +29,7 @@
#include <string>
#include <atomic>
#include <boost/filesystem.hpp>
-#include <boost/asio.hpp>
#include <boost/thread/thread.hpp>
-#include "cryptonote_config.h"
-#include "include_base_utils.h"
#include "file_io_utils.h"
#include "net/http_client.h"
#include "download.h"
diff --git a/src/common/http_connection.h b/src/common/http_connection.h
index 9fc6be261..554dd832b 100644
--- a/src/common/http_connection.h
+++ b/src/common/http_connection.h
@@ -55,7 +55,8 @@ public:
{
if (m_ok)
{
- mp_http_client->disconnect();
+ try { mp_http_client->disconnect(); }
+ catch (...) { /* do not propagate through dtor */ }
}
}
diff --git a/src/common/i18n.cpp b/src/common/i18n.cpp
index 4a89876fb..ffe8d8b52 100644
--- a/src/common/i18n.cpp
+++ b/src/common/i18n.cpp
@@ -31,9 +31,7 @@
#include <ctype.h>
#include <string>
#include <map>
-#include "include_base_utils.h"
#include "file_io_utils.h"
-#include "common/util.h"
#include "common/i18n.h"
#include "translation_files.h"
diff --git a/src/common/int-util.h b/src/common/int-util.h
deleted file mode 100644
index 3bcc085e2..000000000
--- a/src/common/int-util.h
+++ /dev/null
@@ -1,258 +0,0 @@
-// Copyright (c) 2014-2018, The Monero Project
-//
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without modification, are
-// permitted provided that the following conditions are met:
-//
-// 1. Redistributions of source code must retain the above copyright notice, this list of
-// conditions and the following disclaimer.
-//
-// 2. Redistributions in binary form must reproduce the above copyright notice, this list
-// of conditions and the following disclaimer in the documentation and/or other
-// materials provided with the distribution.
-//
-// 3. Neither the name of the copyright holder nor the names of its contributors may be
-// used to endorse or promote products derived from this software without specific
-// prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
-// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
-// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
-// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
-
-#pragma once
-
-#include <assert.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <string.h>
-
-#ifndef _MSC_VER
-#include <sys/param.h>
-#endif
-
-#if defined(__ANDROID__)
-#include <byteswap.h>
-#endif
-
-#if defined(__sun) && defined(__SVR4)
-#include <endian.h>
-#endif
-
-#if defined(_MSC_VER)
-#include <stdlib.h>
-
-static inline uint32_t rol32(uint32_t x, int r) {
- static_assert(sizeof(uint32_t) == sizeof(unsigned int), "this code assumes 32-bit integers");
- return _rotl(x, r);
-}
-
-static inline uint64_t rol64(uint64_t x, int r) {
- return _rotl64(x, r);
-}
-
-#else
-
-static inline uint32_t rol32(uint32_t x, int r) {
- return (x << (r & 31)) | (x >> (-r & 31));
-}
-
-static inline uint64_t rol64(uint64_t x, int r) {
- return (x << (r & 63)) | (x >> (-r & 63));
-}
-
-#endif
-
-static inline uint64_t hi_dword(uint64_t val) {
- return val >> 32;
-}
-
-static inline uint64_t lo_dword(uint64_t val) {
- return val & 0xFFFFFFFF;
-}
-
-static inline uint64_t mul128(uint64_t multiplier, uint64_t multiplicand, uint64_t* product_hi) {
- // multiplier = ab = a * 2^32 + b
- // multiplicand = cd = c * 2^32 + d
- // ab * cd = a * c * 2^64 + (a * d + b * c) * 2^32 + b * d
- uint64_t a = hi_dword(multiplier);
- uint64_t b = lo_dword(multiplier);
- uint64_t c = hi_dword(multiplicand);
- uint64_t d = lo_dword(multiplicand);
-
- uint64_t ac = a * c;
- uint64_t ad = a * d;
- uint64_t bc = b * c;
- uint64_t bd = b * d;
-
- uint64_t adbc = ad + bc;
- uint64_t adbc_carry = adbc < ad ? 1 : 0;
-
- // multiplier * multiplicand = product_hi * 2^64 + product_lo
- uint64_t product_lo = bd + (adbc << 32);
- uint64_t product_lo_carry = product_lo < bd ? 1 : 0;
- *product_hi = ac + (adbc >> 32) + (adbc_carry << 32) + product_lo_carry;
- assert(ac <= *product_hi);
-
- return product_lo;
-}
-
-static inline uint64_t div_with_reminder(uint64_t dividend, uint32_t divisor, uint32_t* remainder) {
- dividend |= ((uint64_t)*remainder) << 32;
- *remainder = dividend % divisor;
- return dividend / divisor;
-}
-
-// Long division with 2^32 base
-static inline uint32_t div128_32(uint64_t dividend_hi, uint64_t dividend_lo, uint32_t divisor, uint64_t* quotient_hi, uint64_t* quotient_lo) {
- uint64_t dividend_dwords[4];
- uint32_t remainder = 0;
-
- dividend_dwords[3] = hi_dword(dividend_hi);
- dividend_dwords[2] = lo_dword(dividend_hi);
- dividend_dwords[1] = hi_dword(dividend_lo);
- dividend_dwords[0] = lo_dword(dividend_lo);
-
- *quotient_hi = div_with_reminder(dividend_dwords[3], divisor, &remainder) << 32;
- *quotient_hi |= div_with_reminder(dividend_dwords[2], divisor, &remainder);
- *quotient_lo = div_with_reminder(dividend_dwords[1], divisor, &remainder) << 32;
- *quotient_lo |= div_with_reminder(dividend_dwords[0], divisor, &remainder);
-
- return remainder;
-}
-
-#define IDENT32(x) ((uint32_t) (x))
-#define IDENT64(x) ((uint64_t) (x))
-
-#define SWAP32(x) ((((uint32_t) (x) & 0x000000ff) << 24) | \
- (((uint32_t) (x) & 0x0000ff00) << 8) | \
- (((uint32_t) (x) & 0x00ff0000) >> 8) | \
- (((uint32_t) (x) & 0xff000000) >> 24))
-#define SWAP64(x) ((((uint64_t) (x) & 0x00000000000000ff) << 56) | \
- (((uint64_t) (x) & 0x000000000000ff00) << 40) | \
- (((uint64_t) (x) & 0x0000000000ff0000) << 24) | \
- (((uint64_t) (x) & 0x00000000ff000000) << 8) | \
- (((uint64_t) (x) & 0x000000ff00000000) >> 8) | \
- (((uint64_t) (x) & 0x0000ff0000000000) >> 24) | \
- (((uint64_t) (x) & 0x00ff000000000000) >> 40) | \
- (((uint64_t) (x) & 0xff00000000000000) >> 56))
-
-static inline uint32_t ident32(uint32_t x) { return x; }
-static inline uint64_t ident64(uint64_t x) { return x; }
-
-#ifndef __OpenBSD__
-# if defined(__ANDROID__) && defined(__swap32) && !defined(swap32)
-# define swap32 __swap32
-# elif !defined(swap32)
-static inline uint32_t swap32(uint32_t x) {
- x = ((x & 0x00ff00ff) << 8) | ((x & 0xff00ff00) >> 8);
- return (x << 16) | (x >> 16);
-}
-# endif
-# if defined(__ANDROID__) && defined(__swap64) && !defined(swap64)
-# define swap64 __swap64
-# elif !defined(swap64)
-static inline uint64_t swap64(uint64_t x) {
- x = ((x & 0x00ff00ff00ff00ff) << 8) | ((x & 0xff00ff00ff00ff00) >> 8);
- x = ((x & 0x0000ffff0000ffff) << 16) | ((x & 0xffff0000ffff0000) >> 16);
- return (x << 32) | (x >> 32);
-}
-# endif
-#endif /* __OpenBSD__ */
-
-#if defined(__GNUC__)
-#define UNUSED __attribute__((unused))
-#else
-#define UNUSED
-#endif
-static inline void mem_inplace_ident(void *mem UNUSED, size_t n UNUSED) { }
-#undef UNUSED
-
-static inline void mem_inplace_swap32(void *mem, size_t n) {
- size_t i;
- for (i = 0; i < n; i++) {
- ((uint32_t *) mem)[i] = swap32(((const uint32_t *) mem)[i]);
- }
-}
-static inline void mem_inplace_swap64(void *mem, size_t n) {
- size_t i;
- for (i = 0; i < n; i++) {
- ((uint64_t *) mem)[i] = swap64(((const uint64_t *) mem)[i]);
- }
-}
-
-static inline void memcpy_ident32(void *dst, const void *src, size_t n) {
- memcpy(dst, src, 4 * n);
-}
-static inline void memcpy_ident64(void *dst, const void *src, size_t n) {
- memcpy(dst, src, 8 * n);
-}
-
-static inline void memcpy_swap32(void *dst, const void *src, size_t n) {
- size_t i;
- for (i = 0; i < n; i++) {
- ((uint32_t *) dst)[i] = swap32(((const uint32_t *) src)[i]);
- }
-}
-static inline void memcpy_swap64(void *dst, const void *src, size_t n) {
- size_t i;
- for (i = 0; i < n; i++) {
- ((uint64_t *) dst)[i] = swap64(((const uint64_t *) src)[i]);
- }
-}
-
-#ifdef _MSC_VER
-# define LITTLE_ENDIAN 1234
-# define BIG_ENDIAN 4321
-# define BYTE_ORDER LITTLE_ENDIAN
-#endif
-
-#if !defined(BYTE_ORDER) || !defined(LITTLE_ENDIAN) || !defined(BIG_ENDIAN)
-static_assert(false, "BYTE_ORDER is undefined. Perhaps, GNU extensions are not enabled");
-#endif
-
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define SWAP32LE IDENT32
-#define SWAP32BE SWAP32
-#define swap32le ident32
-#define swap32be swap32
-#define mem_inplace_swap32le mem_inplace_ident
-#define mem_inplace_swap32be mem_inplace_swap32
-#define memcpy_swap32le memcpy_ident32
-#define memcpy_swap32be memcpy_swap32
-#define SWAP64LE IDENT64
-#define SWAP64BE SWAP64
-#define swap64le ident64
-#define swap64be swap64
-#define mem_inplace_swap64le mem_inplace_ident
-#define mem_inplace_swap64be mem_inplace_swap64
-#define memcpy_swap64le memcpy_ident64
-#define memcpy_swap64be memcpy_swap64
-#endif
-
-#if BYTE_ORDER == BIG_ENDIAN
-#define SWAP32BE IDENT32
-#define SWAP32LE SWAP32
-#define swap32be ident32
-#define swap32le swap32
-#define mem_inplace_swap32be mem_inplace_ident
-#define mem_inplace_swap32le mem_inplace_swap32
-#define memcpy_swap32be memcpy_ident32
-#define memcpy_swap32le memcpy_swap32
-#define SWAP64BE IDENT64
-#define SWAP64LE SWAP64
-#define swap64be ident64
-#define swap64le swap64
-#define mem_inplace_swap64be mem_inplace_ident
-#define mem_inplace_swap64le mem_inplace_swap64
-#define memcpy_swap64be memcpy_ident64
-#define memcpy_swap64le memcpy_swap64
-#endif
diff --git a/src/common/password.cpp b/src/common/password.cpp
index b3c51128f..5f5cb800a 100644
--- a/src/common/password.cpp
+++ b/src/common/password.cpp
@@ -31,7 +31,6 @@
#include "password.h"
#include <iostream>
-#include <memory.h>
#include <stdio.h>
#if defined(_WIN32)
@@ -42,8 +41,6 @@
#include <unistd.h>
#endif
-#include "memwipe.h"
-
#define EOT 0x4
namespace
diff --git a/src/common/scoped_message_writer.h b/src/common/scoped_message_writer.h
index d887a13c9..42f439ad8 100644
--- a/src/common/scoped_message_writer.h
+++ b/src/common/scoped_message_writer.h
@@ -101,13 +101,13 @@ public:
MCLOG_FILE(m_log_level, "msgwriter", m_oss.str());
+ PAUSE_READLINE();
if (epee::console_color_default == m_color)
{
std::cout << m_oss.str();
}
else
{
- PAUSE_READLINE();
set_console_color(m_color, m_bright);
std::cout << m_oss.str();
epee::reset_console_color();
diff --git a/src/common/threadpool.cpp b/src/common/threadpool.cpp
index 37825e31d..cbf7163c5 100644
--- a/src/common/threadpool.cpp
+++ b/src/common/threadpool.cpp
@@ -28,10 +28,6 @@
#include "misc_log_ex.h"
#include "common/threadpool.h"
-#include <cassert>
-#include <limits>
-#include <stdexcept>
-
#include "cryptonote_config.h"
#include "common/util.h"
diff --git a/src/common/util.cpp b/src/common/util.cpp
index 58b0d8210..448f792ff 100644
--- a/src/common/util.cpp
+++ b/src/common/util.cpp
@@ -58,6 +58,7 @@
#include "include_base_utils.h"
#include "file_io_utils.h"
#include "wipeable_string.h"
+#include "misc_os_dependent.h"
using namespace epee;
#include "crypto/crypto.h"
@@ -1025,4 +1026,15 @@ std::string get_nix_version_display_string()
#endif
}
+ std::string get_human_readable_timestamp(uint64_t ts)
+ {
+ char buffer[64];
+ if (ts < 1234567890)
+ return "<unknown>";
+ time_t tt = ts;
+ struct tm tm;
+ misc_utils::get_gmt_time(tt, tm);
+ strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", &tm);
+ return std::string(buffer);
+ }
}
diff --git a/src/common/util.h b/src/common/util.h
index 1c5c5f4e7..d5aca15d1 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -242,4 +242,6 @@ namespace tools
#endif
void closefrom(int fd);
+
+ std::string get_human_readable_timestamp(uint64_t ts);
}