mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Use shared pointers when building protocol messages to fix leaks.
This commit is contained in:
@@ -88,7 +88,7 @@ Transaction::pointer NetworkOPs::processTransaction(Transaction::pointer trans,
|
|||||||
// no cache the account balance information and always get it from the current ledger
|
// no cache the account balance information and always get it from the current ledger
|
||||||
// theApp->getWallet().applyTransaction(trans);
|
// theApp->getWallet().applyTransaction(trans);
|
||||||
|
|
||||||
newcoin::TMTransaction *tx=new newcoin::TMTransaction();
|
boost::shared_ptr<newcoin::TMTransaction> tx = boost::make_shared<newcoin::TMTransaction>();
|
||||||
|
|
||||||
Serializer::pointer s;
|
Serializer::pointer s;
|
||||||
trans->getSTransaction()->getTransaction(*s, false);
|
trans->getSTransaction()->getTransaction(*s, false);
|
||||||
@@ -334,7 +334,7 @@ void NetworkOPs::switchLastClosedLedger(Ledger::pointer newLedger, bool normal)
|
|||||||
{ // this ledger has already closed
|
{ // this ledger has already closed
|
||||||
}
|
}
|
||||||
|
|
||||||
newcoin::TMStatusChange* s = new newcoin::TMStatusChange();
|
boost::shared_ptr<newcoin::TMStatusChange> s = boost::make_shared<newcoin::TMStatusChange>();
|
||||||
|
|
||||||
s->set_newevent(normal ? newcoin::neACCEPTED_LEDGER : newcoin::neSWITCHED_LEDGER);
|
s->set_newevent(normal ? newcoin::neACCEPTED_LEDGER : newcoin::neSWITCHED_LEDGER);
|
||||||
s->set_ledgerseq(newLedger->getLedgerSeq());
|
s->set_ledgerseq(newLedger->getLedgerSeq());
|
||||||
|
|||||||
@@ -716,17 +716,17 @@ void Peer::recvGetLedger(newcoin::TMGetLedger& packet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Figure out what information they want
|
// Figure out what information they want
|
||||||
newcoin::TMLedgerData* data = new newcoin::TMLedgerData;
|
boost::shared_ptr<newcoin::TMLedgerData> data = boost::make_shared<newcoin::TMLedgerData>();
|
||||||
uint256 lHash = ledger->getHash();
|
uint256 lHash = ledger->getHash();
|
||||||
data->set_ledgerhash(lHash.begin(), lHash.size());
|
data->set_ledgerhash(lHash.begin(), lHash.size());
|
||||||
data->set_ledgerseq(ledger->getLedgerSeq());
|
data->set_ledgerseq(ledger->getLedgerSeq());
|
||||||
data->set_type(packet.itype());
|
data->set_type(packet.itype());
|
||||||
|
|
||||||
if(packet.itype()==newcoin::liBASE)
|
if(packet.itype() == newcoin::liBASE)
|
||||||
{
|
{
|
||||||
Serializer nData(116);
|
Serializer nData(116);
|
||||||
ledger->addRaw(nData);
|
ledger->addRaw(nData);
|
||||||
newcoin::TMLedgerNode* node=data->add_nodes();
|
newcoin::TMLedgerNode* node = data->add_nodes();
|
||||||
node->set_nodedata(nData.getDataPtr(), nData.getLength());
|
node->set_nodedata(nData.getDataPtr(), nData.getLength());
|
||||||
}
|
}
|
||||||
else if ( (packet.itype()==newcoin::liTX_NODE) || (packet.itype()==newcoin::liAS_NODE) )
|
else if ( (packet.itype()==newcoin::liTX_NODE) || (packet.itype()==newcoin::liAS_NODE) )
|
||||||
@@ -820,7 +820,7 @@ void Peer::sendHello()
|
|||||||
|
|
||||||
theApp->getWallet().getNodePrivate().signNodePrivate(mCookieHash, vchSig);
|
theApp->getWallet().getNodePrivate().signNodePrivate(mCookieHash, vchSig);
|
||||||
|
|
||||||
newcoin::TMHello* h = new newcoin::TMHello();
|
boost::shared_ptr<newcoin::TMHello> h = boost::make_shared<newcoin::TMHello>();
|
||||||
|
|
||||||
h->set_version(theConfig.VERSION);
|
h->set_version(theConfig.VERSION);
|
||||||
h->set_ledgerindex(theApp->getOPs().getCurrentLedgerID());
|
h->set_ledgerindex(theApp->getOPs().getCurrentLedgerID());
|
||||||
|
|||||||
Reference in New Issue
Block a user