Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/bench/prevector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ struct nontrivial_t {
};
typedef prevector<28, unsigned char> prevec;

static_assert(!IS_TRIVIALLY_CONSTRUCTIBLE<nontrivial_t>::value,
static_assert(!std::is_trivially_default_constructible<nontrivial_t>::value,
"expected nontrivial_t to not be trivially constructible");

typedef unsigned char trivial_t;
static_assert(IS_TRIVIALLY_CONSTRUCTIBLE<trivial_t>::value,
static_assert(std::is_trivially_default_constructible<trivial_t>::value,
"expected trivial_t to be trivially constructible");

template <typename T>
Expand Down
2 changes: 2 additions & 0 deletions src/blockfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ bool BlockFilter::BuildParams(GCSFilter::Params& params) const
params.m_P = BASIC_FILTER_P;
params.m_M = BASIC_FILTER_M;
return true;
case BlockFilterType::INVALID:
return false;
}

return false;
Expand Down
5 changes: 3 additions & 2 deletions src/blockfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ class GCSFilter
constexpr uint8_t BASIC_FILTER_P = 19;
constexpr uint32_t BASIC_FILTER_M = 784931;

enum BlockFilterType : uint8_t
enum class BlockFilterType : uint8_t
{
BASIC_FILTER = 0,
INVALID = 255,
};

/** Get the human-readable name for a filter type. Returns empty string for unknown types. */
Expand All @@ -109,7 +110,7 @@ const std::string& ListBlockFilterTypes();
class BlockFilter
{
private:
BlockFilterType m_filter_type;
BlockFilterType m_filter_type = BlockFilterType::INVALID;
uint256 m_block_hash;
GCSFilter m_filter;

Expand Down
10 changes: 8 additions & 2 deletions src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,21 @@
* Maximum amount of time that a block timestamp is allowed to exceed the
* current network-adjusted time before the block will be accepted.
*/
static const int64_t MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60;
static constexpr int64_t MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60;

/**
* Timestamp window used as a grace period by code that compares external
* timestamps (such as timestamps passed to RPCs, or wallet key creation times)
* to block timestamps. This should be set at least as high as
* MAX_FUTURE_BLOCK_TIME.
*/
static const int64_t TIMESTAMP_WINDOW = MAX_FUTURE_BLOCK_TIME;
static constexpr int64_t TIMESTAMP_WINDOW = MAX_FUTURE_BLOCK_TIME;

/**
* Maximum gap between node time and block time used
* for the "Catching up..." mode in GUI.
*/
static constexpr int64_t MAX_BLOCK_TIME_GAP = 25 * 60;

class CBlockFileInfo
{
Expand Down
8 changes: 5 additions & 3 deletions src/coinjoin/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,8 +812,10 @@ bool CCoinJoinClientSession::DoAutomaticDenominating(CConnman& connman, bool fDr
return false;
}

const auto bal = mixingWallet.GetBalance();

// check if there is anything left to do
CAmount nBalanceAnonymized = mixingWallet.GetAnonymizedBalance();
CAmount nBalanceAnonymized = bal.m_anonymized;
nBalanceNeedsAnonymized = CCoinJoinClientOptions::GetAmount() * COIN - nBalanceAnonymized;

if (nBalanceNeedsAnonymized < 0) {
Expand Down Expand Up @@ -843,8 +845,8 @@ bool CCoinJoinClientSession::DoAutomaticDenominating(CConnman& connman, bool fDr
// excluding denoms
CAmount nBalanceAnonimizableNonDenom = mixingWallet.GetAnonymizableBalance(true);
// denoms
CAmount nBalanceDenominatedConf = mixingWallet.GetDenominatedBalance();
CAmount nBalanceDenominatedUnconf = mixingWallet.GetDenominatedBalance(true);
CAmount nBalanceDenominatedConf = bal.m_denominated_trusted;
CAmount nBalanceDenominatedUnconf = bal.m_denominated_untrusted_pending;
CAmount nBalanceDenominated = nBalanceDenominatedConf + nBalanceDenominatedUnconf;
CAmount nBalanceToDenominate = CCoinJoinClientOptions::GetAmount() * COIN - nBalanceDenominated;

Expand Down
10 changes: 0 additions & 10 deletions src/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@
#include <config/dash-config.h>
#endif

#include <type_traits>

// GCC 4.8 is missing some C++11 type_traits,
// https://www.gnu.org/software/gcc/gcc-5/changes.html
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5
#define IS_TRIVIALLY_CONSTRUCTIBLE std::has_trivial_default_constructor
#else
#define IS_TRIVIALLY_CONSTRUCTIBLE std::is_trivially_default_constructible
#endif

#ifdef WIN32
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
Expand Down
32 changes: 20 additions & 12 deletions src/interfaces/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ class WalletImpl : public Wallet
return result;
}
bool tryGetTxStatus(const uint256& txid,
interfaces::WalletTxStatus& tx_status) override
interfaces::WalletTxStatus& tx_status,
int64_t& block_time) override
{
TRY_LOCK(::cs_main, locked_chain);
if (!locked_chain) {
Expand All @@ -358,6 +359,7 @@ class WalletImpl : public Wallet
return false;
}
tx_status = MakeWalletTxStatus(mi->second);
block_time = ::chainActive.Tip()->GetBlockTime();
return true;
}
WalletTx getWalletTxDetails(const uint256& txid,
Expand All @@ -381,16 +383,17 @@ class WalletImpl : public Wallet
bool isFullyMixed(const COutPoint& outpoint) override { return m_wallet->IsFullyMixed(outpoint); }
WalletBalances getBalances() override
{
const auto bal = m_wallet->GetBalance();
WalletBalances result;
result.balance = m_wallet->GetBalance();
result.unconfirmed_balance = m_wallet->GetUnconfirmedBalance();
result.immature_balance = m_wallet->GetImmatureBalance();
result.anonymized_balance = m_wallet->GetAnonymizedBalance();
result.balance = bal.m_mine_trusted;
result.unconfirmed_balance = bal.m_mine_untrusted_pending;
result.immature_balance = bal.m_mine_immature;
result.anonymized_balance = bal.m_anonymized;
result.have_watch_only = m_wallet->HaveWatchOnly();
if (result.have_watch_only) {
result.watch_only_balance = m_wallet->GetBalance(ISMINE_WATCH_ONLY);
result.unconfirmed_watch_only_balance = m_wallet->GetUnconfirmedWatchOnlyBalance();
result.immature_watch_only_balance = m_wallet->GetImmatureWatchOnlyBalance();
result.watch_only_balance = bal.m_watchonly_trusted;
result.unconfirmed_watch_only_balance = bal.m_watchonly_untrusted_pending;
result.immature_watch_only_balance = bal.m_watchonly_immature;
}
return result;
}
Expand All @@ -408,19 +411,24 @@ class WalletImpl : public Wallet
}
CAmount getBalance() override
{
return m_wallet->GetBalance();
return m_wallet->GetBalance().m_mine_trusted;
}
CAmount getAnonymizableBalance(bool fSkipDenominated, bool fSkipUnconfirmed) override
{
return m_wallet->GetAnonymizableBalance(fSkipDenominated, fSkipUnconfirmed);
}
CAmount getAnonymizedBalance() override
{
return m_wallet->GetAnonymizedBalance();
return m_wallet->GetBalance().m_anonymized;
}
CAmount getDenominatedBalance(bool unconfirmed) override
{
return m_wallet->GetDenominatedBalance(unconfirmed);
const auto bal = m_wallet->GetBalance();
if (unconfirmed) {
return bal.m_denominated_untrusted_pending;
} else {
return bal.m_denominated_trusted;
}
}
CAmount getNormalizedAnonymizedBalance() override
{
Expand All @@ -433,7 +441,7 @@ class WalletImpl : public Wallet
CAmount getAvailableBalance(const CCoinControl& coin_control) override
{
if (coin_control.IsUsingCoinJoin()) {
return m_wallet->GetAnonymizedBalance(&coin_control);
return m_wallet->GetBalance(0, false, &coin_control).m_anonymized;
} else {
return m_wallet->GetAvailableBalance(&coin_control);
}
Expand Down
3 changes: 2 additions & 1 deletion src/interfaces/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ class Wallet

//! Try to get updated status for a particular transaction, if possible without blocking.
virtual bool tryGetTxStatus(const uint256& txid,
WalletTxStatus& tx_status) = 0;
WalletTxStatus& tx_status,
int64_t& block_time) = 0;

//! Get transaction details.
virtual WalletTx getWalletTxDetails(const uint256& txid,
Expand Down
12 changes: 3 additions & 9 deletions src/prevector.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
#include <iterator>
#include <type_traits>

#include <compat.h>

/** Implements a drop-in replacement for std::vector<T> which stores up to N
* elements directly (without heap allocation). The types Size and Diff are
* used to store element counts, and can be any unsigned + signed type.
Expand Down Expand Up @@ -203,11 +201,7 @@ class prevector {
T* item_ptr(difference_type pos) { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); }
const T* item_ptr(difference_type pos) const { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); }

void fill(T* dst, ptrdiff_t count) {
std::fill_n(dst, count, T{});
}

void fill(T* dst, ptrdiff_t count, const T& value) {
void fill(T* dst, ptrdiff_t count, const T& value = T{}) {
std::fill_n(dst, count, value);
}

Expand All @@ -226,7 +220,7 @@ class prevector {
}

void fill(T* dst, const T* src, ptrdiff_t count) {
if (IS_TRIVIALLY_CONSTRUCTIBLE<T>::value) {
if (std::is_trivially_constructible<T>::value) {
::memmove(dst, src, count * sizeof(T));
} else {
for (ptrdiff_t i = 0; i < count; i++) {
Expand Down Expand Up @@ -560,7 +554,7 @@ class prevector {
static void assign_to(const_iterator b, const_iterator e, V& v) {
// We know that internally the iterators are pointing to continues memory, so we can directly use the pointers here
// This avoids internal use of std::copy and operator++ on the iterators and instead allows efficient memcpy/memmove
if (IS_TRIVIALLY_CONSTRUCTIBLE<T>::value) {
if (std::is_trivially_constructible<T>::value) {
auto s = e - b;
if (v.size() != s) {
v.resize(s);
Expand Down
22 changes: 11 additions & 11 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <qt/macdockiconhandler.h>
#endif

#include <chain.h>
#include <chainparams.h>
#include <interfaces/handler.h>
#include <interfaces/node.h>
Expand All @@ -37,6 +38,7 @@
#include <qt/masternodelist.h>

#include <iostream>
#include <memory>

#include <QAction>
#include <QApplication>
Expand All @@ -46,6 +48,7 @@
#include <QDesktopWidget>
#include <QDragEnterEvent>
#include <QListWidget>
#include <QMenu>
#include <QMenuBar>
#include <QMessageBox>
#include <QMimeData>
Expand All @@ -55,6 +58,7 @@
#include <QStackedWidget>
#include <QStatusBar>
#include <QStyle>
#include <QSystemTrayIcon>
#include <QTimer>
#include <QToolBar>
#include <QToolButton>
Expand All @@ -76,7 +80,8 @@ const std::string BitcoinGUI::DEFAULT_UIPLATFORM =
BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle, QWidget* parent) :
QMainWindow(parent),
m_node(node),
m_network_style(networkStyle)
m_network_style(networkStyle),
trayIconMenu{new QMenu()}
{
GUIUtil::loadTheme(true);

Expand Down Expand Up @@ -692,9 +697,8 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
// while the client has not yet fully loaded
if (trayIcon) {
// do so only if trayIcon is already set
trayIconMenu = new QMenu(this);
trayIcon->setContextMenu(trayIconMenu);
createIconMenu(trayIconMenu);
trayIcon->setContextMenu(trayIconMenu.get());
createIconMenu(trayIconMenu.get());

#ifndef Q_OS_MAC
// Show main window on tray icon click
Expand Down Expand Up @@ -1318,16 +1322,12 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, const QStri

// Set icon state: spinning if catching up, tick otherwise
#ifdef ENABLE_WALLET
if (walletFrame)
{
if(secs < 25*60) // 90*60 in bitcoin
{
if (walletFrame) {
if(secs < MAX_BLOCK_TIME_GAP) {
modalOverlay->showHide(true, true);
// TODO instead of hiding it forever, we should add meaningful information about MN sync to the overlay
modalOverlay->hideForever();
}
else
{
} else {
modalOverlay->showHide();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <QLabel>
#include <QMainWindow>
#include <QMap>
#include <QMenu>
#include <QPoint>
#include <QPushButton>
#include <QSystemTrayIcon>
Expand Down Expand Up @@ -47,6 +46,7 @@ QT_BEGIN_NAMESPACE
class QAction;
class QButtonGroup;
class QComboBox;
class QMenu;
class QProgressBar;
class QProgressDialog;
class QToolButton;
Expand Down Expand Up @@ -165,7 +165,7 @@ class BitcoinGUI : public QMainWindow
QComboBox* m_wallet_selector = nullptr;

QSystemTrayIcon* trayIcon = nullptr;
QMenu* trayIconMenu = nullptr;
const std::unique_ptr<QMenu> trayIconMenu;
QMenu* dockIconMenu = nullptr;
Notificator* notificator = nullptr;
RPCConsole* rpcConsole = nullptr;
Expand Down
Loading