mirror of
https://github.com/XRPLF/clio.git
synced 2025-12-01 17:15:52 +00:00
fix cursor issue with account_tx stored procedure
This commit is contained in:
@@ -901,8 +901,8 @@ BEGIN
|
||||
_tally := _tally + 1;
|
||||
IF _tally > _in_limit THEN
|
||||
_ret_marker := jsonb_build_object(
|
||||
'ledger', _record.ledger_seq,
|
||||
'seq', _record.transaction_index);
|
||||
'ledger_sequence', _record.ledger_seq,
|
||||
'transaction_index', _record.transaction_index);
|
||||
EXIT;
|
||||
END IF;
|
||||
|
||||
|
||||
@@ -572,10 +572,19 @@ PostgresBackend::fetchAccountTransactions(
|
||||
if (hash.parseHex(hashHex.at("hash").as_string().c_str() + 2))
|
||||
hashes.push_back(hash);
|
||||
}
|
||||
if (responseObj.contains("cursor"))
|
||||
{
|
||||
return {
|
||||
fetchTransactions(hashes),
|
||||
{{responseObj.at("cursor").at("ledger_sequence").as_int64(),
|
||||
responseObj.at("cursor")
|
||||
.at("transaction_index")
|
||||
.as_int64()}}};
|
||||
}
|
||||
return {fetchTransactions(hashes), {}};
|
||||
}
|
||||
return {{}, {}};
|
||||
}
|
||||
} // namespace Backend
|
||||
|
||||
void
|
||||
PostgresBackend::open()
|
||||
|
||||
12
test.py
12
test.py
@@ -137,7 +137,6 @@ def getMinAndMax(res):
|
||||
minSeq = None
|
||||
maxSeq = None
|
||||
for x in res["transactions"]:
|
||||
print(x)
|
||||
seq = None
|
||||
if "ledger_sequence" in x:
|
||||
seq = int(x["ledger_sequence"])
|
||||
@@ -162,6 +161,7 @@ async def account_tx(ip, port, account, binary, minLedger=None, maxLedger=None):
|
||||
|
||||
res = json.loads(await ws.recv())
|
||||
print(json.dumps(res,indent=4,sort_keys=True))
|
||||
print(res["cursor"])
|
||||
return res
|
||||
except websockets.exceptions.ConnectionClosedError as e:
|
||||
print(e)
|
||||
@@ -184,6 +184,7 @@ async def account_tx_full(ip, port, account, binary,minLedger=None, maxLedger=No
|
||||
if minLedger is not None and maxLedger is not None:
|
||||
req["ledger_index_min"] = minLedger
|
||||
req["ledger_index_max"] = maxLedger
|
||||
print(req)
|
||||
await ws.send(json.dumps(req))
|
||||
res = json.loads(await ws.recv())
|
||||
#print(json.dumps(res,indent=4,sort_keys=True))
|
||||
@@ -202,8 +203,10 @@ async def account_tx_full(ip, port, account, binary,minLedger=None, maxLedger=No
|
||||
marker={"ledger":res["result"]["marker"]["ledger"],"seq":res["result"]["marker"]["seq"]}
|
||||
print(marker)
|
||||
else:
|
||||
print(res)
|
||||
break
|
||||
if numCalls > numPages:
|
||||
print("breaking")
|
||||
break
|
||||
return results
|
||||
except websockets.exceptions.ConnectionClosedError as e:
|
||||
@@ -615,10 +618,17 @@ def run(args):
|
||||
|
||||
res = asyncio.get_event_loop().run_until_complete(tx(args.ip,args.port,args.hash,False))
|
||||
args.account = res["transaction"]["Account"]
|
||||
print("starting")
|
||||
res = asyncio.get_event_loop().run_until_complete(
|
||||
account_tx_full(args.ip, args.port, args.account, args.binary,None,None,int(args.numPages)))
|
||||
rng = getMinAndMax(res)
|
||||
print(len(res["transactions"]))
|
||||
print(args.account)
|
||||
txs = set()
|
||||
for x in res["transactions"]:
|
||||
txs.add((x["transaction"],x["ledger_sequence"]))
|
||||
print(len(txs))
|
||||
|
||||
if args.verify:
|
||||
print("requesting p2p node")
|
||||
res2 = asyncio.get_event_loop().run_until_complete(
|
||||
|
||||
Reference in New Issue
Block a user