Skip to content

Commit df80506

Browse files
committed
disabled exchange
1 parent 4afb41a commit df80506

4 files changed

Lines changed: 60 additions & 33 deletions

File tree

src/main.cpp

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3465,47 +3465,51 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
34653465

34663466
else if (strCommand == "xbridge")
34673467
{
3468-
std::vector<unsigned char> raw;
3469-
vRecv >> raw;
3470-
3471-
uint256 hash = Hash(raw.begin(), raw.end());
3472-
if (!pfrom->setKnown.count(hash))
3468+
static bool isEnabled = XBridgeApp::isEnabled();
3469+
if (isEnabled)
34733470
{
3474-
pfrom->setKnown.insert(hash);
3471+
std::vector<unsigned char> raw;
3472+
vRecv >> raw;
34753473

3476-
// Relay
3474+
uint256 hash = Hash(raw.begin(), raw.end());
3475+
if (!pfrom->setKnown.count(hash))
34773476
{
3478-
LOCK(cs_vNodes);
3479-
for (CNode * pnode : vNodes)
3477+
pfrom->setKnown.insert(hash);
3478+
3479+
// Relay
34803480
{
3481-
if (pnode->setKnown.insert(hash).second)
3481+
LOCK(cs_vNodes);
3482+
for (CNode * pnode : vNodes)
34823483
{
3483-
pnode->PushMessage("xbridge", raw);
3484+
if (pnode->setKnown.insert(hash).second)
3485+
{
3486+
pnode->PushMessage("xbridge", raw);
3487+
}
34843488
}
34853489
}
3486-
}
34873490

3488-
if (raw.size() > 20 + sizeof(time_t))
3489-
{
3490-
static std::vector<unsigned char> zero(20, 0);
3491-
std::vector<unsigned char> addr(raw.begin(), raw.begin()+20);
3492-
// remove addr from raw
3493-
raw.erase(raw.begin(), raw.begin()+20);
3494-
// remove timestamp from raw
3495-
raw.erase(raw.begin(), raw.begin()+sizeof(uint64_t));
3491+
if (raw.size() > 20 + sizeof(time_t))
3492+
{
3493+
static std::vector<unsigned char> zero(20, 0);
3494+
std::vector<unsigned char> addr(raw.begin(), raw.begin()+20);
3495+
// remove addr from raw
3496+
raw.erase(raw.begin(), raw.begin()+20);
3497+
// remove timestamp from raw
3498+
raw.erase(raw.begin(), raw.begin()+sizeof(uint64_t));
34963499

3497-
XBridgeApp & app = XBridgeApp::instance();
3500+
XBridgeApp & app = XBridgeApp::instance();
34983501

3499-
if (addr != zero)
3500-
{
3501-
app.onMessageReceived(addr, raw);
3502-
}
3503-
else
3504-
{
3505-
app.onBroadcastReceived(raw);
3502+
if (addr != zero)
3503+
{
3504+
app.onMessageReceived(addr, raw);
3505+
}
3506+
else
3507+
{
3508+
app.onBroadcastReceived(raw);
3509+
}
35063510
}
35073511
}
3508-
}
3512+
} // if (isEnabled)
35093513
}
35103514

35113515
// messages

src/qt/bitcoingui.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "messagedialog/messagedialog.h"
3434
#include "xbridgeui/xbridgetransactionsview.h"
3535
#include "xbridge/xbridgeexchange.h"
36+
#include "xbridge/xbridgeapp.h"
3637
#include "util/verify.h"
3738

3839
#ifdef Q_OS_MAC
@@ -159,7 +160,10 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
159160
centralWidget->addWidget(receiveCoinsPage);
160161
centralWidget->addWidget(sendCoinsPage);
161162
centralWidget->addWidget(messagesPage);
162-
centralWidget->addWidget(xbridgePage);
163+
if (XBridgeApp::isEnabled())
164+
{
165+
centralWidget->addWidget(xbridgePage);
166+
}
163167
setCentralWidget(centralWidget);
164168

165169

@@ -303,14 +307,19 @@ void BitcoinGUI::createActions()
303307
messagesAction->setToolTip(tr("Show chat"));
304308
// messagesAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_6));
305309
messagesAction->setCheckable(true);
310+
#if 0
306311
tabGroup->addAction(messagesAction);
312+
#endif
307313

308314
// TODO icons
309315
xbridgeAction = new QAction(QIcon(":/icons/block"), tr("&XBridge"), this);
310316
xbridgeAction->setToolTip(tr("Show xbridge dialog"));
311317
// xbridgeAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_6));
312318
xbridgeAction->setCheckable(true);
313-
tabGroup->addAction(xbridgeAction);
319+
if (XBridgeApp::isEnabled())
320+
{
321+
tabGroup->addAction(xbridgeAction);
322+
}
314323

315324
connect(blockAction, SIGNAL(triggered()), this, SLOT(gotoBlockBrowser()));
316325
VERIFY(connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())));
@@ -444,10 +453,14 @@ void BitcoinGUI::createToolBars()
444453
spacer->setObjectName("spacer");
445454
toolbar->addAction(unlockWalletAction);
446455
toolbar->addAction(lockWalletAction);
456+
#if 0
447457
toolbar->addAction(messagesAction);
448-
toolbar->addAction(xbridgeAction);
449-
458+
#endif
450459

460+
if (XBridgeApp::isEnabled())
461+
{
462+
toolbar->addAction(xbridgeAction);
463+
}
451464
}
452465

453466
//*****************************************************************************

src/xbridge/xbridgeapp.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ std::string XBridgeApp::version()
100100
return o.str();
101101
}
102102

103+
//*****************************************************************************
104+
//*****************************************************************************
105+
// static
106+
bool XBridgeApp::isEnabled()
107+
{
108+
return false;
109+
}
110+
103111
//*****************************************************************************
104112
//*****************************************************************************
105113
bool XBridgeApp::start()

src/xbridge/xbridgeapp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class XBridgeApp
4646

4747
static std::string version();
4848

49+
static bool isEnabled();
50+
4951
bool init(int argc, char *argv[]);
5052
bool start();
5153

0 commit comments

Comments
 (0)