Merge branch 'master' of github.com:jedmccaleb/NewCoin

This commit is contained in:
Arthur Britto
2012-11-06 06:22:23 -08:00
7 changed files with 35 additions and 11 deletions

2
.gitignore vendored
View File

@@ -25,4 +25,4 @@ node_modules
tmp
# Ignore database directory.
db/*.db
db/*.db

View File

@@ -14,9 +14,6 @@
// instances of this class for network access.
//
// Node
var util = require('util');
// npm
var WebSocket = require('ws');
@@ -317,7 +314,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);

View File

@@ -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;

View File

@@ -906,6 +906,23 @@ Json::Value NetworkOPs::getServerInfo()
if (mConsensus)
info["consensus"] = mConsensus->getJson();
typedef std::pair<JobType, int> jt_int_pair;
bool anyJobs = false;
Json::Value jobs = Json::arrayValue;
std::vector< std::pair<JobType, int> > 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;
}

View File

@@ -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) :

View File

@@ -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<std::string>(mDepth)
% mNodeID.GetHex());
}

View File

@@ -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