mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-20 03:35:55 +00:00
don't publish stale data
This commit is contained in:
@@ -120,4 +120,6 @@ uint256ToString(ripple::uint256 const& uint)
|
||||
{
|
||||
return {reinterpret_cast<const char*>(uint.data()), uint.size()};
|
||||
}
|
||||
|
||||
static constexpr uint32_t rippleEpochStart = 946684800;
|
||||
#endif
|
||||
|
||||
@@ -658,11 +658,22 @@ ReportingETL::runETLPipeline(uint32_t startSequence, int numExtractors)
|
||||
// success is false if the ledger was already written
|
||||
if (success)
|
||||
{
|
||||
/*
|
||||
boost::asio::post(publishStrand_, [this, lgrInfo = lgrInfo]() {
|
||||
publishLedger(lgrInfo);
|
||||
});
|
||||
*/
|
||||
auto now =
|
||||
std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch())
|
||||
.count();
|
||||
auto closeTime = lgrInfo.closeTime.time_since_epoch().count();
|
||||
auto age = now - (rippleEpochStart + closeTime);
|
||||
// if the ledger closed over 10 seconds ago, assume we are still
|
||||
// catching up and don't publish
|
||||
if (age < 10)
|
||||
{
|
||||
boost::asio::post(
|
||||
publishStrand_, [this, lgrInfo = lgrInfo]() {
|
||||
publishLedger(lgrInfo);
|
||||
});
|
||||
}
|
||||
|
||||
backend_->updateRange(lgrInfo.seq);
|
||||
lastPublishedSequence = lgrInfo.seq;
|
||||
}
|
||||
|
||||
12
test.py
12
test.py
@@ -825,17 +825,7 @@ async def subscribe(ip, port):
|
||||
address = 'ws://' + str(ip) + ':' + str(port)
|
||||
try:
|
||||
async with websockets.connect(address) as ws:
|
||||
await ws.send(json.dumps({"command":"server_info"}));
|
||||
print(json.loads(await ws.recv()))
|
||||
await ws.send(json.dumps({"command":"server_info"}));
|
||||
print(json.loads(await ws.recv()))
|
||||
await ws.send(json.dumps({"command":"server_info"}));
|
||||
await ws.send(json.dumps({"command":"server_info"}));
|
||||
await ws.send(json.dumps({"command":"server_info"}));
|
||||
print(json.loads(await ws.recv()))
|
||||
print(json.loads(await ws.recv()))
|
||||
print(json.loads(await ws.recv()))
|
||||
await ws.send(json.dumps({"command":"subscribe","streams":["ledger"],"books":[{"snapshot":True,"taker_pays":{"currency":"XRP"},"taker_gets":{"currency":"USD","issuer":"rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq"}}]}))
|
||||
await ws.send(json.dumps({"command":"subscribe","streams":["ledger"]}))
|
||||
#await ws.send(json.dumps({"command":"subscribe","streams":["manifests"]}))
|
||||
while True:
|
||||
res = json.loads(await ws.recv())
|
||||
|
||||
Reference in New Issue
Block a user