/* input output network test */ void ioNetwork() { int m0,m,step,iter; FILE *in, *out; time_t time_begin,time_end; struct network * target=NULL; struct network * newNet=NULL; time(&time_begin); out=fopen("net.txt","w"); step=5; m0=m=2; iter=1; m=m; m0=m0; target=NULL; newNet=NULL; target=(struct network *)mem_alloc(sizeof(struct network)); baModel_o(target, m0, m, step); printf(" the original network: \n"); showNetwork(target); outputNetwork(target, out); fclose(out); in=fopen("net.txt","r"); inputNetwork(&newNet, in); fclose(in); printf(" the read-in network: \n"); showNetwork(newNet); time(&time_end); printf("\n exhausted time: %ld \n",time_end-time_begin); }
/* 061226: construct weighted td model */ void td_test1() { int m0, m, steps; double w0,W; struct network *target; m0=3; m=2; w0=1.0; W=0.2; steps=10; target=(struct network *)mem_alloc(sizeof(struct network)); tdModel( target, m0, w0, W, m, steps); showNetwork(target); mem_free(target); }
/* 061225: construct weighted BBV model */ void bbv_test1() { int m0, m, steps; double w0,delta; struct network *target; m0=3; m=2; w0=1.0; delta=0.2; steps=10; target=(struct network *)mem_alloc(sizeof(struct network)); bbvModel( target, m0,w0,m,delta, steps); showNetwork(target); mem_free(target); }
/* oba test: get node load */ void oba_load() { int i, m0,m,step,iter; FILE* pFile_nb; FILE* pFile_lb; struct network * target; double maxNB,maxLB; int id; step=5000; m0=m=2; iter=1; pFile_nb =NULL; pFile_lb =NULL; target=NULL; m=m; m0=m0; pFile_nb=fopen("nb.txt","w"); pFile_lb=fopen("lb.txt","w"); for(i=1;i<=iter;i++) { target=(struct network *)mem_alloc(sizeof(struct network)); baModel_o(target, m0, m, step); showNetwork(target); getNodeLinkLoad(target,NULL, &maxNB, &id, &maxLB,pFile_nb,pFile_lb); } fclose(pFile_nb); fclose(pFile_lb); }
void loadTest() { int step; time_t time_begin,time_end; FILE * pFile_lck; struct network * target=NULL; struct connectedNetInfo * pro=NULL; // double maxNB,maxLB; int m, m0; time(&time_begin); m=2; m0=2; step=10; target=NULL; pro=NULL; target=(struct network *)mem_alloc(sizeof(struct network)); baModel_o(target, m0, m, step); getConnectedNetInfo(target, &pro); showNetwork(target); pFile_lck = fopen("lck.txt","w"); outputConnectedNetInfo(pro, pFile_lck); // getNodeLinkLoad(target,&maxNB,&maxLB,NULL,NULL); time(&time_end); printf("\n exhausted time: %ld \n",time_end-time_begin); fclose(pFile_lck); freeNetwork(target); mem_free(pro); }
BitcoinGUI::BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent) : QMainWindow(parent), clientModel(0), walletFrame(0), unitDisplayControl(0), labelEncryptionIcon(0), labelConnectionsIcon(0), labelBlocksIcon(0), progressBarLabel(0), progressBar(0), progressDialog(0), appMenuBar(0), overviewAction(0), historyAction(0), quitAction(0), sendCoinsAction(0), usedSendingAddressesAction(0), usedReceivingAddressesAction(0), signMessageAction(0), verifyMessageAction(0), aboutAction(0), receiveCoinsAction(0), optionsAction(0), toggleHideAction(0), encryptWalletAction(0), backupWalletAction(0), changePassphraseAction(0), aboutQtAction(0), openRPCConsoleAction(0), openAction(0), showHelpMessageAction(0), trayIcon(0), trayIconMenu(0), notificator(0), rpcConsole(0), prevBlocks(0), spinnerFrame(0) { /* Open CSS when configured */ this->setStyleSheet(GUIUtil::loadStyleSheet()); GUIUtil::restoreWindowGeometry("nWindow", QSize(850, 550), this); QString windowTitle = tr("DarkNet Core") + " - "; #ifdef ENABLE_WALLET /* if compiled with wallet support, -disablewallet can still disable the wallet */ enableWallet = !GetBoolArg("-disablewallet", false); #else enableWallet = false; #endif // ENABLE_WALLET if(enableWallet) { windowTitle += tr("Wallet"); } else { windowTitle += tr("Node"); } QString userWindowTitle = QString::fromStdString(GetArg("-windowtitle", "")); if(!userWindowTitle.isEmpty()) windowTitle += " - " + userWindowTitle; windowTitle += " " + networkStyle->getTitleAddText(); #ifndef Q_OS_MAC QApplication::setWindowIcon(networkStyle->getAppIcon()); setWindowIcon(networkStyle->getAppIcon()); #else MacDockIconHandler::instance()->setIcon(networkStyle->getAppIcon()); #endif setWindowTitle(windowTitle); #if defined(Q_OS_MAC) && QT_VERSION < 0x050000 // This property is not implemented in Qt 5. Setting it has no effect. // A replacement API (QtMacUnifiedToolBar) is available in QtMacExtras. setUnifiedTitleAndToolBarOnMac(true); #endif rpcConsole = new RPCConsole(enableWallet ? this : 0); #ifdef ENABLE_WALLET if(enableWallet) { /** Create wallet frame*/ walletFrame = new WalletFrame(this); } else #endif // ENABLE_WALLET { /* When compiled without wallet or -disablewallet is provided, * the central widget is the rpc console. */ setCentralWidget(rpcConsole); } // Accept D&D of URIs setAcceptDrops(true); // Create actions for the toolbar, menu bar and tray/dock icon // Needs walletFrame to be initialized createActions(networkStyle); // Create application menu bar createMenuBar(); // Create the toolbars createToolBars(); // Create system tray icon and notification createTrayIcon(networkStyle); // Create status bar statusBar(); // Status bar notification icons QFrame *frameBlocks = new QFrame(); frameBlocks->setContentsMargins(0,0,0,0); frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks); frameBlocksLayout->setContentsMargins(3,0,3,0); frameBlocksLayout->setSpacing(3); unitDisplayControl = new UnitDisplayStatusBarControl(); labelEncryptionIcon = new QLabel(); labelConnectionsIcon = new QPushButton(); labelConnectionsIcon->setFlat(true); // Make the button look like a label, but clickable labelConnectionsIcon->setStyleSheet(".QPushButton { background-color: rgba(255, 255, 255, 0);}"); labelConnectionsIcon->setMaximumSize(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE); labelBlocksIcon = new QLabel(); if(enableWallet) { frameBlocksLayout->addStretch(); frameBlocksLayout->addWidget(unitDisplayControl); frameBlocksLayout->addStretch(); frameBlocksLayout->addWidget(labelEncryptionIcon); } frameBlocksLayout->addStretch(); frameBlocksLayout->addWidget(labelConnectionsIcon); frameBlocksLayout->addStretch(); frameBlocksLayout->addWidget(labelBlocksIcon); frameBlocksLayout->addStretch(); // Progress bar and label for blocks download progressBarLabel = new QLabel(); progressBarLabel->setVisible(true); progressBar = new GUIUtil::ProgressBar(); progressBar->setAlignment(Qt::AlignCenter); progressBar->setVisible(true); // Override style sheet for progress bar for styles that have a segmented progress bar, // as they make the text unreadable (workaround for issue #1071) // See https://qt-project.org/doc/qt-4.8/gallery.html QString curStyle = QApplication::style()->metaObject()->className(); if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle") { progressBar->setStyleSheet("QProgressBar { background-color: #F8F8F8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #00CCFF, stop: 1 #33CCFF); border-radius: 7px; margin: 0px; }"); } statusBar()->addWidget(progressBarLabel); statusBar()->addWidget(progressBar); statusBar()->addPermanentWidget(frameBlocks); // Jump directly to tabs in RPC-console connect(openInfoAction, SIGNAL(triggered()), rpcConsole, SLOT(showInfo())); connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(showConsole())); connect(openNetworkAction, SIGNAL(triggered()), rpcConsole, SLOT(showNetwork())); connect(openPeersAction, SIGNAL(triggered()), rpcConsole, SLOT(showPeers())); connect(openRepairAction, SIGNAL(triggered()), rpcConsole, SLOT(showRepair())); connect(openConfEditorAction, SIGNAL(triggered()), rpcConsole, SLOT(showConfEditor())); connect(showBackupsAction, SIGNAL(triggered()), rpcConsole, SLOT(showBackups())); connect(labelConnectionsIcon, SIGNAL(clicked()), rpcConsole, SLOT(showPeers())); // Get restart command-line parameters and handle restart connect(rpcConsole, SIGNAL(handleRestart(QStringList)), this, SLOT(handleRestart(QStringList))); // prevents an open debug window from becoming stuck/unusable on client shutdown connect(quitAction, SIGNAL(triggered()), rpcConsole, SLOT(hide())); // Install event filter to be able to catch status tip events (QEvent::StatusTip) this->installEventFilter(this); // Initially wallet actions should be disabled setWalletActionsEnabled(false); // Subscribe to notifications from core subscribeToCoreSignals(); }
// for software network test void ERTest() { int i; int nodeNum; time_t time_begin,time_end; FILE * pFile_lck; FILE * pFile_node; FILE * pFile_link; FILE * pFile_net; struct network * target; struct netInfo * netinfo; struct CLSTS * clsts; double p; target=NULL; netinfo=NULL; clsts=NULL; pFile_lck = fopen("er_lck.txt","a"); pFile_node=fopen("er_node.txt", "w"); pFile_link=fopen("er_link.txt", "w"); pFile_net=fopen("er_net.txt", "w"); /* nodeNum = 2999; linkNum = 97676; par.p=(double)(65.8/(double)nodeNum/(double)2); */ nodeNum = 10; p=0.3; time(&time_begin); i=0; while(1) { if(i==1) { break; } printf(" i = %d .............................. \n", i); target=(struct network *)mem_alloc(sizeof(struct network)); erModel(target, nodeNum, p); showNetwork(target); outputNetwork(target, pFile_net); // getNetwork Info netinfo=(struct netInfo*)mem_alloc(sizeof(struct netInfo)); initNetInfo(netinfo, target); getBasicNetInfo(target, netinfo); // ouput the basic info outputNodeInfo(netinfo, pFile_node); outputLinkInfo(netinfo, pFile_link); clsts=NULL; getCLSTS(target,&clsts); getClstNetInfo(target, clsts, netinfo); // statis info /* av_k = netinfo->av_k ; max_k = netinfo->max_k; av_coef = netinfo->av_coef; e_loc = netinfo->e_loc; S_size = netinfo->S_size; av_s = netinfo->av_s; S_avspl = netinfo->S_avspl; S_maxspl = netinfo->S_maxspl; e_glob_active = netinfo->e_glob_active; S_e_glob = netinfo->S_e_glob; */ printf(" %.5f %d %.5f %.5f %d %.5f %.5f %d %.5f %.5f \n", netinfo->av_k, netinfo->max_k, netinfo->av_coef, netinfo->e_loc, netinfo->S_size, netinfo->av_s, netinfo->S_avspl, netinfo->S_maxspl, netinfo->e_glob_active, netinfo->S_e_glob); fprintf(pFile_lck, " %.5f %d %.5f %.5f %d %.5f %.5f %d %.5f %.5f \n", netinfo->av_k, netinfo->max_k, netinfo->av_coef, netinfo->e_loc, netinfo->S_size, netinfo->av_s, netinfo->S_avspl, netinfo->S_maxspl, netinfo->e_glob_active, netinfo->S_e_glob); i++; freeNetwork(target); freeCLSTS(clsts); freeNetInfo(netinfo); } /* av_k/=i; max_k/=i; av_coef/=i; e_loc/=i; S_size/=i; av_s/=i; S_avspl/=i; S_maxspl/=i; e_glob_active/=i; S_e_glob/=i; fprintf(pFile_lck, " %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f \n", av_k, max_k, av_coef, e_loc, S_size, av_s, S_avspl, S_maxspl, e_glob_active, S_e_glob); */ time(&time_end); printf("\n exhausted time: %ld \n",time_end-time_begin); fclose(pFile_lck); fclose (pFile_node); fclose (pFile_link); fclose (pFile_net); }
BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) : QMainWindow(parent), clientModel(0), walletFrame(0), encryptWalletAction(0), changePassphraseAction(0), aboutQtAction(0), trayIcon(0), notificator(0), rpcConsole(0), prevBlocks(0), spinnerFrame(0) { /* Open CSS when configured */ this->setStyleSheet(GUIUtil::loadStyleSheet()); GUIUtil::restoreWindowGeometry("nWindow", QSize(850, 550), this); QString windowTitle = tr("Mobicoin Core") + " - "; #ifdef ENABLE_WALLET /* if compiled with wallet support, -disablewallet can still disable the wallet */ bool enableWallet = !GetBoolArg("-disablewallet", false); #else bool enableWallet = false; #endif if(enableWallet) { windowTitle += tr("Wallet"); } else { windowTitle += tr("Node"); } if (!fIsTestnet) { #ifndef Q_OS_MAC QApplication::setWindowIcon(QIcon(":icons/bitcoin")); setWindowIcon(QIcon(":icons/bitcoin")); #else MacDockIconHandler::instance()->setIcon(QIcon(":icons/bitcoin")); #endif } else { windowTitle += " " + tr("[testnet]"); #ifndef Q_OS_MAC QApplication::setWindowIcon(QIcon(":icons/bitcoin_testnet")); setWindowIcon(QIcon(":icons/bitcoin_testnet")); #else MacDockIconHandler::instance()->setIcon(QIcon(":icons/bitcoin_testnet")); #endif } setWindowTitle(windowTitle); #if defined(Q_OS_MAC) && QT_VERSION < 0x050000 // This property is not implemented in Qt 5. Setting it has no effect. // A replacement API (QtMacUnifiedToolBar) is available in QtMacExtras. setUnifiedTitleAndToolBarOnMac(true); #endif rpcConsole = new RPCConsole(enableWallet ? this : 0); #ifdef ENABLE_WALLET if(enableWallet) { /** Create wallet frame*/ walletFrame = new WalletFrame(this); } else #endif { /* When compiled without wallet or -disablewallet is provided, * the central widget is the rpc console. */ setCentralWidget(rpcConsole); } // Accept D&D of URIs setAcceptDrops(true); // Create actions for the toolbar, menu bar and tray/dock icon // Needs walletFrame to be initialized createActions(fIsTestnet); // Create application menu bar createMenuBar(); // Create the toolbars createToolBars(); // Create system tray icon and notification createTrayIcon(fIsTestnet); // Create status bar statusBar(); // Status bar notification icons QFrame *frameBlocks = new QFrame(); frameBlocks->setContentsMargins(0,0,0,0); frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks); frameBlocksLayout->setContentsMargins(3,0,3,0); frameBlocksLayout->setSpacing(3); labelEncryptionIcon = new QLabel(); labelConnectionsIcon = new QLabel(); labelBlocksIcon = new QLabel(); frameBlocksLayout->addStretch(); frameBlocksLayout->addWidget(labelEncryptionIcon); frameBlocksLayout->addStretch(); frameBlocksLayout->addWidget(labelConnectionsIcon); frameBlocksLayout->addStretch(); frameBlocksLayout->addWidget(labelBlocksIcon); frameBlocksLayout->addStretch(); // Progress bar and label for blocks download progressBarLabel = new QLabel(); progressBarLabel->setVisible(false); progressBar = new GUIUtil::ProgressBar(); progressBar->setAlignment(Qt::AlignCenter); progressBar->setVisible(false); // Override style sheet for progress bar for styles that have a segmented progress bar, // as they make the text unreadable (workaround for issue #1071) // See https://qt-project.org/doc/qt-4.8/gallery.html QString curStyle = QApplication::style()->metaObject()->className(); if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle") { progressBar->setStyleSheet("QProgressBar { background-color: #F8F8F8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #00CCFF, stop: 1 #33CCFF); border-radius: 7px; margin: 0px; }"); } statusBar()->addWidget(progressBarLabel); statusBar()->addWidget(progressBar); statusBar()->addPermanentWidget(frameBlocks); connect(openInfoAction, SIGNAL(triggered()), rpcConsole, SLOT(showInfo())); connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(showConsole())); connect(openNetworkAction, SIGNAL(triggered()), rpcConsole, SLOT(showNetwork())); connect(openConfEditorAction, SIGNAL(triggered()), rpcConsole, SLOT(showConfEditor())); connect(showBackupsAction, SIGNAL(triggered()), rpcConsole, SLOT(showBackups())); // prevents an oben debug window from becoming stuck/unusable on client shutdown connect(quitAction, SIGNAL(triggered()), rpcConsole, SLOT(hide())); // Install event filter to be able to catch status tip events (QEvent::StatusTip) this->installEventFilter(this); // Initially wallet actions should be disabled setWalletActionsEnabled(false); // Subscribe to notifications from core subscribeToCoreSignals(); }