fix readRaw disconnection issue

This commit is contained in:
nitowa
2022-02-12 22:18:55 +01:00
parent 37948df6f7
commit 5d2305b4e6
3 changed files with 9 additions and 10 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "xrpio", "name": "xrpio",
"version": "0.0.4", "version": "0.0.7",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "xrpio", "name": "xrpio",
"version": "0.0.7", "version": "0.0.8",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://gitea.nitowa.xyz/npm-packages/xrpio.git" "url": "https://gitea.nitowa.xyz/npm-packages/xrpio.git"
+7 -8
View File
@@ -141,15 +141,16 @@ export const writeRaw = async (api: RippleAPI, data: Memo, from:
export const readRaw = async (api: RippleAPI, hash: string): Promise<Memo> => { export const readRaw = async (api: RippleAPI, hash: string): Promise<Memo> => {
let _api while(!api.isConnected()){
if(!api.isConnected()){ try{
_api = await cloneApi(api) await api.connect()
}else{ }catch(e){
_api = api //retry
}
} }
let tx let tx
try{ try{
tx = await _api.getTransaction(hash, { tx = await api.getTransaction(hash, {
minLedgerVersion: 25235454 minLedgerVersion: 25235454
}) })
}catch(e){ }catch(e){
@@ -157,8 +158,6 @@ export const readRaw = async (api: RippleAPI, hash: string): Promise<Memo> => {
console.log("READRAW ERR", e) console.log("READRAW ERR", e)
throw e throw e
} }
}finally{
await _api.disconnect()
} }
if (!tx || !tx.specification || !tx.specification['memos'] || !tx.specification['memos'][0]) { if (!tx || !tx.specification || !tx.specification['memos'] || !tx.specification['memos'][0]) {