From ba09e48fc6c4f942bb1b2177ebb0ee1376585a55 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Mon, 5 Nov 2012 19:09:23 -0800 Subject: [PATCH 1/7] Cleanups. --- src/SHAMap.h | 2 +- src/SHAMapNodes.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/SHAMap.h b/src/SHAMap.h index 6acadf6679..7adc92bc2f 100644 --- a/src/SHAMap.h +++ b/src/SHAMap.h @@ -259,7 +259,7 @@ protected: public: SHAMapMissingNode(SHAMapType t, const SHAMapNode& nodeID, const uint256& nodeHash) : - std::runtime_error(nodeID.getString()), mType(t), mNodeID(nodeID), mNodeHash(nodeHash) + std::runtime_error("SHAMapMissingNode"), mType(t), mNodeID(nodeID), mNodeHash(nodeHash) { ; } SHAMapMissingNode(SHAMapType t, const SHAMapNode& nodeID, const uint256& nodeHash, const uint256& targetIndex) : diff --git a/src/SHAMapNodes.cpp b/src/SHAMapNodes.cpp index 0d4f134c45..f4caccb8bc 100644 --- a/src/SHAMapNodes.cpp +++ b/src/SHAMapNodes.cpp @@ -18,10 +18,12 @@ std::string SHAMapNode::getString() const { + static boost::format NodeID("NodeID(%s,%s)"); + if ((mDepth == 0) && (mNodeID.isZero())) return "NodeID(root)"; - return str(boost::format("NodeID(%s,%s)") + return str(NodeID % boost::lexical_cast(mDepth) % mNodeID.GetHex()); } From 0b7668f4a290c3e08dc1942193cb51a5c21873b4 Mon Sep 17 00:00:00 2001 From: Andrey Fedorov Date: Tue, 6 Nov 2012 00:16:45 -0800 Subject: [PATCH 2/7] removing util from remote.js --- js/remote.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/js/remote.js b/js/remote.js index 89a2cdb9d8..0c555388ed 100644 --- a/js/remote.js +++ b/js/remote.js @@ -14,9 +14,6 @@ // instances of this class for network access. // -// Node -var util = require('util'); - // npm var WebSocket = require('ws'); @@ -311,7 +308,7 @@ Remote.prototype._connect_start = function () { // with self-signed certs as the user must have pre-approved the self-signed certs. var self = this; - var url = util.format("ws://%s:%s", this.websocket_ip, this.websocket_port); + var url = "ws://" + this.websocket_ip + ":" + this.websocket_port; if (this.trace) console.log("remote: connect: %s", url); From 29dd173e635db60f1b600b182e2423929d9993b3 Mon Sep 17 00:00:00 2001 From: Andrey Fedorov Date: Tue, 6 Nov 2012 00:24:30 -0800 Subject: [PATCH 3/7] updated .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 793d90cba5..e363836ff5 100644 --- a/.gitignore +++ b/.gitignore @@ -25,4 +25,5 @@ node_modules tmp # Ignore database directory. -db/*.db \ No newline at end of file +db/*.db +newcoind From d630ccb0c90d2e22aff586325b463a48170094f1 Mon Sep 17 00:00:00 2001 From: Andrey Fedorov Date: Tue, 6 Nov 2012 00:37:25 -0800 Subject: [PATCH 4/7] removing newcoind from .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index e363836ff5..d9b3fdee92 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,3 @@ tmp # Ignore database directory. db/*.db -newcoind From 19ab2e5b9cf125d0fc5cd6ee84e3c34c7c7051ae Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Tue, 6 Nov 2012 05:27:54 -0800 Subject: [PATCH 5/7] Add job information to server_info. --- src/NetworkOPs.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/NetworkOPs.cpp b/src/NetworkOPs.cpp index 0ee5be595f..5a1ffe1dfd 100644 --- a/src/NetworkOPs.cpp +++ b/src/NetworkOPs.cpp @@ -906,6 +906,23 @@ Json::Value NetworkOPs::getServerInfo() if (mConsensus) info["consensus"] = mConsensus->getJson(); + typedef std::pair jt_int_pair; + bool anyJobs = false; + Json::Value jobs = Json::arrayValue; + std::vector< std::pair > jobCounts = theApp->getJobQueue().getJobCounts(); + BOOST_FOREACH(jt_int_pair& it, jobCounts) + { + if (it.second != 0) + { + Json::Value o = Json::objectValue; + o[Job::toString(it.first)] = it.second; + jobs.append(o); + anyJobs = true; + } + } + if (anyJobs) + info["jobs"] = jobs; + return info; } From 7eb1ce1b09af1271fa4a8036adf04a104ef86607 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Tue, 6 Nov 2012 05:30:19 -0800 Subject: [PATCH 6/7] Fix a FIXME. --- src/TransactionMaster.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TransactionMaster.cpp b/src/TransactionMaster.cpp index e260ccde25..196845bfdb 100644 --- a/src/TransactionMaster.cpp +++ b/src/TransactionMaster.cpp @@ -58,8 +58,8 @@ bool TransactionMaster::canonicalize(Transaction::pointer& txn, bool may_be_new) uint256 tid = txn->getID(); if (!tid) return false; if (mCache.canonicalize(tid, txn)) return true; - if (may_be_new) // FIXME: Don't dispatch to main pool - theApp->getIOService().post(boost::bind(&Transaction::saveTransaction, txn)); + if (may_be_new) + theApp->getAuxService().post(boost::bind(&Transaction::saveTransaction, txn)); return false; } // vim:ts=4 From f9368b42093a2399865a8a1876e78cd892b0970a Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Tue, 6 Nov 2012 05:42:04 -0800 Subject: [PATCH 7/7] Make native multiplication overflow safe. --- src/Amount.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Amount.cpp b/src/Amount.cpp index 8f22491711..40639d164e 100644 --- a/src/Amount.cpp +++ b/src/Amount.cpp @@ -892,8 +892,16 @@ STAmount STAmount::multiply(const STAmount& v1, const STAmount& v2, const uint16 if (v1.isZero() || v2.isZero()) return STAmount(uCurrencyID, uIssuerID); - if (v1.mIsNative && v2.mIsNative) // FIXME: overflow - return STAmount(v1.getFName(), v1.getSNValue() * v2.getSNValue()); + if (v1.mIsNative && v2.mIsNative) + { + uint64 minV = (v1.getSNValue() < v2.getSNValue()) ? v1.getSNValue() : v2.getSNValue(); + uint64 maxV = (v1.getSNValue() < v2.getSNValue()) ? v2.getSNValue() : v1.getSNValue(); + if (minV > 3000000000) // sqrt(cMaxNative) + throw std::runtime_error("Native value overflow"); + if (((maxV >> 32) * minV) > 2095475792) // cMaxNative / 2^32 + throw std::runtime_error("Native value overflow"); + return STAmount(v1.getFName(), minV * maxV); + } uint64 value1 = v1.mValue, value2 = v2.mValue; int offset1 = v1.mOffset, offset2 = v2.mOffset;