mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 21:12:48 +01:00
Cosmetic: move CTransaction::GetMinFee out of header file
This commit is contained in:
parent
0e08efc54a
commit
76970091f1
49
src/main.cpp
49
src/main.cpp
@ -477,6 +477,55 @@ bool CTransaction::CheckTransaction() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64 CTransaction::GetMinFee(unsigned int nBlockSize, bool fAllowFree,
|
||||||
|
enum GetMinFee_mode mode) const
|
||||||
|
{
|
||||||
|
// Base fee is either MIN_TX_FEE or MIN_RELAY_TX_FEE
|
||||||
|
int64 nBaseFee = (mode == GMF_RELAY) ? MIN_RELAY_TX_FEE : MIN_TX_FEE;
|
||||||
|
|
||||||
|
unsigned int nBytes = ::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION);
|
||||||
|
unsigned int nNewBlockSize = nBlockSize + nBytes;
|
||||||
|
int64 nMinFee = (1 + (int64)nBytes / 1000) * nBaseFee;
|
||||||
|
|
||||||
|
if (fAllowFree)
|
||||||
|
{
|
||||||
|
if (nBlockSize == 1)
|
||||||
|
{
|
||||||
|
// Transactions under 10K are free
|
||||||
|
// (about 4500 BTC if made of 50 BTC inputs)
|
||||||
|
if (nBytes < 10000)
|
||||||
|
nMinFee = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Free transaction area
|
||||||
|
if (nNewBlockSize < 27000)
|
||||||
|
nMinFee = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// To limit dust spam, require MIN_TX_FEE/MIN_RELAY_TX_FEE if any output is less than 0.01
|
||||||
|
if (nMinFee < nBaseFee)
|
||||||
|
{
|
||||||
|
BOOST_FOREACH(const CTxOut& txout, vout)
|
||||||
|
if (txout.nValue < CENT)
|
||||||
|
nMinFee = nBaseFee;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Raise the price as the block approaches full
|
||||||
|
if (nBlockSize != 1 && nNewBlockSize >= MAX_BLOCK_SIZE_GEN/2)
|
||||||
|
{
|
||||||
|
if (nNewBlockSize >= MAX_BLOCK_SIZE_GEN)
|
||||||
|
return MAX_MONEY;
|
||||||
|
nMinFee *= MAX_BLOCK_SIZE_GEN / (MAX_BLOCK_SIZE_GEN - nNewBlockSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!MoneyRange(nMinFee))
|
||||||
|
nMinFee = MAX_MONEY;
|
||||||
|
return nMinFee;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CTxMemPool::accept(CTxDB& txdb, CTransaction &tx, bool fCheckInputs,
|
bool CTxMemPool::accept(CTxDB& txdb, CTransaction &tx, bool fCheckInputs,
|
||||||
bool* pfMissingInputs)
|
bool* pfMissingInputs)
|
||||||
{
|
{
|
||||||
|
48
src/main.h
48
src/main.h
@ -540,53 +540,7 @@ public:
|
|||||||
return dPriority > COIN * 144 / 250;
|
return dPriority > COIN * 144 / 250;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64 GetMinFee(unsigned int nBlockSize=1, bool fAllowFree=true, enum GetMinFee_mode mode=GMF_BLOCK) const
|
int64 GetMinFee(unsigned int nBlockSize=1, bool fAllowFree=true, enum GetMinFee_mode mode=GMF_BLOCK) const;
|
||||||
{
|
|
||||||
// Base fee is either MIN_TX_FEE or MIN_RELAY_TX_FEE
|
|
||||||
int64 nBaseFee = (mode == GMF_RELAY) ? MIN_RELAY_TX_FEE : MIN_TX_FEE;
|
|
||||||
|
|
||||||
unsigned int nBytes = ::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION);
|
|
||||||
unsigned int nNewBlockSize = nBlockSize + nBytes;
|
|
||||||
int64 nMinFee = (1 + (int64)nBytes / 1000) * nBaseFee;
|
|
||||||
|
|
||||||
if (fAllowFree)
|
|
||||||
{
|
|
||||||
if (nBlockSize == 1)
|
|
||||||
{
|
|
||||||
// Transactions under 10K are free
|
|
||||||
// (about 4500 BTC if made of 50 BTC inputs)
|
|
||||||
if (nBytes < 10000)
|
|
||||||
nMinFee = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Free transaction area
|
|
||||||
if (nNewBlockSize < 27000)
|
|
||||||
nMinFee = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// To limit dust spam, require MIN_TX_FEE/MIN_RELAY_TX_FEE if any output is less than 0.01
|
|
||||||
if (nMinFee < nBaseFee)
|
|
||||||
{
|
|
||||||
BOOST_FOREACH(const CTxOut& txout, vout)
|
|
||||||
if (txout.nValue < CENT)
|
|
||||||
nMinFee = nBaseFee;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Raise the price as the block approaches full
|
|
||||||
if (nBlockSize != 1 && nNewBlockSize >= MAX_BLOCK_SIZE_GEN/2)
|
|
||||||
{
|
|
||||||
if (nNewBlockSize >= MAX_BLOCK_SIZE_GEN)
|
|
||||||
return MAX_MONEY;
|
|
||||||
nMinFee *= MAX_BLOCK_SIZE_GEN / (MAX_BLOCK_SIZE_GEN - nNewBlockSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!MoneyRange(nMinFee))
|
|
||||||
nMinFee = MAX_MONEY;
|
|
||||||
return nMinFee;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool ReadFromDisk(CDiskTxPos pos, FILE** pfileRet=NULL)
|
bool ReadFromDisk(CDiskTxPos pos, FILE** pfileRet=NULL)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user