Skip to content

Commit

Permalink
Minor Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mkimid committed Jul 3, 2014
1 parent b22c148 commit 4e0eb23
Show file tree
Hide file tree
Showing 29 changed files with 320 additions and 122 deletions.
15 changes: 12 additions & 3 deletions src/bitcoinrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,18 @@ bool ClientAllowed(const boost::asio::ip::address& address)

const string strAddress = address.to_string();
const vector<string>& vAllow = mapMultiArgs["-rpcallowip"];
BOOST_FOREACH(string strAllow, vAllow)
if (WildcardMatch(strAddress, strAllow))
return true;

//
// minimumn 8 characters for IP address, so, * or *.*.*.* will be ignored
// need to set more detail IP address with wile card
//
BOOST_FOREACH(string strAllow, vAllow) {
if (strAllow.length() > 7) {
if (WildcardMatch(strAddress, strAllow)) {
return true;
}
}
}
return false;
}

Expand Down
8 changes: 4 additions & 4 deletions src/groestl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2813,7 +2813,7 @@ static void
groestl_small_close(sph_groestl_small_context *sc,
unsigned ub, unsigned n, void *dst, size_t out_len)
{
unsigned char *buf;
// unsigned char *buf;
unsigned char pad[72];
size_t u, ptr, pad_len;
#if SPH_64
Expand All @@ -2824,7 +2824,7 @@ groestl_small_close(sph_groestl_small_context *sc,
unsigned z;
DECL_STATE_SMALL

buf = sc->buf;
// buf = sc->buf;
ptr = sc->ptr;
z = 0x80 >> n;
pad[0] = ((ub & -z) | z) & 0xFF;
Expand Down Expand Up @@ -2949,7 +2949,7 @@ static void
groestl_big_close(sph_groestl_big_context *sc,
unsigned ub, unsigned n, void *dst, size_t out_len)
{
unsigned char *buf;
// unsigned char *buf;
unsigned char pad[136];
size_t ptr, pad_len, u;
#if SPH_64
Expand All @@ -2960,7 +2960,7 @@ groestl_big_close(sph_groestl_big_context *sc,
unsigned z;
DECL_STATE_BIG

buf = sc->buf;
// buf = sc->buf;
ptr = sc->ptr;
z = 0x80 >> n;
pad[0] = ((ub & -z) | z) & 0xFF;
Expand Down
75 changes: 43 additions & 32 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
Expand Down Expand Up @@ -87,6 +87,11 @@ static const int checkpointPoWHeight[NUM_OF_POW_CHECKPOINT][2] =
{150000, 22309}
};

//
// for Jackpot infomation
//



//////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -1025,6 +1030,7 @@ int GetPosHeight(const CBlockIndex* pindex)

static const int64 nMinSubsidy = 1 * COIN;


// miner's coin base reward based on nBits
int64 GetProofOfWorkReward(int nHeight, int64 nFees, const CBlockIndex* pindex)
{
Expand All @@ -1048,6 +1054,7 @@ int64 GetProofOfWorkReward(int nHeight, int64 nFees, const CBlockIndex* pindex)
return nSubsidy + nFees;
}

int nJackpotValue = 0;

// miner's coin base bonus block extra reward
const int POW_BLOCKS_PER_DAY = 24 * 3600 / nWorkTargetSpacing;
Expand Down Expand Up @@ -1077,40 +1084,44 @@ int64 GetProofOfWorkBlockBonusRewardFactor(CBlockIndex* pindex)

double numofdays = (double)delta / (double)POW_BLOCKS_PER_DAY;

if(numofdays > SUPER_BONUS_MAX_DAY)
{
// increase the possibility
int dd = 5 * (delta - SUPER_BONUS_MAX_DAY * POW_BLOCKS_PER_DAY);
if(dd < 0)
dd = 0;

lowerLimit -= dd;
if(lowerLimit < 0)
lowerLimit = 0;

upperLimit += dd;
if(upperLimit > 25200)
upperLimit = 25200;
}
if(numofdays > SUPER_BONUS_MAX_DAY)
{
// increase the possibility
int dd = 5 * (delta - SUPER_BONUS_MAX_DAY * POW_BLOCKS_PER_DAY);
if(dd < 0)
dd = 0;


// printf(">> height = %d, random = %d, numberofday= %f, upper = %d, lower = %d\n", pindex->nHeight, random, numofdays,
// upperLimit, lowerLimit);
// printf(">> cseed =%s\n", cseed);
lowerLimit -= dd;
if(lowerLimit < 0)
lowerLimit = 0;

if(random > lowerLimit && random < upperLimit) // 1 in 3.5 days on average
{
printf(">>> Found Jackpot!! height = %d, random = %d, numberofday= %f, upper = %d, lower = %d\n", pindex->nHeight, random, numofdays,
upperLimit, lowerLimit);
upperLimit += dd;
if(upperLimit > 25200)
upperLimit = 25200;
}

if(numofdays > SUPER_BONUS_CAP_DAY)
numofdays = SUPER_BONUS_CAP_DAY;
double dfac = 0.0;
if (numofdays > SUPER_BONUS_CAP_DAY) {
dfac = pow(10.0, (SUPER_BONUS_CAP_DAY/TARGET_AVERAGE_DAY + 1.0));
}
else {
dfac = pow(10.0, (numofdays/TARGET_AVERAGE_DAY + 1.0));
}

double dfac = pow(10.0, (numofdays/TARGET_AVERAGE_DAY + 1.0)) * 100;
return (int64)(dfac - 100);
}
int64 reward = GetProofOfWorkReward(pindex->nHeight, 0, pindex->pprev);
nJackpotValue = (int)(((double)reward * dfac) / COIN);

// printf(">> height = %d, random = %d, numberofday= %f, upper = %d, lower = %d\n", pindex->nHeight, random, numofdays,
// upperLimit, lowerLimit);
// printf(">> cseed =%s\n", cseed);

return 0;
if (random > lowerLimit && random < upperLimit) { // 1 in 3.5 days on average
printf(">>> Found Jackpot!! height = %d, random = %d, numberofday= %f, upper = %d, lower = %d\n", pindex->nHeight, random, numofdays, upperLimit, lowerLimit);
dfac = dfac * 100;
return (int64)(dfac - 100);
}

return 0;
}


Expand All @@ -1122,14 +1133,14 @@ int64 GetCurrentJackpotSize(const CBlockIndex* pindex)

int64 reward = GetProofOfWorkReward(pindex->nHeight, 0, pprev);

int height = pindex->nHeight;
int lastSuperBlock = pindex->nSuperBlock;
int delta = CountPowDelta(pprev, lastSuperBlock);
double numofdays = (double)delta / (double)POW_BLOCKS_PER_DAY;
if(numofdays > SUPER_BONUS_CAP_DAY)
numofdays = SUPER_BONUS_CAP_DAY;

double dfac = pow(10.0, (numofdays/TARGET_AVERAGE_DAY + 1.0));

return (int64)((double)reward * dfac) / COIN;
}

Expand Down Expand Up @@ -2757,7 +2768,7 @@ bool LoadBlockIndex(bool fAllowNew)
return false;

// Genesis block
const char* pszTimestamp = "April 24, 2014: The Powerball jackpot will go to one extremely lucky ticket buyer in Florida, as that ticket alone matched all six numbers from Wednesday night’s drawing, making it good for a life-changing $148.8 million top prize";
const char* pszTimestamp = "April 24, 2014: The Powerball jackpot will go to one extremely lucky ticket buyer in Florida, as that ticket alone matched all six numbers from Wednesday night뭩 drawing, making it good for a life-changing $148.8 million top prize";
CTransaction txNew;
txNew.nTime = nChainStartTime;
txNew.vin.resize(1);
Expand Down
8 changes: 3 additions & 5 deletions src/makefile.mingw
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ USE_IPV6:=0
INCLUDEPATHS= \
-I"/c/deps/boost_1_53_0" \
-I"/c/deps/db-4.8.30.NC/build_unix" \
-I"/c/deps/openssl-1.0.1g/include" \
-I"/c"
-I"/c/deps/openssl-1.0.1g/include"

LIBPATHS= \
-L"/c/deps/boost_1_53_0/stage/lib" \
-L"/c/deps/db-4.8.30.NC/build_unix" \
-L"/c/deps/openssl-1.0.1g" \
-L"/c/deps/miniupnpc"
-L"/c/deps/openssl-1.0.1g"

LIBS= \
-l boost_system-mgw48-mt-s-1_53 \
Expand All @@ -29,7 +27,7 @@ LIBS= \
DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -D__NO_SYSTEM_INCLUDES
DEBUGFLAGS=-g
CFLAGS=-mthreads -O2 -msse2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -fpermissive $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat
LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat -static

TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)

Expand Down
3 changes: 2 additions & 1 deletion src/makefile.unix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Distributed under the MIT/X11 software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

USE_UPNP:=-
USE_UPNP:=1
USE_IPV6:=1

LINK:=$(CXX)
Expand All @@ -16,6 +16,7 @@ TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)

LMODE = dynamic
LMODE2 = dynamic

ifdef STATIC
LMODE = static
ifeq (${STATIC}, all)
Expand Down
12 changes: 12 additions & 0 deletions src/qt/askpassphrasedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <QPushButton>
#include <QKeyEvent>

extern bool fWalletUnlockStakingOnly;

AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget *parent) :
QDialog(parent),
ui(new Ui::AskPassphraseDialog),
Expand All @@ -25,6 +27,9 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget *parent) :
ui->passEdit2->installEventFilter(this);
ui->passEdit3->installEventFilter(this);

// Unlock for PoS
ui->stakingCheckBox->setChecked(fWalletUnlockStakingOnly);

switch(mode)
{
case Encrypt: // Ask passphrase x2
Expand All @@ -33,6 +38,10 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget *parent) :
ui->warningLabel->setText(tr("Enter the new passphrase to the wallet.<br/>Please use a passphrase of <b>10 or more random characters</b>, or <b>eight or more words</b>."));
setWindowTitle(tr("Encrypt wallet"));
break;
case UnlockStaking:
ui->stakingCheckBox->setChecked(true);
ui->stakingCheckBox->show();
break;
case Unlock: // Ask passphrase
ui->warningLabel->setText(tr("This operation needs your wallet passphrase to unlock the wallet."));
ui->passLabel2->hide();
Expand Down Expand Up @@ -138,6 +147,7 @@ void AskPassphraseDialog::accept()
QDialog::reject(); // Cancelled
}
} break;
case UnlockStaking:
case Unlock:
if(!model->setWalletLocked(false, oldpass))
{
Expand All @@ -146,6 +156,7 @@ void AskPassphraseDialog::accept()
}
else
{
fWalletUnlockStakingOnly = ui->stakingCheckBox->isChecked();
QDialog::accept(); // Success
}
break;
Expand Down Expand Up @@ -193,6 +204,7 @@ void AskPassphraseDialog::textChanged()
case Encrypt: // New passphrase x2
acceptable = !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty();
break;
case UnlockStaking:
case Unlock: // Old passphrase x1
case Decrypt:
acceptable = !ui->passEdit1->text().isEmpty();
Expand Down
9 changes: 5 additions & 4 deletions src/qt/askpassphrasedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ class AskPassphraseDialog : public QDialog

public:
enum Mode {
Encrypt, /**< Ask passphrase twice and encrypt */
Unlock, /**< Ask passphrase and unlock */
ChangePass, /**< Ask old passphrase + new passphrase twice */
Decrypt /**< Ask passphrase and decrypt wallet */
Encrypt, /**< Ask passphrase twice and encrypt */
UnlockStaking, /**< Ask passphase to unlock for PoS only */
Unlock, /**< Ask passphrase and unlock */
ChangePass, /**< Ask old passphrase + new passphrase twice */
Decrypt /**< Ask passphrase and decrypt wallet */
};

explicit AskPassphraseDialog(Mode mode, QWidget *parent = 0);
Expand Down
32 changes: 21 additions & 11 deletions src/qt/forms/askpassphrasedialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>598</width>
<height>198</height>
<height>180</height>
</rect>
</property>
<property name="sizePolicy">
Expand All @@ -26,16 +26,6 @@
<string>Passphrase Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="warningLabel">
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
Expand Down Expand Up @@ -99,8 +89,28 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="stakingCheckBox">
<property name="accessibleDescription">
<string extracomment="Check this option if want to ulock wallet for PoS mining only"/>
</property>
<property name="text">
<string>Unlock for PoS mining only</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="warningLabel">
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
Expand Down
2 changes: 1 addition & 1 deletion src/qt/forms/coincontroldialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@
<height>41</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayoutPanel" stretch="0,0,0,0,0">
<layout class="QHBoxLayout" name="horizontalLayoutPanel" stretch="0,0,0,0">
<property name="spacing">
<number>14</number>
</property>
Expand Down
Loading

0 comments on commit 4e0eb23

Please sign in to comment.