Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions doc/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
(note: this is a temporary file, to be added-to by anybody, and deleted at
release time)

Fee changes

Fee-handling code has been rewritten, so that transaction fees paid are adjusted
based on the transactions that miners are including in blocks instead of
being arbitrarily hard-coded.

RPC changes

getrawmempool : now has an optional 'verbose' boolean flag, if true
reports information on each memory pool transaction.

New RPC methods

estimatefees : Returns estimate of priority or fee needed to get
transactions accepted into blocks.

Command-line changes

-limitfreerelay and -minrelaytxfee options are obsolete.
They are replaced with dropping transactions that are unlikely
to be included in the next several blocks.

6 changes: 3 additions & 3 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ BITCOIN_CORE_H = addrman.h alert.h allocators.h base58.h bignum.h \
clientversion.h compat.h core.h crypter.h db.h hash.h init.h \
key.h keystore.h leveldb.h limitedmap.h main.h miner.h mruset.h \
netbase.h net.h protocol.h script.h serialize.h sync.h threadsafety.h \
txdb.h ui_interface.h uint256.h util.h version.h walletdb.h wallet.h
txdb.h txmempool.h ui_interface.h uint256.h util.h version.h walletdb.h wallet.h

JSON_H = json/json_spirit.h json/json_spirit_error_position.h \
json/json_spirit_reader.h json/json_spirit_reader_template.h \
Expand All @@ -31,12 +31,12 @@ obj/build.h: FORCE
$(abs_top_srcdir)
version.o: obj/build.h

libbitcoin_a_SOURCES = addrman.cpp alert.cpp bitcoinrpc.cpp bloom.cpp \
libbitcoin_a_SOURCES = addrman.cpp alert.cpp allocators.cpp bitcoinrpc.cpp bloom.cpp \
chainparams.cpp checkpoints.cpp core.cpp crypter.cpp db.cpp hash.cpp \
init.cpp key.cpp keystore.cpp leveldb.cpp main.cpp miner.cpp \
netbase.cpp net.cpp noui.cpp protocol.cpp rpcblockchain.cpp rpcdump.cpp \
rpcmining.cpp rpcnet.cpp rpcrawtransaction.cpp rpcwallet.cpp script.cpp \
sync.cpp txdb.cpp util.cpp version.cpp wallet.cpp walletdb.cpp $(JSON_H) \
sync.cpp txdb.cpp txmempool.cpp util.cpp version.cpp wallet.cpp walletdb.cpp $(JSON_H) \
$(BITCOIN_CORE_H)

nodist_libbitcoin_a_SOURCES = $(top_srcdir)/src/obj/build.h
Expand Down
64 changes: 64 additions & 0 deletions src/allocators.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright (c) 2009-2013 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "allocators.h"

#ifdef WIN32
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x0501
#define WIN32_LEAN_AND_MEAN 1
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h>
// This is used to attempt to keep keying material out of swap
// Note that VirtualLock does not provide this as a guarantee on Windows,
// but, in practice, memory that has been VirtualLock'd almost never gets written to
// the pagefile except in rare circumstances where memory is extremely low.
#else
#include <sys/mman.h>
#include <limits.h> // for PAGESIZE
#include <unistd.h> // for sysconf
#endif

/** Determine system page size in bytes */
static inline size_t GetSystemPageSize()
{
size_t page_size;
#if defined(WIN32)
SYSTEM_INFO sSysInfo;
GetSystemInfo(&sSysInfo);
page_size = sSysInfo.dwPageSize;
#elif defined(PAGESIZE) // defined in limits.h
page_size = PAGESIZE;
#else // assume some POSIX OS
page_size = sysconf(_SC_PAGESIZE);
#endif
return page_size;
}

bool MemoryPageLocker::Lock(const void *addr, size_t len)
{
#ifdef WIN32
return VirtualLock(const_cast<void*>(addr), len);
#else
return mlock(addr, len) == 0;
#endif
}

bool MemoryPageLocker::Unlock(const void *addr, size_t len)
{
#ifdef WIN32
return VirtualUnlock(const_cast<void*>(addr), len);
#else
return munlock(addr, len) == 0;
#endif
}

LockedPageManager::LockedPageManager() : LockedPageManagerBase<MemoryPageLocker>(GetSystemPageSize())
{
}

56 changes: 3 additions & 53 deletions src/allocators.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,6 @@
#include <map>
#include <openssl/crypto.h> // for OPENSSL_cleanse()

#ifdef WIN32
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x0501
#define WIN32_LEAN_AND_MEAN 1
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h>
// This is used to attempt to keep keying material out of swap
// Note that VirtualLock does not provide this as a guarantee on Windows,
// but, in practice, memory that has been VirtualLock'd almost never gets written to
// the pagefile except in rare circumstances where memory is extremely low.
#else
#include <sys/mman.h>
#include <limits.h> // for PAGESIZE
#include <unistd.h> // for sysconf
#endif

/**
* Thread-safe class to keep track of locked (ie, non-swappable) memory pages.
Expand Down Expand Up @@ -115,21 +96,6 @@ template <class Locker> class LockedPageManagerBase
Histogram histogram;
};

/** Determine system page size in bytes */
static inline size_t GetSystemPageSize()
{
size_t page_size;
#if defined(WIN32)
SYSTEM_INFO sSysInfo;
GetSystemInfo(&sSysInfo);
page_size = sSysInfo.dwPageSize;
#elif defined(PAGESIZE) // defined in limits.h
page_size = PAGESIZE;
#else // assume some POSIX OS
page_size = sysconf(_SC_PAGESIZE);
#endif
return page_size;
}

/**
* OS-dependent memory page locking/unlocking.
Expand All @@ -141,25 +107,11 @@ class MemoryPageLocker
/** Lock memory pages.
* addr and len must be a multiple of the system page size
*/
bool Lock(const void *addr, size_t len)
{
#ifdef WIN32
return VirtualLock(const_cast<void*>(addr), len);
#else
return mlock(addr, len) == 0;
#endif
}
bool Lock(const void *addr, size_t len);
/** Unlock memory pages.
* addr and len must be a multiple of the system page size
*/
bool Unlock(const void *addr, size_t len)
{
#ifdef WIN32
return VirtualUnlock(const_cast<void*>(addr), len);
#else
return munlock(addr, len) == 0;
#endif
}
bool Unlock(const void *addr, size_t len);
};

/**
Expand All @@ -171,9 +123,7 @@ class LockedPageManager: public LockedPageManagerBase<MemoryPageLocker>
public:
static LockedPageManager instance; // instantiated in util.cpp
private:
LockedPageManager():
LockedPageManagerBase<MemoryPageLocker>(GetSystemPageSize())
{}
LockedPageManager();
};

//
Expand Down
4 changes: 4 additions & 0 deletions src/bitcoinrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ static const CRPCCommand vRPCCommands[] =
{ "lockunspent", &lockunspent, false, false, true },
{ "listlockunspent", &listlockunspent, false, false, true },
{ "verifychain", &verifychain, true, false, false },
{ "estimatefees", &estimatefees, true, true, false },
};

CRPCTable::CRPCTable()
Expand Down Expand Up @@ -1243,6 +1244,9 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector<std::stri
if (strMethod == "verifychain" && n > 0) ConvertTo<boost::int64_t>(params[0]);
if (strMethod == "verifychain" && n > 1) ConvertTo<boost::int64_t>(params[1]);
if (strMethod == "keypoolrefill" && n > 0) ConvertTo<boost::int64_t>(params[0]);
if (strMethod == "getrawmempool" && n > 0) ConvertTo<bool>(params[0]);
if (strMethod == "estimatefees" && n > 0) ConvertTo<double>(params[0]);
if (strMethod == "estimatefees" && n > 1) ConvertTo<double>(params[1]);

return params;
}
Expand Down
1 change: 1 addition & 0 deletions src/bitcoinrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,5 +223,6 @@ extern json_spirit::Value getblock(const json_spirit::Array& params, bool fHelp)
extern json_spirit::Value gettxoutsetinfo(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value gettxout(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value verifychain(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value estimatefees(const json_spirit::Array& params, bool fHelp);

#endif
1 change: 1 addition & 0 deletions src/checkqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#ifndef CHECKQUEUE_H
#define CHECKQUEUE_H

#include <boost/foreach.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/locks.hpp>
#include <boost/thread/condition_variable.hpp>
Expand Down
25 changes: 25 additions & 0 deletions src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <boost/foreach.hpp>

#include "core.h"
#include "util.h"

/** Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) */
int64 CTransaction::nMinTxFee = 10000; // Override with -mintxfee

/** Mining: priorities smaller than this are not eligible for free-transaction area */
double CTransaction::dMinFreePriority = COIN * 144 / 250;

std::string COutPoint::ToString() const
{
return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10).c_str(), n);
Expand Down Expand Up @@ -107,6 +115,23 @@ bool CTransaction::IsNewerThan(const CTransaction& old) const
return fNewer;
}

/** Amount of bitcoins spent by the transaction.
@return sum of all outputs (note: does not include fees)
*/
int64 CTransaction::GetValueOut() const
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: call this GetSumValueOut()

{
int64 nValueOut = 0;
BOOST_FOREACH(const CTxOut& txout, this->vout)
{
nValueOut += txout.nValue;
if (!MoneyRange(txout.nValue) || !MoneyRange(nValueOut))
throw std::runtime_error("GetValueOut() : value out of range");
}
return nValueOut;
}



std::string CTransaction::ToString() const
{
std::string str;
Expand Down
28 changes: 12 additions & 16 deletions src/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

#include <stdio.h>

/** No amount larger than this (in satoshi) is valid */
static const int64 MAX_MONEY = 21000000 * COIN;
inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't similar functions in util.h or at least used there by our helper functions?


class CTransaction;

/** An outpoint - a combination of a transaction hash and an index n into its vout */
Expand Down Expand Up @@ -49,11 +53,11 @@ class COutPoint
class CInPoint
{
public:
CTransaction* ptx;
const CTransaction* ptx;
unsigned int n;

CInPoint() { SetNull(); }
CInPoint(CTransaction* ptxIn, unsigned int nIn) { ptx = ptxIn; n = nIn; }
CInPoint(const CTransaction* ptxIn, unsigned int nIn) { ptx = ptxIn; n = nIn; }
void SetNull() { ptx = NULL; n = (unsigned int) -1; }
bool IsNull() const { return (ptx == NULL && n == (unsigned int) -1); }
};
Expand Down Expand Up @@ -143,19 +147,6 @@ class CTxOut

uint256 GetHash() const;

bool IsDust(int64 nMinRelayTxFee) const
{
// "Dust" is defined in terms of CTransaction::nMinRelayTxFee,
// which has units satoshis-per-kilobyte.
// If you'd pay more than 1/3 in fees
// to spend something, then we consider it dust.
// A typical txout is 34 bytes big, and will
// need a CTxIn of at least 148 bytes to spend,
// so dust is a txout less than 54 uBTC
// (5460 satoshis) with default nMinRelayTxFee
return ((nValue*1000)/(3*((int)GetSerializeSize(SER_DISK,0)+148)) < nMinRelayTxFee);
}

friend bool operator==(const CTxOut& a, const CTxOut& b)
{
return (a.nValue == b.nValue &&
Expand All @@ -179,7 +170,7 @@ class CTransaction
{
public:
static int64 nMinTxFee;
static int64 nMinRelayTxFee;
static double dMinFreePriority;
static const int CURRENT_VERSION=1;
int nVersion;
std::vector<CTxIn> vin;
Expand Down Expand Up @@ -221,6 +212,11 @@ class CTransaction
return (vin.size() == 1 && vin[0].prevout.IsNull());
}

/** Returns sum of all outputs (note: does not include fees) */
int64 GetValueOut() const;
// Note: GetValueIn is a method on CCoinsViewCache, because
// it requires looking up the values of previous inputs

friend bool operator==(const CTransaction& a, const CTransaction& b)
{
return (a.nVersion == b.nVersion &&
Expand Down
21 changes: 15 additions & 6 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ void Shutdown()
bitdb.Flush(false);
GenerateBitcoins(false, NULL);
StopNode();
mempool.Write();
{
LOCK(cs_main);
if (pwalletMain)
Expand Down Expand Up @@ -433,7 +434,7 @@ bool AppInit2(boost::thread_group& threadGroup)

if (mapMultiArgs.count("-debug")) fDebug = true;
fBenchmark = GetBoolArg("-benchmark", false);
mempool.fChecks = GetBoolArg("-checkmempool", RegTest());
mempool.setSanityCheck(GetBoolArg("-checkmempool", RegTest()));
Checkpoints::fEnabled = GetBoolArg("-checkpoints", true);

// -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency
Expand Down Expand Up @@ -492,11 +493,14 @@ bool AppInit2(boost::thread_group& threadGroup)
}
if (mapArgs.count("-minrelaytxfee"))
{
int64 n = 0;
if (ParseMoney(mapArgs["-minrelaytxfee"], n) && n > 0)
CTransaction::nMinRelayTxFee = n;
else
return InitError(strprintf(_("Invalid amount for -minrelaytxfee=<amount>: '%s'"), mapArgs["-minrelaytxfee"].c_str()));
LogPrintf("Warning: -minrelaytxfee obsolete, use -mintxfee\n");
}
if (mapArgs.count("-minfreepriority"))
{
double dPriority = atof(mapArgs["-minfreepriority"].c_str());
if (dPriority < 0)
return InitError(strprintf(_("Invalid amount for -minfreepriority=<priority>: '%s'"), mapArgs["-minfreepriority"].c_str()));
CTransaction::dMinFreePriority = dPriority;
}

if (mapArgs.count("-paytxfee"))
Expand Down Expand Up @@ -943,6 +947,11 @@ bool AppInit2(boost::thread_group& threadGroup)
nWalletDBUpdated++;
}

// It is OK if mempool.Read() fails; starting out with an empty memory pool is not
// a problem, it gets filled quickly.
mempool.Read();
LogPrintf("Read %lu mempool transactions\n", mempool.size());

// ********************************************************* Step 9: import blocks

// scan for better chains in the block chain database, that are not yet connected in the active best chain
Expand Down
1 change: 1 addition & 0 deletions src/limitedmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#ifndef BITCOIN_LIMITEDMAP_H
#define BITCOIN_LIMITEDMAP_H

#include <assert.h> // TODO: remove
#include <map>
#include <deque>

Expand Down
Loading