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