Browse Source

fix readRaw disconnection issue

master
nitowa 2 years ago
parent
commit
5d2305b4e6
3 changed files with 9 additions and 10 deletions
  1. 1
    1
      package-lock.json
  2. 1
    1
      package.json
  3. 7
    8
      src/xrpIO/ripple-binding.ts

+ 1
- 1
package-lock.json View File

1
 {
1
 {
2
   "name": "xrpio",
2
   "name": "xrpio",
3
-  "version": "0.0.4",
3
+  "version": "0.0.7",
4
   "lockfileVersion": 1,
4
   "lockfileVersion": 1,
5
   "requires": true,
5
   "requires": true,
6
   "dependencies": {
6
   "dependencies": {

+ 1
- 1
package.json View File

1
 {
1
 {
2
   "name": "xrpio",
2
   "name": "xrpio",
3
-  "version": "0.0.7",
3
+  "version": "0.0.8",
4
   "repository": {
4
   "repository": {
5
     "type": "git",
5
     "type": "git",
6
     "url": "https://gitea.nitowa.xyz/npm-packages/xrpio.git"
6
     "url": "https://gitea.nitowa.xyz/npm-packages/xrpio.git"

+ 7
- 8
src/xrpIO/ripple-binding.ts View File

141
 
141
 
142
 
142
 
143
 export const readRaw = async (api: RippleAPI, hash: string): Promise<Memo> => {
143
 export const readRaw = async (api: RippleAPI, hash: string): Promise<Memo> => {
144
-  let _api
145
-  if(!api.isConnected()){
146
-    _api = await cloneApi(api)
147
-  }else{
148
-    _api = api
144
+  while(!api.isConnected()){
145
+    try{
146
+      await api.connect()
147
+    }catch(e){
148
+      //retry
149
+    }
149
   }
150
   }
150
   let tx
151
   let tx
151
   try{
152
   try{
152
-    tx = await _api.getTransaction(hash, {
153
+    tx = await api.getTransaction(hash, {
153
       minLedgerVersion: 25235454
154
       minLedgerVersion: 25235454
154
     })
155
     })
155
   }catch(e){
156
   }catch(e){
157
       console.log("READRAW ERR", e)
158
       console.log("READRAW ERR", e)
158
       throw e
159
       throw e
159
     }
160
     }
160
-  }finally{
161
-    await _api.disconnect()
162
   }
161
   }
163
 
162
 
164
   if (!tx || !tx.specification || !tx.specification['memos'] || !tx.specification['memos'][0]) {
163
   if (!tx || !tx.specification || !tx.specification['memos'] || !tx.specification['memos'][0]) {

Loading…
Cancel
Save