20 #include <ripple/app/ledger/LedgerMaster.h>
21 #include <ripple/app/ledger/LedgerReplayer.h>
22 #include <ripple/app/ledger/impl/LedgerReplayMsgHandler.h>
23 #include <ripple/app/main/Application.h>
33 , journal_(app.journal(
"LedgerReplayMsgHandler"))
37 protocol::TMProofPathResponse
41 protocol::TMProofPathRequest& packet = *msg;
42 protocol::TMProofPathResponse reply;
44 if (!packet.has_key() || !packet.has_ledgerhash() || !packet.has_type() ||
47 !protocol::TMLedgerMapType_IsValid(packet.type()))
50 reply.set_error(protocol::TMReplyError::reBAD_REQUEST);
53 reply.set_key(packet.key());
54 reply.set_ledgerhash(packet.ledgerhash());
55 reply.set_type(packet.type());
57 uint256 const key(packet.key());
58 uint256 const ledgerHash(packet.ledgerhash());
63 <<
"getProofPath: Don't have ledger " << ledgerHash;
64 reply.set_error(protocol::TMReplyError::reNO_LEDGER);
69 switch (packet.type())
71 case protocol::lmACCOUNT_STATE:
72 return ledger->stateMap().getProofPath(key);
73 case protocol::lmTRANASCTION:
74 return ledger->txMap().getProofPath(key);
84 JLOG(
journal_.
debug()) <<
"getProofPath: Don't have the node " << key
85 <<
" of ledger " << ledgerHash;
86 reply.set_error(protocol::TMReplyError::reNO_NODE);
92 addRaw(ledger->info(), nData);
95 for (
auto const& b : *path)
96 reply.add_path(b.data(), b.size());
99 <<
" of ledger " << ledgerHash <<
" path length "
108 protocol::TMProofPathResponse& reply = *msg;
109 if (reply.has_error() || !reply.has_key() || !reply.has_ledgerhash() ||
110 !reply.has_type() || !reply.has_ledgerheader() ||
111 reply.path_size() == 0)
117 if (reply.type() != protocol::lmACCOUNT_STATE)
120 <<
"Bad message: we only support the state ShaMap for now";
126 {reply.ledgerheader().data(), reply.ledgerheader().size()});
127 uint256 replyHash(reply.ledgerhash());
133 info.hash = replyHash;
139 <<
"Bad message: we only support the short skip list for now. "
147 path.reserve(reply.path_size());
148 for (
int i = 0; i < reply.path_size(); ++i)
150 path.emplace_back(reply.path(i).begin(), reply.path(i).end());
155 JLOG(
journal_.
debug()) <<
"Bad message: Proof path verify failed";
161 if (!node || !node->isLeaf())
173 JLOG(
journal_.
debug()) <<
"Bad message: Cannot get ShaMapItem";
177 protocol::TMReplayDeltaResponse
181 protocol::TMReplayDeltaRequest& packet = *msg;
182 protocol::TMReplayDeltaResponse reply;
184 if (!packet.has_ledgerhash() ||
188 reply.set_error(protocol::TMReplyError::reBAD_REQUEST);
191 reply.set_ledgerhash(packet.ledgerhash());
193 uint256 const ledgerHash{packet.ledgerhash()};
195 if (!ledger || !ledger->isImmutable())
198 <<
"getReplayDelta: Don't have ledger " << ledgerHash;
199 reply.set_error(protocol::TMReplyError::reNO_LEDGER);
205 addRaw(ledger->info(), nData);
208 auto const& txMap = ledger->txMap();
210 [&](boost::intrusive_ptr<SHAMapItem const>
const&
txNode) {
214 JLOG(
journal_.
debug()) <<
"getReplayDelta for ledger " << ledgerHash
215 <<
" txMap hash " << txMap.getHash().as_uint256();
223 protocol::TMReplayDeltaResponse& reply = *msg;
224 if (reply.has_error() || !reply.has_ledgerheader())
231 {reply.ledgerheader().data(), reply.ledgerheader().size()});
232 uint256 replyHash(reply.ledgerhash());
238 info.hash = replyHash;
240 auto numTxns = reply.transaction_size();
245 for (
int i = 0; i < numTxns; ++i)
252 reply.transaction(i).data(), reply.transaction(i).size());
258 auto tx = std::make_shared<STTx const>(txSit);
264 auto tid = tx->getTransactionID();
285 JLOG(
journal_.
debug()) <<
"Bad message: Transactions verify failed";