Backporting fixes for CMasternodeMan::CheckAndRemove and smartfee (+test)

Closes #738
This commit is contained in:
UdjinM6 2016-03-16 06:04:32 +03:00 committed by Holger Schinzel
parent fbd43191b2
commit 6cfe5bfe2b
4 changed files with 16 additions and 15 deletions

View File

@ -40,7 +40,7 @@ class EstimateFeeTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
# Prime the memory pool with pairs of transactions # Prime the memory pool with pairs of transactions
# (high-priority, random fee and zero-priority, random fee) # (high-priority, random fee and zero-priority, random fee)
min_fee = Decimal("0.001") min_fee = Decimal("0.00010000")
fees_per_kb = []; fees_per_kb = [];
for i in range(12): for i in range(12):
(txid, txhex, fee) = random_zeropri_transaction(self.nodes, Decimal("1.1"), (txid, txhex, fee) = random_zeropri_transaction(self.nodes, Decimal("1.1"),
@ -58,7 +58,7 @@ class EstimateFeeTest(BitcoinTestFramework):
print("Fee estimates, super-stingy miner: "+str([str(e) for e in all_estimates])) print("Fee estimates, super-stingy miner: "+str([str(e) for e in all_estimates]))
# Estimates should be within the bounds of what transactions fees actually were: # Estimates should be within the bounds of what transactions fees actually were:
delta = 1.0e-6 # account for rounding error delta = 1.0e-5 # account for rounding error
for e in filter(lambda x: x >= 0, all_estimates): for e in filter(lambda x: x >= 0, all_estimates):
if float(e)+delta < min(fees_per_kb) or float(e)-delta > max(fees_per_kb): if float(e)+delta < min(fees_per_kb) or float(e)-delta > max(fees_per_kb):
raise AssertionError("Estimated fee (%f) out of range (%f,%f)"%(float(e), min_fee_kb, max_fee_kb)) raise AssertionError("Estimated fee (%f) out of range (%f,%f)"%(float(e), min_fee_kb, max_fee_kb))

View File

@ -1539,7 +1539,7 @@ int64_t GetBlockValue(int nBits, int nHeight, const CAmount& nFees)
double dDiff = (double)0x0000ffff / (double)(nBits & 0x00ffffff); double dDiff = (double)0x0000ffff / (double)(nBits & 0x00ffffff);
/* fixed bug caused diff to not be correctly calculated */ /* fixed bug caused diff to not be correctly calculated */
if(nHeight > 4500 || Params().NetworkID() == CBaseChainParams::TESTNET) dDiff = ConvertBitsToDouble(nBits); if(nHeight > 4500 || Params().NetworkID() != CBaseChainParams::MAIN) dDiff = ConvertBitsToDouble(nBits);
int64_t nSubsidy = 0; int64_t nSubsidy = 0;
if(nHeight >= 5465) { if(nHeight >= 5465) {

View File

@ -324,17 +324,18 @@ void CMasternodeMan::CheckAndRemove(bool forceExpiredRemoval)
} }
} }
// remove expired mapSeenMasternodeBroadcast // remove expired mapSeenMasternodeBroadcast
map<uint256, CMasternodeBroadcast>::iterator it3 = mapSeenMasternodeBroadcast.begin(); map<uint256, CMasternodeBroadcast>::iterator it3 = mapSeenMasternodeBroadcast.begin();
while(it3 != mapSeenMasternodeBroadcast.end()){ while(it3 != mapSeenMasternodeBroadcast.end()){
if((*it3).second.lastPing.sigTime < GetTime()-(MASTERNODE_REMOVAL_SECONDS*2)){ if((*it3).second.lastPing.sigTime < GetTime() - MASTERNODE_REMOVAL_SECONDS*2){
mapSeenMasternodeBroadcast.erase(it3++); LogPrint("masternode", "CMasternodeMan::CheckAndRemove - Removing expired Masternode broadcast %s\n", (*it3).second.GetHash().ToString());
masternodeSync.mapSeenSyncMNB.erase((*it3).second.GetHash()); masternodeSync.mapSeenSyncMNB.erase((*it3).second.GetHash());
} else { mapSeenMasternodeBroadcast.erase(it3++);
++it3; } else {
} ++it3;
} }
}
// remove expired mapSeenMasternodePing // remove expired mapSeenMasternodePing
map<uint256, CMasternodePing>::iterator it4 = mapSeenMasternodePing.begin(); map<uint256, CMasternodePing>::iterator it4 = mapSeenMasternodePing.begin();
while(it4 != mapSeenMasternodePing.end()){ while(it4 != mapSeenMasternodePing.end()){

View File

@ -17,7 +17,7 @@ class CAutoFile;
inline double AllowFreeThreshold() inline double AllowFreeThreshold()
{ {
return COIN * 576 / 250; return COIN * 144 / 250;
} }
inline bool AllowFree(double dPriority) inline bool AllowFree(double dPriority)