|
21 | 21 |
|
22 | 22 | #include "data/BackendInterface.hpp" |
23 | 23 | #include "data/Types.hpp" |
24 | | -#include "etl/ETLService.hpp" |
25 | 24 | #include "etlng/ETLServiceInterface.hpp" |
26 | 25 | #include "rpc/Errors.hpp" |
27 | 26 | #include "rpc/JS.hpp" |
|
39 | 38 | #include <boost/json/value.hpp> |
40 | 39 | #include <boost/json/value_to.hpp> |
41 | 40 | #include <xrpl/basics/base_uint.h> |
| 41 | +#include <xrpl/basics/chrono.h> |
42 | 42 | #include <xrpl/basics/strHex.h> |
43 | 43 | #include <xrpl/protocol/ErrorCodes.h> |
44 | 44 | #include <xrpl/protocol/LedgerHeader.h> |
@@ -214,17 +214,15 @@ class TxHandler { |
214 | 214 | // input.transaction might be not available, get hash via tx object |
215 | 215 | if (txn.contains(JS(hash))) |
216 | 216 | output.hash = txn.at(JS(hash)).as_string(); |
| 217 | + } |
217 | 218 |
|
218 | | - // append ctid here to mimic rippled 1.12 behavior: return ctid even binary=true |
219 | | - // rippled will change it in the future, ctid should be part of tx json which not available in binary |
220 | | - // mode |
221 | | - auto const txnIdx = boost::json::value_to<uint64_t>(meta.at("TransactionIndex")); |
222 | | - if (txnIdx <= 0xFFFFU && dbResponse->ledgerSequence < 0x0FFF'FFFFUL && currentNetId && |
223 | | - *currentNetId <= 0xFFFFU) { |
224 | | - output.ctid = rpc::encodeCTID( |
225 | | - dbResponse->ledgerSequence, static_cast<uint16_t>(txnIdx), static_cast<uint16_t>(*currentNetId) |
226 | | - ); |
227 | | - } |
| 219 | + // append ctid here to mimic rippled behavior |
| 220 | + auto const txnIdx = boost::json::value_to<uint64_t>(meta.at("TransactionIndex")); |
| 221 | + if (txnIdx <= 0xFFFFU && dbResponse->ledgerSequence < 0x0FFF'FFFFUL && currentNetId && |
| 222 | + *currentNetId <= 0xFFFFU) { |
| 223 | + output.ctid = rpc::encodeCTID( |
| 224 | + dbResponse->ledgerSequence, static_cast<uint16_t>(txnIdx), static_cast<uint16_t>(*currentNetId) |
| 225 | + ); |
228 | 226 | } |
229 | 227 |
|
230 | 228 | output.date = dbResponse->date; |
@@ -281,12 +279,10 @@ class TxHandler { |
281 | 279 | if (output.tx) { |
282 | 280 | obj[JS(tx_json)] = *output.tx; |
283 | 281 | obj[JS(tx_json)].as_object()[JS(date)] = output.date; |
| 282 | + if (output.ctid) |
| 283 | + obj[JS(tx_json)].as_object()[JS(ctid)] = *output.ctid; |
| 284 | + |
284 | 285 | obj[JS(tx_json)].as_object()[JS(ledger_index)] = output.ledgerIndex; |
285 | | - // move ctid from tx_json to root |
286 | | - if (obj[JS(tx_json)].as_object().contains(JS(ctid))) { |
287 | | - obj[JS(ctid)] = obj[JS(tx_json)].as_object()[JS(ctid)]; |
288 | | - obj[JS(tx_json)].as_object().erase(JS(ctid)); |
289 | | - } |
290 | 286 | // move hash from tx_json to root |
291 | 287 | if (obj[JS(tx_json)].as_object().contains(JS(hash))) { |
292 | 288 | obj[JS(hash)] = obj[JS(tx_json)].as_object()[JS(hash)]; |
|
0 commit comments