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>
24 #include <ripple/protocol/LedgerHeader.h>
34 , journal_(app.journal(
"LedgerReplayMsgHandler"))
38 protocol::TMProofPathResponse
42 protocol::TMProofPathRequest& packet = *msg;
43 protocol::TMProofPathResponse reply;
45 if (!packet.has_key() || !packet.has_ledgerhash() || !packet.has_type() ||
48 !protocol::TMLedgerMapType_IsValid(packet.type()))
51 reply.set_error(protocol::TMReplyError::reBAD_REQUEST);
54 reply.set_key(packet.key());
55 reply.set_ledgerhash(packet.ledgerhash());
56 reply.set_type(packet.type());
58 uint256 const key(packet.key());
59 uint256 const ledgerHash(packet.ledgerhash());
64 <<
"getProofPath: Don't have ledger " << ledgerHash;
65 reply.set_error(protocol::TMReplyError::reNO_LEDGER);
70 switch (packet.type())
72 case protocol::lmACCOUNT_STATE:
73 return ledger->stateMap().getProofPath(key);
74 case protocol::lmTRANASCTION:
75 return ledger->txMap().getProofPath(key);
85 JLOG(
journal_.
debug()) <<
"getProofPath: Don't have the node " << key
86 <<
" of ledger " << ledgerHash;
87 reply.set_error(protocol::TMReplyError::reNO_NODE);
93 addRaw(ledger->info(), nData);
96 for (
auto const& b : *path)
97 reply.add_path(b.data(), b.size());
100 <<
" of ledger " << ledgerHash <<
" path length "
109 protocol::TMProofPathResponse& reply = *msg;
110 if (reply.has_error() || !reply.has_key() || !reply.has_ledgerhash() ||
111 !reply.has_type() || !reply.has_ledgerheader() ||
112 reply.path_size() == 0)
118 if (reply.type() != protocol::lmACCOUNT_STATE)
121 <<
"Bad message: we only support the state ShaMap for now";
127 {reply.ledgerheader().data(), reply.ledgerheader().size()});
128 uint256 replyHash(reply.ledgerhash());
134 info.hash = replyHash;
140 <<
"Bad message: we only support the short skip list for now. "
148 path.reserve(reply.path_size());
149 for (
int i = 0; i < reply.path_size(); ++i)
151 path.emplace_back(reply.path(i).begin(), reply.path(i).end());
156 JLOG(
journal_.
debug()) <<
"Bad message: Proof path verify failed";
162 if (!node || !node->isLeaf())
174 JLOG(
journal_.
debug()) <<
"Bad message: Cannot get ShaMapItem";
178 protocol::TMReplayDeltaResponse
182 protocol::TMReplayDeltaRequest& packet = *msg;
183 protocol::TMReplayDeltaResponse reply;
185 if (!packet.has_ledgerhash() ||
189 reply.set_error(protocol::TMReplyError::reBAD_REQUEST);
192 reply.set_ledgerhash(packet.ledgerhash());
194 uint256 const ledgerHash{packet.ledgerhash()};
196 if (!ledger || !ledger->isImmutable())
199 <<
"getReplayDelta: Don't have ledger " << ledgerHash;
200 reply.set_error(protocol::TMReplyError::reNO_LEDGER);
206 addRaw(ledger->info(), nData);
209 auto const& txMap = ledger->txMap();
211 [&](boost::intrusive_ptr<SHAMapItem const>
const&
txNode) {
215 JLOG(
journal_.
debug()) <<
"getReplayDelta for ledger " << ledgerHash
216 <<
" txMap hash " << txMap.getHash().as_uint256();
224 protocol::TMReplayDeltaResponse& reply = *msg;
225 if (reply.has_error() || !reply.has_ledgerheader())
232 {reply.ledgerheader().data(), reply.ledgerheader().size()});
233 uint256 replyHash(reply.ledgerhash());
239 info.hash = replyHash;
241 auto numTxns = reply.transaction_size();
246 for (
int i = 0; i < numTxns; ++i)
253 reply.transaction(i).data(), reply.transaction(i).size());
259 auto tx = std::make_shared<STTx const>(txSit);
265 auto tid = tx->getTransactionID();
286 JLOG(
journal_.
debug()) <<
"Bad message: Transactions verify failed";