Ver código fonte

fix readRaw disconnection issue

master
nitowa 2 anos atrás
pai
commit
5d2305b4e6
3 arquivos alterados com 9 adições e 10 exclusões
  1. 1
    1
      package-lock.json
  2. 1
    1
      package.json
  3. 7
    8
      src/xrpIO/ripple-binding.ts

+ 1
- 1
package-lock.json Ver arquivo

@@ -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 Ver arquivo

@@ -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 Ver arquivo

@@ -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]) {

Carregando…
Cancelar
Salvar