Refactor treatment of Ledger:

All handling of Ledger in shared_ptr is modified to
use a const managed object when the context requires
immutable semantics.
This commit is contained in:
Nik Bougalis
2016-02-21 16:56:18 -05:00
parent 77a4218a9e
commit 34e85ccb62
50 changed files with 788 additions and 782 deletions

View File

@@ -2111,7 +2111,7 @@ PeerImp::getLedger (std::shared_ptr<protocol::TMGetLedger> const& m)
// Figure out what ledger they want
JLOG(p_journal_.trace) << "GetLedger: Received";
Ledger::pointer ledger;
std::shared_ptr<Ledger const> ledger;
if (packet.has_ledgerhash ())
{
@@ -2176,10 +2176,14 @@ PeerImp::getLedger (std::shared_ptr<protocol::TMGetLedger> const& m)
else if (packet.has_ltype () && (packet.ltype () == protocol::ltCLOSED) )
{
ledger = app_.getLedgerMaster ().getClosedLedger ();
assert(! ledger->open());
// VFALCO ledger should never be null!
// VFALCO How can the closed ledger be open?
#if 0
if (ledger && ledger->info().open)
ledger = app_.getLedgerMaster ().getLedgerBySeq (
ledger->info().seq - 1);
#endif
}
else
{
@@ -2208,7 +2212,7 @@ PeerImp::getLedger (std::shared_ptr<protocol::TMGetLedger> const& m)
}
// Fill out the reply
uint256 lHash = ledger->getHash ();
auto const lHash = ledger->info().hash;
reply.set_ledgerhash (lHash.begin (), lHash.size ());
reply.set_ledgerseq (ledger->info().seq);
reply.set_type (packet.itype ());
@@ -2218,7 +2222,7 @@ PeerImp::getLedger (std::shared_ptr<protocol::TMGetLedger> const& m)
// they want the ledger base data
JLOG(p_journal_.trace) << "GetLedger: Base data";
Serializer nData (128);
ledger->addRaw (nData);
addRaw(ledger->info(), nData);
reply.add_nodes ()->set_nodedata (
nData.getDataPtr (), nData.getLength ());