Permalink
Browse files

Block Browser Final Update

More code cleanup, close button added, remove un needed includes
  • Loading branch information...
Tranz5 committed Sep 5, 2014
1 parent cf2f423 commit c2153fdca9ce2e22c67ebdeee96647fd78d92ff6
Showing with 33 additions and 60 deletions.
  1. +6 −33 src/qt/blockbrowser.cpp
  2. +14 −27 src/qt/blockbrowser.h
  3. +13 −0 src/qt/forms/blockbrowser.ui
@@ -1,22 +1,16 @@
#include "blockbrowser.h"
#include "ui_blockbrowser.h"
#include "main.h"
#include "wallet.h"
#include "base58.h"
#include "clientmodel.h"
#include "transactionrecord.h"
#include "txdb.h"
#include <sstream>
#include <string>
double GetPoSKernelPS(const CBlockIndex* blockindex);
double GetDifficulty(const CBlockIndex* blockindex);
double GetPoWMHashPS(const CBlockIndex* blockindex);
using namespace std;
const CBlockIndex* getBlockIndex(int64 height)
{
std::string hex = getBlockHash(height);
@@ -91,29 +85,6 @@ int64 getBlockNonce(int64 Height)
return pblockindex->nNonce;
}
int64 blocksInPastHours(int64 hours)
{
int64 wayback = hours * 3600;
bool check = true;
int64 height = pindexBest->nHeight;
int64 heightHour = pindexBest->nHeight;
int64 utime = (int64)time(NULL);
int64 target = utime - wayback;
while(check)
{
if(getBlockTime(heightHour) < target)
{
check = false;
return height - heightHour;
} else {
heightHour = heightHour - 1;
}
}
return 0;
}
double getTxTotalValue(std::string txid)
{
uint256 hash;
@@ -257,6 +228,7 @@ BlockBrowser::BlockBrowser(QWidget *parent) :
connect(ui->blockButton, SIGNAL(pressed()), this, SLOT(blockClicked()));
connect(ui->txButton, SIGNAL(pressed()), this, SLOT(txClicked()));
connect(ui->closeButton, SIGNAL(pressed()), this, SLOT(close()));
}
void BlockBrowser::updateExplorer(bool block)
@@ -280,16 +252,17 @@ void BlockBrowser::updateExplorer(bool block)
ui->timeBox->setText(QString::fromUtf8(DateTimeStrFormat(getBlockTime(height)).c_str()));
ui->diffBox->setText(QString::number(GetDifficulty(pindex), 'f', 6));
if (pindex->IsProofOfStake()) {
ui->hashRateLabel->setText("Block Network Stake Weight");
ui->hashRateLabel->setText("Block Network Stake Weight:");
ui->diffLabel->setText("PoS Block Difficulty:");
ui->hashRateBox->setText(QString::number(GetPoSKernelPS(pindex), 'f', 3) + " ");
}
else {
ui->hashRateLabel->setText("Block Hash Rate");
ui->hashRateLabel->setText("Block Hash Rate:");
ui->diffLabel->setText("PoW Block Difficulty:");
ui->hashRateBox->setText(QString::number(GetPoWMHashPS(pindex), 'f', 3) + " MH/s");
}
}
if(block == false) {
else {
std::string txid = ui->txBox->text().toUtf8().constData();
ui->valueBox->setText(QString::number(getTxTotalValue(txid), 'f', 6) + " HBN");
@@ -3,34 +3,8 @@
#include "clientmodel.h"
#include "main.h"
#include "wallet.h"
#include "base58.h"
#include <QDialog>
#include <QDir>
#include <QFile>
#include <QProcess>
#include <QTime>
#include <QTimer>
#include <QStringList>
#include <QMap>
#include <QSettings>
#include <QSlider>
double getTxTotalValue(std::string);
double convertCoins(int64);
int64 getBlockTime(int64);
int64 getBlocknBits(int64);
int64 getBlockNonce(int64);
int64 blocksInPastHours(int64);
int64 getBlockHashrate(int64);
std::string getInputs(std::string);
std::string getOutputs(std::string);
std::string getBlockHash(int64);
std::string getBlockMerkle(int64);
bool addnode(std::string);
const CBlockIndex* getBlockIndex(int64);
#include <QDialog>
namespace Ui {
class BlockBrowser;
@@ -65,4 +39,17 @@ private slots:
};
double getTxTotalValue(std::string);
double convertCoins(int64);
int64 getBlockTime(int64);
int64 getBlocknBits(int64);
int64 getBlockNonce(int64);
int64 getBlockHashrate(int64);
std::string getInputs(std::string);
std::string getOutputs(std::string);
std::string getBlockHash(int64);
std::string getBlockMerkle(int64);
bool addnode(std::string);
const CBlockIndex* getBlockIndex(int64);
#endif // BLOCKBROWSER_H
@@ -440,6 +440,19 @@
</item>
</layout>
</widget>
<widget class="QPushButton" name="closeButton">
<property name="geometry">
<rect>
<x>0</x>
<y>450</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Close</string>
</property>
</widget>
</widget>
</item>
</layout>

0 comments on commit c2153fd

Please sign in to comment.