Browse Source

changed free transactions per block threshold

git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@157 1a98c847-1fd6-4fd8-948a-caf3550aa51b
0.8
s_nakamoto 14 years ago
parent
commit
8d13ca1f11
  1. 4
      main.cpp
  2. 33
      main.h
  3. 2
      serialize.h

4
main.cpp

@ -2929,7 +2929,7 @@ void BitcoinMiner()
CTxDB txdb("r"); CTxDB txdb("r");
map<uint256, CTxIndex> mapTestPool; map<uint256, CTxIndex> mapTestPool;
vector<char> vfAlreadyAdded(mapTransactions.size()); vector<char> vfAlreadyAdded(mapTransactions.size());
uint64 nBlockSize = 10000; uint64 nBlockSize = 1000;
int nBlockSigOps = 100; int nBlockSigOps = 100;
bool fFoundSomething = true; bool fFoundSomething = true;
while (fFoundSomething) while (fFoundSomething)
@ -2944,7 +2944,7 @@ void BitcoinMiner()
if (tx.IsCoinBase() || !tx.IsFinal()) if (tx.IsCoinBase() || !tx.IsFinal())
continue; continue;
unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK); unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK);
if (nBlockSize + nTxSize >= MAX_BLOCK_SIZE) if (nBlockSize + nTxSize >= MAX_BLOCK_SIZE_GEN)
continue; continue;
int nTxSigOps = tx.GetSigOpCount(); int nTxSigOps = tx.GetSigOpCount();
if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS) if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS)

33
main.h

@ -565,15 +565,16 @@ public:
{ {
// Base fee is 1 cent per kilobyte // Base fee is 1 cent per kilobyte
unsigned int nBytes = ::GetSerializeSize(*this, SER_NETWORK); unsigned int nBytes = ::GetSerializeSize(*this, SER_NETWORK);
unsigned int nNewBlockSize = nBlockSize + nBytes;
int64 nMinFee = (1 + (int64)nBytes / 1000) * CENT; int64 nMinFee = (1 + (int64)nBytes / 1000) * CENT;
// Transactions under 60K are free as long as block size is under 80K // Transactions under 25K are free as long as block size is under 40K
// (about 27,000bc if made of 50bc inputs) // (about 11,000bc if made of 50bc inputs)
if (nBytes < 60000 && nBlockSize < 80000) if (nBytes < 25000 && nNewBlockSize < 40000)
nMinFee = 0; nMinFee = 0;
// Transactions under 3K are free as long as block size is under 200K // Transactions under 3K are free as long as block size is under 50K
if (nBytes < 3000 && nBlockSize < 200000) if (nBytes < 3000 && nNewBlockSize < 50000)
nMinFee = 0; nMinFee = 0;
// To limit dust spam, require a 0.01 fee if any output is less than 0.01 // To limit dust spam, require a 0.01 fee if any output is less than 0.01
@ -583,11 +584,15 @@ public:
nMinFee = CENT; nMinFee = CENT;
// Raise the price as the block approaches full // Raise the price as the block approaches full
if (MAX_BLOCK_SIZE/2 <= nBlockSize && nBlockSize < MAX_BLOCK_SIZE) if (nBlockSize != 1 && nNewBlockSize >= MAX_BLOCK_SIZE_GEN/2)
nMinFee *= MAX_BLOCK_SIZE / (MAX_BLOCK_SIZE - nBlockSize); {
if (nNewBlockSize >= MAX_BLOCK_SIZE_GEN)
return MAX_MONEY;
nMinFee *= MAX_BLOCK_SIZE_GEN / (MAX_BLOCK_SIZE_GEN - nNewBlockSize);
}
if (!MoneyRange(nMinFee)) if (!MoneyRange(nMinFee))
nMinFee = MAX_MONEY; nMinFee = MAX_MONEY;
return nMinFee; return nMinFee;
} }
@ -1186,9 +1191,11 @@ public:
CBigNum GetBlockWork() const CBigNum GetBlockWork() const
{ {
if (CBigNum().SetCompact(nBits) <= 0) CBigNum bnTarget;
bnTarget.SetCompact(nBits);
if (bnTarget <= 0)
return 0; return 0;
return (CBigNum(1)<<256) / (CBigNum().SetCompact(nBits)+1); return (CBigNum(1)<<256) / (bnTarget+1);
} }
bool IsInMainChain() const bool IsInMainChain() const
@ -1470,10 +1477,10 @@ public:
//// todo: add something to note what created it (user, getnewaddress, change) //// todo: add something to note what created it (user, getnewaddress, change)
//// maybe should have a map<string, string> property map //// maybe should have a map<string, string> property map
CWalletKey(int64 nTimeExpiresIn=0) CWalletKey(int64 nExpires=0)
{ {
nTimeCreated = (nTimeExpiresIn ? GetTime() : 0); nTimeCreated = (nExpires ? GetTime() : 0);
nTimeExpires = nTimeExpiresIn; nTimeExpires = nExpires;
} }
IMPLEMENT_SERIALIZE IMPLEMENT_SERIALIZE

2
serialize.h

@ -23,7 +23,7 @@ class CAutoFile;
static const unsigned int MAX_SIZE = 0x02000000; static const unsigned int MAX_SIZE = 0x02000000;
static const int VERSION = 312; static const int VERSION = 312;
static const char* pszSubVer = ".7"; static const char* pszSubVer = ".8";

Loading…
Cancel
Save