aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2012-04-15 21:05:54 -0400
committerLuke Dashjr <luke-jr+git@utopios.org>2012-04-15 21:05:54 -0400
commit79fc752b6104b796aa5e0a8a8b6d2822fb0f3299 (patch)
tree7ae039ced8787d0fe10e1150f3dcf249524c6a4c /src
parentfdcafa35359b3ad9af79d2367a1884d01607fb84 (diff)
parent8460185dec74383b1e49500683cfc7aa9ceba554 (diff)
downloadbitcoin-79fc752b6104b796aa5e0a8a8b6d2822fb0f3299.tar.xz
Merge branch '0.4.x' into 0.5.0.x
Conflicts: src/keystore.h
Diffstat (limited to 'src')
-rw-r--r--src/bitcoinrpc.cpp42
-rw-r--r--src/keystore.h2
-rw-r--r--src/main.cpp4
-rw-r--r--src/main.h2
-rw-r--r--src/util.cpp11
-rw-r--r--src/wallet.cpp2
-rw-r--r--src/wallet.h2
7 files changed, 50 insertions, 15 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index ac20ae8610..8a98d7fca3 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -749,8 +749,10 @@ Value getbalance(const Array& params, bool fHelp)
list<pair<CBitcoinAddress, int64> > listSent;
wtx.GetAmounts(allGeneratedImmature, allGeneratedMature, listReceived, listSent, allFee, strSentAccount);
if (wtx.GetDepthInMainChain() >= nMinDepth)
+ {
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress,int64)& r, listReceived)
nBalance += r.second;
+ }
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress,int64)& r, listSent)
nBalance -= r.second;
nBalance -= allFee;
@@ -1108,6 +1110,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
// Received
if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth)
+ {
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, int64)& r, listReceived)
{
string account;
@@ -1125,6 +1128,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
ret.push_back(entry);
}
}
+ }
}
void AcentryToJSON(const CAccountingEntry& acentry, const string& strAccount, Array& ret)
@@ -1161,14 +1165,21 @@ Value listtransactions(const Array& params, bool fHelp)
if (params.size() > 2)
nFrom = params[2].get_int();
+ if (nCount < 0)
+ throw JSONRPCError(-8, "Negative count");
+ if (nFrom < 0)
+ throw JSONRPCError(-8, "Negative from");
+
Array ret;
CWalletDB walletdb(pwalletMain->strWalletFile);
- // Firs: get all CWalletTx and CAccountingEntry into a sorted-by-time multimap:
+ // First: get all CWalletTx and CAccountingEntry into a sorted-by-time multimap.
typedef pair<CWalletTx*, CAccountingEntry*> TxPair;
typedef multimap<int64, TxPair > TxItems;
TxItems txByTime;
+ // Note: maintaining indices in the database of (account,time) --> txid and (account, time) --> acentry
+ // would make this much faster for applications that do this a lot.
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
CWalletTx* wtx = &((*it).second);
@@ -1181,10 +1192,8 @@ Value listtransactions(const Array& params, bool fHelp)
txByTime.insert(make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry)));
}
- // Now: iterate backwards until we have nCount items to return:
- TxItems::reverse_iterator it = txByTime.rbegin();
- if (txByTime.size() > nFrom) std::advance(it, nFrom);
- for (; it != txByTime.rend(); ++it)
+ // iterate backwards until we have nCount items to return:
+ for (TxItems::reverse_iterator it = txByTime.rbegin(); it != txByTime.rend(); ++it)
{
CWalletTx *const pwtx = (*it).second.first;
if (pwtx != 0)
@@ -1193,18 +1202,21 @@ Value listtransactions(const Array& params, bool fHelp)
if (pacentry != 0)
AcentryToJSON(*pacentry, strAccount, ret);
- if (ret.size() >= nCount) break;
+ if (ret.size() >= (nCount+nFrom)) break;
}
- // ret is now newest to oldest
+ // ret is newest to oldest
- // Make sure we return only last nCount items (sends-to-self might give us an extra):
- if (ret.size() > nCount)
- {
- Array::iterator last = ret.begin();
- std::advance(last, nCount);
- ret.erase(last, ret.end());
- }
- std::reverse(ret.begin(), ret.end()); // oldest to newest
+ if (nFrom > ret.size()) nFrom = ret.size();
+ if (nFrom+nCount > ret.size()) nCount = ret.size()-nFrom;
+ Array::iterator first = ret.begin();
+ std::advance(first, nFrom);
+ Array::iterator last = ret.begin();
+ std::advance(last, nFrom+nCount);
+
+ if (last != ret.end()) ret.erase(last, ret.end());
+ if (first != ret.begin()) ret.erase(ret.begin(), first);
+
+ std::reverse(ret.begin(), ret.end()); // Return oldest to newest
return ret;
}
diff --git a/src/keystore.h b/src/keystore.h
index 4d889146fc..8aaf3e6440 100644
--- a/src/keystore.h
+++ b/src/keystore.h
@@ -14,6 +14,8 @@ protected:
mutable CCriticalSection cs_KeyStore;
public:
+ virtual ~CKeyStore() {}
+
// Add a key to the store.
virtual bool AddKey(const CKey& key) =0;
diff --git a/src/main.cpp b/src/main.cpp
index 3c5fef2997..fade6a28a4 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1169,14 +1169,18 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex)
// This rule applies to all blocks whose timestamp is after March 15, 2012, 0:00 UTC.
// On testnet it is enabled as of februari 20, 2012, 0:00 UTC.
if (pindex->nTime > 1331769600 || (fTestNet && pindex->nTime > 1329696000))
+ {
BOOST_FOREACH(CTransaction& tx, vtx)
{
CTxIndex txindexOld;
if (txdb.ReadTxIndex(tx.GetHash(), txindexOld))
+ {
BOOST_FOREACH(CDiskTxPos &pos, txindexOld.vSpent)
if (pos.IsNull())
return false;
+ }
}
+ }
// P2SH didn't become active until Apr 1 2012 (Feb 15 on testnet)
int64 nEvalSwitchTime = fTestNet ? 1329264000 : 1333238400;
diff --git a/src/main.h b/src/main.h
index e400bd96ab..70d83b90e0 100644
--- a/src/main.h
+++ b/src/main.h
@@ -578,9 +578,11 @@ public:
// 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)
diff --git a/src/util.cpp b/src/util.cpp
index a9111673e7..5b59eadaa2 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -4,6 +4,17 @@
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
#include "headers.h"
#include "strlcpy.h"
+
+// Work around clang compilation problem in Boost 1.46:
+// /usr/include/boost/program_options/detail/config_file.hpp:163:17: error: call to function 'to_internal' that is neither visible in the template definition nor found by argument-dependent lookup
+// See also: http://stackoverflow.com/questions/10020179/compilation-fail-in-boost-librairies-program-options
+// http://clang.debian.net/status.php?version=3.0&key=CANNOT_FIND_FUNCTION
+namespace boost {
+ namespace program_options {
+ std::string to_internal(const std::string&);
+ }
+}
+
#include <boost/program_options/detail/config_file.hpp>
#include <boost/program_options/parsers.hpp>
#include <boost/filesystem.hpp>
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 20c3eabdc7..43c9656f78 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -547,8 +547,10 @@ void CWalletTx::AddSupportingTransactions(CTxDB& txdb)
vtxPrev.push_back(tx);
if (nDepth < COPY_DEPTH)
+ {
BOOST_FOREACH(const CTxIn& txin, tx.vin)
vWorkQueue.push_back(txin.prevout.hash);
+ }
}
}
}
diff --git a/src/wallet.h b/src/wallet.h
index 62dd6d52a6..fe97a0a5a5 100644
--- a/src/wallet.h
+++ b/src/wallet.h
@@ -509,8 +509,10 @@ public:
return false;
if (mapPrev.empty())
+ {
BOOST_FOREACH(const CMerkleTx& tx, vtxPrev)
mapPrev[tx.GetHash()] = &tx;
+ }
BOOST_FOREACH(const CTxIn& txin, ptx->vin)
{