mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
Merge branch 'master' of github.com:jedmccaleb/NewCoin
This commit is contained in:
@@ -43,6 +43,8 @@ class Application
|
||||
boost::asio::io_service mIOService, mAuxService;
|
||||
boost::asio::io_service::work mIOWork, mAuxWork;
|
||||
|
||||
boost::recursive_mutex mMasterLock;
|
||||
|
||||
Wallet mWallet;
|
||||
UniqueNodeList mUNL;
|
||||
LedgerMaster mMasterLedger;
|
||||
@@ -99,6 +101,7 @@ public:
|
||||
JobQueue& getJobQueue() { return mJobQueue; }
|
||||
SuppressionTable& getSuppression() { return mSuppressions; }
|
||||
RPCHandler& getRPCHandler() { return mRPCHandler; }
|
||||
boost::recursive_mutex& getMasterLock() { return mMasterLock; }
|
||||
|
||||
|
||||
bool isNew(const uint256& s) { return mSuppressions.addSuppression(s); }
|
||||
|
||||
@@ -21,6 +21,7 @@ enum JobType
|
||||
jtTRANSACTION,
|
||||
jtPROPOSAL_ut,
|
||||
jtVALIDATION_t,
|
||||
jtTRANSACTION_l,
|
||||
jtPROPOSAL_t,
|
||||
jtADMIN,
|
||||
jtDEATH, // job of death, used internally
|
||||
|
||||
@@ -541,7 +541,7 @@ bool LedgerAcquireMaster::gotLedgerData(ripple::TMLedgerData& packet, Peer::ref
|
||||
return false;
|
||||
}
|
||||
memcpy(hash.begin(), packet.ledgerhash().data(), 32);
|
||||
cLog(lsTRACE) << "Got data ( " << packet.nodes().size() << ") for acquiring ledger: " << hash;
|
||||
cLog(lsTRACE) << "Got data (" << packet.nodes().size() << ") for acquiring ledger: " << hash;
|
||||
|
||||
LedgerAcquire::pointer ledger = find(hash);
|
||||
if (!ledger)
|
||||
|
||||
@@ -1141,6 +1141,7 @@ uint32 LedgerConsensus::roundCloseTime(uint32 closeTime)
|
||||
|
||||
void LedgerConsensus::accept(SHAMap::ref set)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock masterLock(theApp->getMasterLock());
|
||||
assert(set->getHash() == mOurPosition->getCurrentHash());
|
||||
|
||||
uint32 closeTime = roundCloseTime(mOurPosition->getCloseTime());
|
||||
|
||||
@@ -161,7 +161,6 @@ Transaction::pointer NetworkOPs::submitTransactionSync(const Transaction::pointe
|
||||
|
||||
Transaction::pointer NetworkOPs::processTransaction(Transaction::pointer trans, stCallback callback)
|
||||
{
|
||||
Transaction::pointer dbtx = theApp->getMasterTransaction().fetch(trans->getID(), true);
|
||||
|
||||
int newFlags = theApp->getSuppression().getFlags(trans->getID());
|
||||
if ((newFlags & SF_BAD) != 0)
|
||||
@@ -182,6 +181,8 @@ Transaction::pointer NetworkOPs::processTransaction(Transaction::pointer trans,
|
||||
theApp->isNewFlag(trans->getID(), SF_SIGGOOD);
|
||||
}
|
||||
|
||||
boost::recursive_mutex::scoped_lock sl(theApp->getMasterLock());
|
||||
Transaction::pointer dbtx = theApp->getMasterTransaction().fetch(trans->getID(), true);
|
||||
TER r = mLedgerMaster->doTransaction(*trans->getSTransaction(), tapOPEN_LEDGER | tapNO_CHECK_SIGN);
|
||||
trans->setResult(r);
|
||||
|
||||
@@ -762,6 +763,8 @@ uint256 NetworkOPs::getConsensusLCL()
|
||||
void NetworkOPs::processTrustedProposal(LedgerProposal::pointer proposal,
|
||||
boost::shared_ptr<ripple::TMProposeSet> set, RippleAddress nodePublic, uint256 checkLedger, bool sigGood)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl(theApp->getMasterLock());
|
||||
|
||||
bool relay = true;
|
||||
|
||||
if (!haveConsensusObject())
|
||||
|
||||
@@ -41,6 +41,8 @@ void Peer::handle_write(const boost::system::error_code& error, size_t bytes_tra
|
||||
// std::cerr << "Peer::handle_write bytes: "<< bytes_transferred << std::endl;
|
||||
#endif
|
||||
|
||||
boost::recursive_mutex::scoped_lock sl(theApp->getMasterLock());
|
||||
|
||||
mSendingPacket.reset();
|
||||
|
||||
if (mDetaching)
|
||||
@@ -357,6 +359,7 @@ void Peer::handle_read_body(const boost::system::error_code& error)
|
||||
else
|
||||
{
|
||||
cLog(lsINFO) << "Peer: Body: Error: " << ADDRESS(this) << ": " << error.category().name() << ": " << error.message() << ": " << error;
|
||||
boost::recursive_mutex::scoped_lock sl(theApp->getMasterLock());
|
||||
detach("hrb");
|
||||
}
|
||||
}
|
||||
@@ -371,6 +374,7 @@ void Peer::processReadBuffer()
|
||||
// std::cerr << "Peer::processReadBuffer: " << mIpPort.first << " " << mIpPort.second << std::endl;
|
||||
|
||||
// If connected and get a mtHELLO or if not connected and get a non-mtHELLO, wrong message was sent.
|
||||
boost::recursive_mutex::scoped_lock sl(theApp->getMasterLock());
|
||||
if (mHelloed == (type == ripple::mtHELLO))
|
||||
{
|
||||
cLog(lsWARNING) << "Wrong message type: " << type;
|
||||
@@ -893,8 +897,6 @@ void Peer::recvPropose(const boost::shared_ptr<ripple::TMProposeSet>& packet)
|
||||
|
||||
void Peer::recvHaveTxSet(ripple::TMHaveTransactionSet& packet)
|
||||
{
|
||||
// FIXME: We should have some limit on the number of HaveTxSet messages a peer can send us
|
||||
// per consensus pass, to keep a peer from running up our memory without limit
|
||||
uint256 hashes;
|
||||
if (packet.hash().size() != (256 / 8))
|
||||
{
|
||||
|
||||
@@ -1384,7 +1384,9 @@ Json::Value RPCHandler::doCommand(const std::string& command, Json::Value& param
|
||||
return rpcError(rpcNO_NETWORK);
|
||||
}
|
||||
// XXX Should verify we have a current ledger.
|
||||
else if ((commandsA[i].iOptions & optCurrent) && false)
|
||||
|
||||
boost::recursive_mutex::scoped_lock sl(theApp->getMasterLock());
|
||||
if ((commandsA[i].iOptions & optCurrent) && false)
|
||||
{
|
||||
return rpcError(rpcNO_CURRENT);
|
||||
}
|
||||
|
||||
@@ -16,16 +16,26 @@ protected:
|
||||
|
||||
public:
|
||||
ScopedLock(boost::recursive_mutex& mutex) :
|
||||
mHolder(boost::make_shared<boost::recursive_mutex::scoped_lock>(boost::ref(mutex)))
|
||||
{ ; }
|
||||
void lock() const
|
||||
{
|
||||
mHolder->lock();
|
||||
}
|
||||
void unlock() const
|
||||
{
|
||||
mHolder->unlock();
|
||||
}
|
||||
mHolder(boost::make_shared<boost::recursive_mutex::scoped_lock>(boost::ref(mutex))) { ; }
|
||||
|
||||
void lock() const { mHolder->lock(); }
|
||||
void unlock() const { mHolder->unlock(); }
|
||||
};
|
||||
|
||||
// A class that unlocks on construction and locks on destruction
|
||||
|
||||
class ScopedUnlock
|
||||
{
|
||||
protected:
|
||||
boost::recursive_mutex& mMutex;
|
||||
|
||||
public:
|
||||
ScopedUnlock(boost::recursive_mutex& mutex) : mMutex(mutex) { mMutex.unlock(); }
|
||||
~ScopedUnlock() { mMutex.lock(); }
|
||||
|
||||
private:
|
||||
ScopedUnlock(const ScopedUnlock&); // no implementation
|
||||
ScopedUnlock& operator=(const ScopedUnlock&); // no implementation
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -34,6 +34,7 @@ TER TransactionEngine::setAuthorized(const SerializedTransaction& txn, bool bMus
|
||||
std::vector<unsigned char> vucSignature = txn.getFieldVL(sfSignature);
|
||||
RippleAddress naAccountPublic = RippleAddress::createAccountPublic(vucPubKey);
|
||||
|
||||
// FIXME: This should be moved to the transaction's signature check and cached
|
||||
if (!naAccountPublic.accountPublicVerify(Serializer::getSHA512Half(vucCipher), vucSignature))
|
||||
{
|
||||
Log(lsWARNING) << "createGenerator: bad signature unauthorized generator claim";
|
||||
@@ -614,6 +615,7 @@ TER TransactionEngine::doWalletAdd(const SerializedTransaction& txn)
|
||||
const RippleAddress naMasterPubKey = RippleAddress::createAccountPublic(vucPubKey);
|
||||
const uint160 uDstAccountID = naMasterPubKey.getAccountID();
|
||||
|
||||
// FIXME: This should be moved to the transaction's signature check logic and cached
|
||||
if (!naMasterPubKey.accountPublicVerify(Serializer::getSHA512Half(uAuthKeyID.begin(), uAuthKeyID.size()), vucSignature))
|
||||
{
|
||||
std::cerr << "WalletAdd: unauthorized: bad signature " << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user