Beispiel #1
0
void BidPage::GetBids()
{
    // get current blockheight and calc next superblock
    // get current time and calc period

    long int startdate = 1450396800; // 18 December 2015 00:00
    long int current = GetTime();
    long int diff = current - startdate;

    int until = 86400 - (diff % 86400);
    ui->labelNumber->setText(GUIUtil::formatDurationStr(until));

    // get default datadir, tack on bidtracker
    QString dataDir = getDefaultDataDirectory();
    QString bidDir = "bidtracker";
    QString datPath = pathAppend(dataDir, bidDir);

    // get bids from /bidtracker/final.dat
    QString bidspath = QDir(datPath).filePath("prefinal.dat");
    double btctot = 0;
    // for each line in file, get the float after the comma
    QFile bidsFile(bidspath);
    if (bidsFile.open(QIODevice::ReadOnly))
    {
       QTextStream btcin(&bidsFile);
       while (!btcin.atEnd())
       {
           QString line = btcin.readLine();
           if (line.isEmpty()){ continue; }
           else if (line.startsWith("1"))  //  BTC
           {
               QString btcamount = line.remove(0, 35);
               btctot = btctot + btcamount.toDouble();
           }
       else //  we should never get here
           {
               QMessageBox::information(0, QString("Oops!"), QString("There is a problem with the file, please try again later!"), QMessageBox::Ok);
           }
       }
       bidsFile.close();
    }

    // btctot, ltctot and dashtot are in satoshis, so divide by 10000000 to get right units
    // to do - add radiobuttons or dropdown to select sats or not?
    double btctotU = btctot / 100000000;
    QString btctotal = QString::number(btctotU, 'f', 8);
    ui->labelBTC_2->setText(btctotal);

    // add 'em up and display 'em
    double alltot = btctotU;
    QString alltotal = QString::number(alltot, 'f', 8);
    ui->labelTotal_2->setText(alltotal);

    // calc price per BCR based on total bids and display it
    double bcrprice = alltot / 31500;
    QString bcrPrice = QString::number(bcrprice, 'f', 8);
    ui->labelEstprice_2->setText(bcrPrice);

    ui->lineEditBid->setEnabled(true);
}
Beispiel #2
0
void TestPage::GetBids()
{
    // get current blockheight and calc next superblock
    int base = 200700;
    int current = TestPage::getNumBlocks();
    int diff = current - base;

    int until = 900 - (diff % 900);
    QString blocks = QString::number(until);
    ui->labelNumber->setText(blocks);

    // get default datadir, tack on bidtracker
    QString dataDir = getDefaultDataDirectory();
    QString bidDir = "bidtracker";
    QString datPath = pathAppend(dataDir, bidDir);

    // get bids from /bidtracker/final.dat
    QString bidspath = QDir(datPath).filePath("final.dat");
    double btctot = 0;
    double ltctot = 0;
    double dashtot = 0;
    // for each line in file, get the float after the comma
    QFile bidsFile(bidspath);
    if (bidsFile.open(QIODevice::ReadOnly))
    {
       QTextStream btcin(&bidsFile);
       while (!btcin.atEnd())
       {
           QString line = btcin.readLine();
           if (line.startsWith("1"))  //  BTC
           {
               QString btcamount = line.remove(0, 35);
               btctot = btctot + btcamount.toDouble();
           }
           else if (line.startsWith("L"))  //  LTC
           {
               QString ltcamount = line.remove(0, 35);
               ltctot = ltctot + ltcamount.toDouble();
           }
           else if (line.startsWith("X"))  //  DASH
           {
               QString dashamount = line.remove(0, 35);
               dashtot = dashtot + dashamount.toDouble();
           }
	   else //  we should never get here
           {
               QMessageBox::information(0, QString("Oops!"), QString("There is a problem with the file, please try again later!"), QMessageBox::Ok);
           }
       }
       bidsFile.close();
    }

    // btctot, ltctot and dashtot are in satoshis, so divide by 10000000 to get right units
    // to do - add radiobuttons or dropdown to select sats or not?
    double btctotU = btctot / 100000000;
    double ltctotU = ltctot / 100000000;
    double dashtotU = dashtot / 100000000;
    QString btctotal = QString::number(btctotU, 'f', 8);
    QString ltctotal = QString::number(ltctotU, 'f', 8);
    QString dashtotal = QString::number(dashtotU, 'f', 8);
    ui->labelBTC_2->setText(btctotal);
    ui->labelLTC_2->setText(ltctotal);
    ui->labelDASH_2->setText(dashtotal);

    // add 'em up and display 'em
    double alltot = btctotU + ltctotU + dashtotU;
    QString alltotal = QString::number(alltot, 'f', 8);
    ui->labelTotal_2->setText(alltotal);

    // calc price per BCR based on total bids and display it
    double bcrprice = alltot / 30000;
    QString bcrPrice = QString::number(bcrprice, 'f', 8);
    ui->labelEstprice_2->setText(bcrPrice);     

    ui->lineEditBid->setEnabled(true);
}