fix readRaw disconnecting

This commit is contained in:
nitowa
2022-02-12 23:36:07 +01:00
parent ad9fd09f91
commit ca8498707b
2 changed files with 20 additions and 24 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "xrpio", "name": "xrpio",
"version": "0.0.9", "version": "0.0.10",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://gitea.nitowa.xyz/npm-packages/xrpio.git" "url": "https://gitea.nitowa.xyz/npm-packages/xrpio.git"
+3 -7
View File
@@ -141,13 +141,7 @@ 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> => {
while(!api.isConnected()){ api = await cloneApi(api)
try{
await api.connect()
}catch(e){
//retry
}
}
let tx let tx
try { try {
tx = await api.getTransaction(hash, { tx = await api.getTransaction(hash, {
@@ -158,6 +152,8 @@ 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]) {