diff --git a/handlers/Ledger.cpp b/handlers/Ledger.cpp index 96dd3e83..b03a8920 100644 --- a/handlers/Ledger.cpp +++ b/handlers/Ledger.cpp @@ -1,21 +1,5 @@ #include #include -std::vector -ledgerInfoToBlob(ripple::LedgerInfo const& info) -{ - ripple::Serializer s; - s.add32(info.seq); - s.add64(info.drops.drops()); - s.addBitString(info.parentHash); - s.addBitString(info.txHash); - s.addBitString(info.accountHash); - s.add32(info.parentCloseTime.time_since_epoch().count()); - s.add32(info.closeTime.time_since_epoch().count()); - s.add8(info.closeTimeResolution.count()); - s.add8(info.closeFlags); - // s.addBitString(info.hash); - return s.peekData(); -} boost::json::object doLedger(boost::json::object const& request, BackendInterface const& backend) diff --git a/handlers/RPCHelpers.cpp b/handlers/RPCHelpers.cpp index 77e0f997..191c6790 100644 --- a/handlers/RPCHelpers.cpp +++ b/handlers/RPCHelpers.cpp @@ -80,3 +80,19 @@ ledgerSequenceFromRequest( return request.at("ledger_index").as_int64(); } } +std::vector +ledgerInfoToBlob(ripple::LedgerInfo const& info) +{ + ripple::Serializer s; + s.add32(info.seq); + s.add64(info.drops.drops()); + s.addBitString(info.parentHash); + s.addBitString(info.txHash); + s.addBitString(info.accountHash); + s.add32(info.parentCloseTime.time_since_epoch().count()); + s.add32(info.closeTime.time_since_epoch().count()); + s.add8(info.closeTimeResolution.count()); + s.add8(info.closeFlags); + s.addBitString(info.hash); + return s.peekData(); +} diff --git a/handlers/RPCHelpers.h b/handlers/RPCHelpers.h index f07bf3ef..d3c5c26e 100644 --- a/handlers/RPCHelpers.h +++ b/handlers/RPCHelpers.h @@ -24,5 +24,7 @@ std::optional ledgerSequenceFromRequest( boost::json::object const& request, BackendInterface const& backend); +std::vector +ledgerInfoToBlob(ripple::LedgerInfo const& info); #endif diff --git a/reporting/BackendIndexer.cpp b/reporting/BackendIndexer.cpp index 1cf19ce4..af0f49bd 100644 --- a/reporting/BackendIndexer.cpp +++ b/reporting/BackendIndexer.cpp @@ -16,6 +16,7 @@ BackendIndexer::~BackendIndexer() std::unique_lock lck(mutex_); work_.reset(); ioThread_.join(); + updateThread_.join(); } void BackendIndexer::writeLedgerObject( diff --git a/reporting/Pg.cpp b/reporting/Pg.cpp index 4966b6b8..9f61df1e 100644 --- a/reporting/Pg.cpp +++ b/reporting/Pg.cpp @@ -52,7 +52,7 @@ static void noticeReceiver(void* arg, PGresult const* res) { - BOOST_LOG_TRIVIAL(debug) << "server message: " << PQresultErrorMessage(res); + BOOST_LOG_TRIVIAL(trace) << "server message: " << PQresultErrorMessage(res); } //----------------------------------------------------------------------------- diff --git a/reporting/PostgresBackend.cpp b/reporting/PostgresBackend.cpp index 799ae715..d6bae3c1 100644 --- a/reporting/PostgresBackend.cpp +++ b/reporting/PostgresBackend.cpp @@ -846,7 +846,11 @@ PostgresBackend::writeKeys( } } if (isAsync) + { + if (numRows > 0) + conn.bulkInsert("keys", buffer.str()); conn("COMMIT"); + } return true; } bool @@ -890,7 +894,11 @@ PostgresBackend::writeBooks( } } if (isAsync) + { + if (numRows > 0) + conn.bulkInsert("books", buffer.str()); conn("COMMIT"); + } return true; } bool diff --git a/test.py b/test.py index 7c5aa898..72d296ab 100755 --- a/test.py +++ b/test.py @@ -729,7 +729,7 @@ async def ledger(ip, port, ledger, binary, transactions, expand): async with websockets.connect(address,max_size=1000000000) as ws: await ws.send(json.dumps({"command":"ledger","ledger_index":int(ledger),"binary":bool(binary), "transactions":bool(transactions),"expand":bool(expand)})) res = json.loads(await ws.recv()) - #print(json.dumps(res,indent=4,sort_keys=True)) + print(json.dumps(res,indent=4,sort_keys=True)) return res except websockets.exceptions.connectionclosederror as e: