Sfoglia il codice sorgente

fix readRaw disconnection issue

master
nitowa 2 anni fa
parent
commit
5d2305b4e6
3 ha cambiato i file con 9 aggiunte e 10 eliminazioni
  1. 1
    1
      package-lock.json
  2. 1
    1
      package.json
  3. 7
    8
      src/xrpIO/ripple-binding.ts

+ 1
- 1
package-lock.json Vedi File

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

+ 1
- 1
package.json Vedi File

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

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

@@ -141,15 +141,16 @@ export const writeRaw = async (api: RippleAPI, data: Memo, from:
141 141
 
142 142
 
143 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 151
   let tx
151 152
   try{
152
-    tx = await _api.getTransaction(hash, {
153
+    tx = await api.getTransaction(hash, {
153 154
       minLedgerVersion: 25235454
154 155
     })
155 156
   }catch(e){
@@ -157,8 +158,6 @@ export const readRaw = async (api: RippleAPI, hash: string): Promise<Memo> => {
157 158
       console.log("READRAW ERR", e)
158 159
       throw e
159 160
     }
160
-  }finally{
161
-    await _api.disconnect()
162 161
   }
163 162
 
164 163
   if (!tx || !tx.specification || !tx.specification['memos'] || !tx.specification['memos'][0]) {

Loading…
Annulla
Salva