Anoncoin  0.9.4
P2P Digital Currency
rpcconsole.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2014 The Bitcoin developers
2 // Copyright (c) 2013-2015 The Anoncoin Core developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 // Many builder specific things set in the config file, ENABLE_WALLET is a good example. Don't forget to include it this way in your source files.
7 #if defined(HAVE_CONFIG_H)
9 #endif
10 
11 #include "rpcconsole.h"
12 #include "ui_rpcconsole.h"
13 
14 #include "clientmodel.h"
15 #include "guiutil.h"
16 #include "peertablemodel.h"
17 
18 #include "main.h"
19 #include "chainparams.h"
20 #include "rpcserver.h"
21 #include "rpcclient.h"
22 #include "util.h"
23 
24 
25 #include "json/json_spirit_value.h"
26 #include <openssl/crypto.h>
27 
28 #ifdef ENABLE_WALLET
29 #include <db_cxx.h>
30 #endif
31 
32 #include <QKeyEvent>
33 #include <QScrollBar>
34 #include <QThread>
35 #include <QTime>
36 
37 #if QT_VERSION < 0x050000
38 #include <QUrl>
39 #endif
40 
41 // TODO: add a scrollback limit, as there is currently none
42 // TODO: make it possible to filter out categories (esp debug messages when implemented)
43 // TODO: receive errors and debug messages through ClientModel
44 
45 const int CONSOLE_HISTORY = 50;
46 const QSize ICON_SIZE(24, 24);
47 
49 
50 const struct {
51  const char *url;
52  const char *source;
53 } ICON_MAPPING[] = {
54  {"cmd-request", ":/icons/tx_input"},
55  {"cmd-reply", ":/icons/tx_output"},
56  {"cmd-error", ":/icons/tx_output"},
57  {"misc", ":/icons/tx_inout"},
58  {NULL, NULL}
59 };
60 
61 /* Object for executing console RPC commands in a separate thread.
62 */
63 class RPCExecutor : public QObject
64 {
65  Q_OBJECT
66 
67 public slots:
68  void request(const QString &command);
69 
70 signals:
71  void reply(int category, const QString &command);
72 };
73 
74 #include "rpcconsole.moc"
75 
90 bool parseCommandLine(std::vector<std::string> &args, const std::string &strCommand)
91 {
92  enum CmdParseState
93  {
94  STATE_EATING_SPACES,
95  STATE_ARGUMENT,
96  STATE_SINGLEQUOTED,
97  STATE_DOUBLEQUOTED,
98  STATE_ESCAPE_OUTER,
99  STATE_ESCAPE_DOUBLEQUOTED
100  } state = STATE_EATING_SPACES;
101  std::string curarg;
102  foreach(char ch, strCommand)
103  {
104  switch(state)
105  {
106  case STATE_ARGUMENT: // In or after argument
107  case STATE_EATING_SPACES: // Handle runs of whitespace
108  switch(ch)
109  {
110  case '"': state = STATE_DOUBLEQUOTED; break;
111  case '\'': state = STATE_SINGLEQUOTED; break;
112  case '\\': state = STATE_ESCAPE_OUTER; break;
113  case ' ': case '\n': case '\t':
114  if(state == STATE_ARGUMENT) // Space ends argument
115  {
116  args.push_back(curarg);
117  curarg.clear();
118  }
119  state = STATE_EATING_SPACES;
120  break;
121  default: curarg += ch; state = STATE_ARGUMENT;
122  }
123  break;
124  case STATE_SINGLEQUOTED: // Single-quoted string
125  switch(ch)
126  {
127  case '\'': state = STATE_ARGUMENT; break;
128  default: curarg += ch;
129  }
130  break;
131  case STATE_DOUBLEQUOTED: // Double-quoted string
132  switch(ch)
133  {
134  case '"': state = STATE_ARGUMENT; break;
135  case '\\': state = STATE_ESCAPE_DOUBLEQUOTED; break;
136  default: curarg += ch;
137  }
138  break;
139  case STATE_ESCAPE_OUTER: // '\' outside quotes
140  curarg += ch; state = STATE_ARGUMENT;
141  break;
142  case STATE_ESCAPE_DOUBLEQUOTED: // '\' in double-quoted text
143  if(ch != '"' && ch != '\\') curarg += '\\'; // keep '\' for everything but the quote and '\' itself
144  curarg += ch; state = STATE_DOUBLEQUOTED;
145  break;
146  }
147  }
148  switch(state) // final state
149  {
150  case STATE_EATING_SPACES:
151  return true;
152  case STATE_ARGUMENT:
153  args.push_back(curarg);
154  return true;
155  default: // ERROR to end in one of the other states
156  return false;
157  }
158 }
159 
160 void RPCExecutor::request(const QString &command)
161 {
162  std::vector<std::string> args;
163  if(!parseCommandLine(args, command.toStdString()))
164  {
165  emit reply(RPCConsole::CMD_ERROR, QString("Parse error: unbalanced ' or \""));
166  return;
167  }
168  if(args.empty())
169  return; // Nothing to do
170  try
171  {
172  std::string strPrint;
173  // Convert argument list to JSON objects in method-dependent way,
174  // and pass it along with the method name to the dispatcher.
175  json_spirit::Value result = tableRPC.execute(
176  args[0],
177  RPCConvertValues(args[0], std::vector<std::string>(args.begin() + 1, args.end())));
178 
179  // Format result reply
180  if (result.type() == json_spirit::null_type)
181  strPrint = "";
182  else if (result.type() == json_spirit::str_type)
183  strPrint = result.get_str();
184  else
185  strPrint = write_string(result, true);
186 
187  emit reply(RPCConsole::CMD_REPLY, QString::fromStdString(strPrint));
188  }
189  catch (json_spirit::Object& objError)
190  {
191  try // Nice formatting for standard-format error
192  {
193  int code = find_value(objError, "code").get_int();
194  std::string message = find_value(objError, "message").get_str();
195  emit reply(RPCConsole::CMD_ERROR, QString::fromStdString(message) + " (code " + QString::number(code) + ")");
196  }
197  catch(std::runtime_error &) // raised when converting to invalid type, i.e. missing code or message
198  { // Show raw JSON object
199  emit reply(RPCConsole::CMD_ERROR, QString::fromStdString(write_string(json_spirit::Value(objError), false)));
200  }
201  }
202  catch (std::exception& e)
203  {
204  emit reply(RPCConsole::CMD_ERROR, QString("Error: ") + QString::fromStdString(e.what()));
205  }
206 }
207 
208 RPCConsole::RPCConsole(QWidget *parent) :
209  QDialog(parent),
210  ui(new Ui::RPCConsole),
211  clientModel(0),
212  historyPtr(0),
213  cachedNodeid(-1)
214 {
215  ui->setupUi(this);
216  GUIUtil::restoreWindowGeometry("nRPCConsoleWindow", this->size(), this);
217 
218 #ifndef Q_OS_MAC
219  ui->openDebugLogfileButton->setIcon(QIcon(":/icons/export"));
220 #endif
221 
222  // Install event filter for up and down arrow
223  ui->lineEdit->installEventFilter(this);
224  ui->messagesWidget->installEventFilter(this);
225 
226  connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear()));
227  connect(ui->btnClearTrafficGraph, SIGNAL(clicked()), ui->trafficGraph, SLOT(clear()));
228 
229  // set OpenSSL version string value
230  ui->openSSLVersion->setText(SSLeay_version(SSLEAY_VERSION));
231 
232  // Set berkelyDB Version string value
233 #ifdef ENABLE_WALLET
234  ui->berkeleyDBVersion->setText(DbEnv::version(0, 0, 0));
235 #else
236  ui->label_berkeleyDBVersion->hide();
237  ui->berkeleyDBVersion->hide();
238 #endif
239 
240  startExecutor();
242 
243  ui->detailWidget->hide();
244  ui->peerHeading->setText(tr("Select a peer to view detailed information."));
245 
246  clear();
247 }
248 
250 {
251  GUIUtil::saveWindowGeometry("nRPCConsoleWindow", this);
252  emit stopExecutor();
253  delete ui;
254 }
255 
256 bool RPCConsole::eventFilter(QObject* obj, QEvent *event)
257 {
258  if(event->type() == QEvent::KeyPress) // Special key handling
259  {
260  QKeyEvent *keyevt = static_cast<QKeyEvent*>(event);
261  int key = keyevt->key();
262  Qt::KeyboardModifiers mod = keyevt->modifiers();
263  switch(key)
264  {
265  case Qt::Key_Up: if(obj == ui->lineEdit) { browseHistory(-1); return true; } break;
266  case Qt::Key_Down: if(obj == ui->lineEdit) { browseHistory(1); return true; } break;
267  case Qt::Key_PageUp: /* pass paging keys to messages widget */
268  case Qt::Key_PageDown:
269  if(obj == ui->lineEdit)
270  {
271  QApplication::postEvent(ui->messagesWidget, new QKeyEvent(*keyevt));
272  return true;
273  }
274  break;
275  default:
276  // Typing in messages widget brings focus to line edit, and redirects key there
277  // Exclude most combinations and keys that emit no text, except paste shortcuts
278  if(obj == ui->messagesWidget && (
279  (!mod && !keyevt->text().isEmpty() && key != Qt::Key_Tab) ||
280  ((mod & Qt::ControlModifier) && key == Qt::Key_V) ||
281  ((mod & Qt::ShiftModifier) && key == Qt::Key_Insert)))
282  {
283  ui->lineEdit->setFocus();
284  QApplication::postEvent(ui->lineEdit, new QKeyEvent(*keyevt));
285  return true;
286  }
287  }
288  }
289  return QDialog::eventFilter(obj, event);
290 }
291 
293 {
294  clientModel = model;
295  ui->trafficGraph->setClientModel(model);
296  if(model)
297  {
298  // Keep up to date with client
300  connect(model, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
301 
302  setNumBlocks(model->getNumBlocks());
303  connect(model, SIGNAL(numBlocksChanged(int)), this, SLOT(setNumBlocks(int)));
304 
306  connect(model, SIGNAL(bytesChanged(quint64,quint64)), this, SLOT(updateTrafficStats(quint64, quint64)));
307 
308  // set up peer table
309  ui->peerWidget->setModel(model->getPeerTableModel());
310  ui->peerWidget->verticalHeader()->hide();
311  ui->peerWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
312  ui->peerWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
313  ui->peerWidget->setSelectionMode(QAbstractItemView::SingleSelection);
317 
318  // connect the peerWidget selection model to our peerSelected() handler
319  connect(ui->peerWidget->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
320  this, SLOT(peerSelected(const QItemSelection &, const QItemSelection &)));
321  connect(model->getPeerTableModel(), SIGNAL(layoutChanged()), this, SLOT(peerLayoutChanged()));
322 
323  // Provide initial values
324  ui->clientVersion->setText(model->formatFullVersion());
325  ui->clientName->setText(model->clientName());
326  ui->buildDate->setText(model->formatBuildDate());
327  ui->startupTime->setText(model->formatClientStartupTime());
328 
329  ui->networkName->setText(QString::fromStdString(Params().NetworkIDString()));
330  // ui->networkName->setText(model->getNetworkName());
331  }
332 }
333 
334 static QString categoryClass(int category)
335 {
336  switch(category)
337  {
338  case RPCConsole::CMD_REQUEST: return "cmd-request"; break;
339  case RPCConsole::CMD_REPLY: return "cmd-reply"; break;
340  case RPCConsole::CMD_ERROR: return "cmd-error"; break;
341  default: return "misc";
342  }
343 }
344 
346 {
347  ui->messagesWidget->clear();
348  history.clear();
349  historyPtr = 0;
350  ui->lineEdit->clear();
351  ui->lineEdit->setFocus();
352 
353  // Add smoothly scaled icon images.
354  // (when using width/height on an img, Qt uses nearest instead of linear interpolation)
355  for(int i=0; ICON_MAPPING[i].url; ++i)
356  {
357  ui->messagesWidget->document()->addResource(
358  QTextDocument::ImageResource,
359  QUrl(ICON_MAPPING[i].url),
360  QImage(ICON_MAPPING[i].source).scaled(ICON_SIZE, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
361  }
362 
363  // Set default style sheet
364  ui->messagesWidget->document()->setDefaultStyleSheet(
365  "table { }"
366  "td.time { color: #808080; padding-top: 3px; } "
367  "td.message { font-family: monospace; font-size: 12px; } " // Todo: Remove fixed font-size
368  "td.cmd-request { color: #006060; } "
369  "td.cmd-error { color: red; } "
370  "b { color: #006060; } "
371  );
372 
373  message(CMD_REPLY, (tr("Welcome to the Anoncoin RPC console.") + "<br>" +
374  tr("Use up and down arrows to navigate history, and <b>Ctrl-L</b> to clear screen.") + "<br>" +
375  tr("Type <b>help</b> for an overview of available commands.")), true);
376 }
377 
379 {
380  // Ignore escape keypress if this is not a seperate window
381  if(windowType() != Qt::Widget)
382  QDialog::reject();
383 }
384 
385 void RPCConsole::message(int category, const QString &message, bool html)
386 {
387  QTime time = QTime::currentTime();
388  QString timeString = time.toString();
389  QString out;
390  out += "<table><tr><td class=\"time\" width=\"65\">" + timeString + "</td>";
391  out += "<td class=\"icon\" width=\"32\"><img src=\"" + categoryClass(category) + "\"></td>";
392  out += "<td class=\"message " + categoryClass(category) + "\" valign=\"middle\">";
393  if(html)
394  out += message;
395  else
396  out += GUIUtil::HtmlEscape(message, true);
397  out += "</td></tr></table>";
398  ui->messagesWidget->append(out);
399 }
400 
402 {
403  if (!clientModel)
404  return;
405 
406  QString connections = QString::number(count) + " (";
407  connections += tr("In:") + " " + QString::number(clientModel->getNumConnections(CONNECTIONS_IN)) + " / ";
408  connections += tr("Out:") + " " + QString::number(clientModel->getNumConnections(CONNECTIONS_OUT)) + ")";
409 
410  ui->numberOfConnections->setText(connections);
411 }
412 
414 {
415  ui->numberOfBlocks->setText(QString::number(count));
416  if(clientModel)
417  ui->lastBlockTime->setText(clientModel->getLastBlockDate().toString());
418 }
419 
421 {
422  QString cmd = ui->lineEdit->text();
423  ui->lineEdit->clear();
424 
425  if(!cmd.isEmpty())
426  {
427  message(CMD_REQUEST, cmd);
428  emit cmdRequest(cmd);
429  // Remove command, if already in history
430  history.removeOne(cmd);
431  // Append command to history
432  history.append(cmd);
433  // Enforce maximum history size
434  while(history.size() > CONSOLE_HISTORY)
435  history.removeFirst();
436  // Set pointer to end of history
437  historyPtr = history.size();
438  // Scroll console view to end
439  scrollToEnd();
440  }
441 }
442 
444 {
445  historyPtr += offset;
446  if(historyPtr < 0)
447  historyPtr = 0;
448  if(historyPtr > history.size())
449  historyPtr = history.size();
450  QString cmd;
451  if(historyPtr < history.size())
452  cmd = history.at(historyPtr);
453  ui->lineEdit->setText(cmd);
454 }
455 
457 {
458  QThread *thread = new QThread;
459  RPCExecutor *executor = new RPCExecutor();
460  executor->moveToThread(thread);
461 
462  // Replies from executor object must go to this object
463  connect(executor, SIGNAL(reply(int,QString)), this, SLOT(message(int,QString)));
464  // Requests from this object must go to executor
465  connect(this, SIGNAL(cmdRequest(QString)), executor, SLOT(request(QString)));
466 
467  // On stopExecutor signal
468  // - queue executor for deletion (in execution thread)
469  // - quit the Qt event loop in the execution thread
470  connect(this, SIGNAL(stopExecutor()), executor, SLOT(deleteLater()));
471  connect(this, SIGNAL(stopExecutor()), thread, SLOT(quit()));
472  // Queue the thread for deletion (in this thread) when it is finished
473  connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
474 
475  // Default implementation of QThread::run() simply spins up an event loop in the thread,
476  // which is what we want.
477  thread->start();
478 }
479 
481 {
482  if(ui->tabWidget->widget(index) == ui->tab_console)
483  {
484  ui->lineEdit->setFocus();
485  }
486 }
487 
489 {
491 }
492 
494 {
495  QScrollBar *scrollbar = ui->messagesWidget->verticalScrollBar();
496  scrollbar->setValue(scrollbar->maximum());
497 }
498 
500 {
501  const int multiplier = 5; // each position on the slider represents 5 min
502  int mins = value * multiplier;
503  setTrafficGraphRange(mins);
504 }
505 
506 QString RPCConsole::FormatBytes(quint64 bytes)
507 {
508  if(bytes < 1024)
509  return QString(tr("%1 B")).arg(bytes);
510  if(bytes < 1024 * 1024)
511  return QString(tr("%1 KB")).arg(bytes / 1024);
512  if(bytes < 1024 * 1024 * 1024)
513  return QString(tr("%1 MB")).arg(bytes / 1024 / 1024);
514 
515  return QString(tr("%1 GB")).arg(bytes / 1024 / 1024 / 1024);
516 }
517 
519 {
521  if(mins < 60) {
522  ui->lblGraphRange->setText(QString(tr("%1 m")).arg(mins));
523  } else {
524  int hours = mins / 60;
525  int minsLeft = mins % 60;
526  if(minsLeft == 0) {
527  ui->lblGraphRange->setText(QString(tr("%1 h")).arg(hours));
528  } else {
529  ui->lblGraphRange->setText(QString(tr("%1 h %2 m")).arg(hours).arg(minsLeft));
530  }
531  }
532 }
533 
534 void RPCConsole::updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut)
535 {
536  ui->lblBytesIn->setText(FormatBytes(totalBytesIn));
537  ui->lblBytesOut->setText(FormatBytes(totalBytesOut));
538 }
539 
540 void RPCConsole::peerSelected(const QItemSelection &selected, const QItemSelection &deselected)
541 {
542  Q_UNUSED(deselected);
543 
544  if (!clientModel || selected.indexes().isEmpty())
545  return;
546 
547  const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(selected.indexes().first().row());
548  if (stats)
549  updateNodeDetail(stats);
550 }
551 
553 {
554  if (!clientModel)
555  return;
556 
557  const CNodeCombinedStats *stats = NULL;
558  bool fUnselect = false;
559  bool fReselect = false;
560 
561  if (cachedNodeid == -1) // no node selected yet
562  return;
563 
564  // find the currently selected row
565  int selectedRow;
566  QModelIndexList selectedModelIndex = ui->peerWidget->selectionModel()->selectedIndexes();
567  if (selectedModelIndex.isEmpty())
568  selectedRow = -1;
569  else
570  selectedRow = selectedModelIndex.first().row();
571 
572  // check if our detail node has a row in the table (it may not necessarily
573  // be at selectedRow since its position can change after a layout change)
574  int detailNodeRow = clientModel->getPeerTableModel()->getRowByNodeId(cachedNodeid);
575 
576  if (detailNodeRow < 0)
577  {
578  // detail node dissapeared from table (node disconnected)
579  fUnselect = true;
580  cachedNodeid = -1;
581  ui->detailWidget->hide();
582  ui->peerHeading->setText(tr("Select a peer to view detailed information."));
583  }
584  else
585  {
586  if (detailNodeRow != selectedRow)
587  {
588  // detail node moved position
589  fUnselect = true;
590  fReselect = true;
591  }
592 
593  // get fresh stats on the detail node.
594  stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow);
595  }
596 
597  if (fUnselect && selectedRow >= 0)
598  {
599  ui->peerWidget->selectionModel()->select(QItemSelection(selectedModelIndex.first(), selectedModelIndex.last()),
600  QItemSelectionModel::Deselect);
601  }
602 
603  if (fReselect)
604  {
605  ui->peerWidget->selectRow(detailNodeRow);
606  }
607 
608  if (stats)
609  updateNodeDetail(stats);
610 }
611 
613 {
614  // Update cached nodeid
615  cachedNodeid = stats->nodeStats.nodeid;
616 
617  // update the detail ui with latest node information
618  QString peerAddrDetails(QString::fromStdString(stats->nodeStats.addrName));
619  if (!stats->nodeStats.addrLocal.empty())
620  peerAddrDetails += "<br />" + tr("via %1").arg(QString::fromStdString(stats->nodeStats.addrLocal));
621  ui->peerHeading->setText(peerAddrDetails);
623  ui->peerLastSend->setText(stats->nodeStats.nLastSend ? GUIUtil::formatDurationStr(GetTime() - stats->nodeStats.nLastSend) : tr("never"));
624  ui->peerLastRecv->setText(stats->nodeStats.nLastRecv ? GUIUtil::formatDurationStr(GetTime() - stats->nodeStats.nLastRecv) : tr("never"));
625  ui->peerBytesSent->setText(FormatBytes(stats->nodeStats.nSendBytes));
626  ui->peerBytesRecv->setText(FormatBytes(stats->nodeStats.nRecvBytes));
629  ui->peerVersion->setText(QString("%1").arg(stats->nodeStats.nVersion));
630  ui->peerSubversion->setText(QString::fromStdString(stats->nodeStats.cleanSubVer));
631  ui->peerDirection->setText(stats->nodeStats.fInbound ? tr("Inbound") : tr("Outbound"));
632  ui->peerHeight->setText(QString("%1").arg(stats->nodeStats.nStartingHeight));
633 
634  // This check fails for example if the lock was busy and
635  // nodeStateStats couldn't be fetched.
636  if (stats->fNodeStateStatsAvailable) {
637  // Ban score is init to 0
638  ui->peerBanScore->setText(QString("%1").arg(stats->nodeStateStats.nMisbehavior));
639 
640  // Sync height is init to -1
641  if (stats->nodeStateStats.nSyncHeight > -1)
642  ui->peerSyncHeight->setText(QString("%1").arg(stats->nodeStateStats.nSyncHeight));
643  else
644  ui->peerSyncHeight->setText(tr("Unknown"));
645  } else {
646  ui->peerBanScore->setText(tr("Fetching..."));
647  ui->peerSyncHeight->setText(tr("Fetching..."));
648  }
649 
650  ui->detailWidget->show();
651 }
652 
653 void RPCConsole::resizeEvent(QResizeEvent *event)
654 {
655  QWidget::resizeEvent(event);
656 }
657 
658 void RPCConsole::showEvent(QShowEvent *event)
659 {
660  QWidget::showEvent(event);
661 
662  if (!clientModel)
663  return;
664 
665  // start PeerTableModel auto refresh
667 }
668 
669 void RPCConsole::hideEvent(QHideEvent *event)
670 {
671  QWidget::hideEvent(event);
672 
673  if (!clientModel)
674  return;
675 
676  // stop PeerTableModel auto refresh
678 }
void openDebugLogfile()
Definition: guiutil.cpp:373
int getRowByNodeId(NodeId nodeid)
QTableView * peerWidget
Definition: ui_rpcconsole.h:99
void reject()
Definition: rpcconsole.cpp:378
QLabel * peerPingTime
int nStartingHeight
Definition: net.h:171
Local Anoncoin RPC console.
Definition: rpcconsole.h:26
QLabel * berkeleyDBVersion
Definition: ui_rpcconsole.h:51
QLabel * clientVersion
Definition: ui_rpcconsole.h:47
CNodeStateStats nodeStateStats
QLabel * lblGraphRange
Definition: ui_rpcconsole.h:83
static QString FormatBytes(quint64 bytes)
Definition: rpcconsole.cpp:506
void showEvent(QShowEvent *event)
Definition: rpcconsole.cpp:658
QPushButton * openDebugLogfileButton
Definition: ui_rpcconsole.h:68
QLabel * peerLastRecv
void on_lineEdit_returnPressed()
Definition: rpcconsole.cpp:420
int nMisbehavior
Definition: main.h:207
QLabel * numberOfConnections
Definition: ui_rpcconsole.h:60
QLabel * peerServices
QLabel * networkName
Definition: ui_rpcconsole.h:58
NodeId cachedNodeid
Definition: rpcconsole.h:100
void message(int category, const QString &message, bool html=false)
Definition: rpcconsole.cpp:385
QStringList history
Definition: rpcconsole.h:98
quint64 getTotalBytesRecv() const
Definition: clientmodel.cpp:77
bool parseCommandLine(std::vector< std::string > &args, const std::string &strCommand)
Split shell command line into a list of arguments.
Definition: rpcconsole.cpp:90
QTextEdit * messagesWidget
Definition: ui_rpcconsole.h:72
QLabel * peerBanScore
int getNumConnections(unsigned int flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
Definition: clientmodel.cpp:51
void scrollToEnd()
Scroll console view to end.
Definition: rpcconsole.cpp:493
QLabel * peerDirection
json_spirit::Value execute(const std::string &method, const json_spirit::Array &params) const
Execute a method.
Definition: rpcserver.cpp:852
std::string cleanSubVer
Definition: net.h:169
QLabel * peerHeading
int64_t nTimeConnected
Definition: net.h:166
QString HtmlEscape(const QString &str, bool fMultiLine)
Definition: guiutil.cpp:228
QWidget * detailWidget
QLabel * peerVersion
const struct @5 ICON_MAPPING[]
int nSyncHeight
Definition: main.h:208
QLabel * startupTime
Definition: ui_rpcconsole.h:55
QString formatClientStartupTime() const
PeerTableModel * getPeerTableModel()
CNodeStats nodeStats
void setupUi(QDialog *RPCConsole)
void on_tabWidget_currentChanged(int index)
Definition: rpcconsole.cpp:480
QLabel * peerHeight
void updateNodeDetail(const CNodeCombinedStats *stats)
show detailed information on ui about selected node
Definition: rpcconsole.cpp:612
QLabel * peerConnTime
void saveWindowGeometry(const QString &strSetting, QWidget *parent)
Save window size and position.
Definition: guiutil.cpp:738
QPushButton * btnClearTrafficGraph
Definition: ui_rpcconsole.h:84
void setClientModel(ClientModel *model)
Definition: rpcconsole.cpp:292
void resizeEvent(QResizeEvent *event)
Definition: rpcconsole.cpp:653
QLabel * peerSubversion
const char * url
Definition: rpcconsole.cpp:51
void reply(int category, const QString &command)
QLabel * peerLastSend
QLabel * numberOfBlocks
Definition: ui_rpcconsole.h:63
int nVersion
Definition: net.h:168
const char * source
Definition: rpcconsole.cpp:52
void browseHistory(int offset)
Go forward or back in history.
Definition: rpcconsole.cpp:443
const QSize ICON_SIZE(24, 24)
QString formatDurationStr(int secs)
Definition: guiutil.cpp:790
const int CONSOLE_HISTORY
Definition: rpcconsole.cpp:45
QDateTime getLastBlockDate() const
Definition: clientmodel.cpp:87
QPushButton * clearButton
Definition: ui_rpcconsole.h:76
QLabel * lblBytesOut
Definition: ui_rpcconsole.h:95
QLineEdit * lineEdit
Definition: ui_rpcconsole.h:75
QLabel * lastBlockTime
Definition: ui_rpcconsole.h:65
void request(const QString &command)
Definition: rpcconsole.cpp:160
QLabel * peerSyncHeight
QString clientName() const
bool fInbound
Definition: net.h:170
uint64_t nRecvBytes
Definition: net.h:173
int historyPtr
Definition: rpcconsole.h:99
void peerLayoutChanged()
Handle updated peer information.
Definition: rpcconsole.cpp:552
double dPingTime
Definition: net.h:175
std::string addrName
Definition: net.h:167
const CNodeCombinedStats * getNodeStats(int idx)
QLabel * openSSLVersion
Definition: ui_rpcconsole.h:49
QString formatBuildDate() const
uint64_t nSendBytes
Definition: net.h:172
void on_openDebugLogfileButton_clicked()
open the debug.log from the current datadir
Definition: rpcconsole.cpp:488
const CRPCTable tableRPC
Definition: rpcserver.cpp:908
void restoreWindowGeometry(const QString &strSetting, const QSize &defaultSize, QWidget *parent)
Restore window size and position.
Definition: guiutil.cpp:745
Model for Anoncoin network client.
Definition: clientmodel.h:45
int64_t GetTime()
Definition: util.cpp:1220
QLabel * label_berkeleyDBVersion
Definition: ui_rpcconsole.h:50
QLabel * peerBytesRecv
void hideEvent(QHideEvent *event)
Definition: rpcconsole.cpp:669
ClientModel * clientModel
Definition: rpcconsole.h:97
TrafficGraphWidget * trafficGraph
Definition: ui_rpcconsole.h:80
QString formatPingTime(double dPingTime)
Definition: guiutil.cpp:836
virtual bool eventFilter(QObject *obj, QEvent *event)
Definition: rpcconsole.cpp:256
QLabel * buildDate
Definition: ui_rpcconsole.h:53
void setTrafficGraphRange(int mins)
Definition: rpcconsole.cpp:518
int getNumBlocks() const
Definition: clientmodel.cpp:65
QLabel * peerBytesSent
QLabel * lblBytesIn
Definition: ui_rpcconsole.h:91
quint64 getTotalBytesSent() const
Definition: clientmodel.cpp:82
RPCConsole(QWidget *parent)
Definition: rpcconsole.cpp:208
void updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut)
update traffic statistics
Definition: rpcconsole.cpp:534
void setNumConnections(int count)
Set number of connections shown in the UI.
Definition: rpcconsole.cpp:401
void startExecutor()
Definition: rpcconsole.cpp:456
const CChainParams & Params()
Return the currently selected parameters.
QString formatServicesStr(quint64 mask)
Definition: guiutil.cpp:810
std::string addrLocal
Definition: net.h:177
void on_sldGraphRange_valueChanged(int value)
change the time range of the network traffic graph
Definition: rpcconsole.cpp:499
void clear()
Definition: rpcconsole.cpp:345
QWidget * tab_console
Definition: ui_rpcconsole.h:70
const int INITIAL_TRAFFIC_GRAPH_MINS
Definition: rpcconsole.cpp:48
uint64_t nServices
Definition: net.h:163
void setGraphRangeMins(int mins)
void peerSelected(const QItemSelection &selected, const QItemSelection &deselected)
Handle selection of peer in peers list.
Definition: rpcconsole.cpp:540
QLabel * clientName
Definition: ui_rpcconsole.h:45
QTabWidget * tabWidget
Definition: ui_rpcconsole.h:40
Ui::RPCConsole * ui
Definition: rpcconsole.h:96
void stopExecutor()
void setNumBlocks(int count)
Set number of blocks shown in the UI.
Definition: rpcconsole.cpp:413
QString formatFullVersion() const
void cmdRequest(const QString &command)
Array RPCConvertValues(const std::string &strMethod, const std::vector< std::string > &strParams)
Definition: rpcclient.cpp:194
int64_t nLastSend
Definition: net.h:164
NodeId nodeid
Definition: net.h:162
void setClientModel(ClientModel *model)
int64_t nLastRecv
Definition: net.h:165