Skip to content

Commit

Permalink
FIX: try-read delay 0.5s for the second try
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbegin authored and qtxie committed Jul 1, 2019
1 parent dd91e17 commit 73dbb94
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
6 changes: 3 additions & 3 deletions keys/keys.red
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,10 @@ keys: context [

either ledger-nano-s? [
BATCH-NUM: 1
set 'network-delay? no
btc/network-delay?: no
][
BATCH-NUM: 10
set 'network-delay? yes
btc/network-delay?: yes
]

list: copy []
Expand Down Expand Up @@ -386,7 +386,7 @@ keys: context [

i: i + 1
]
set 'network-delay? yes
btc/network-delay?: yes
append list reduce ['balance total]
list
]
Expand Down
12 changes: 12 additions & 0 deletions libs/bitcoin.red
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,23 @@ btc: context [
cause-error 'user 'btc-api [name arg2 arg3]
]

network-delay?: yes
top-scalar: to-i256 1e8
btc-to-sat: func [num [vector!] return: [vector!]][
mul256 num top-scalar
]

try-read: func [url][
;-- workaround for speed limitation of some WebAPIs
if network-delay? [
wait 0.5
]
unless error? res: try [read url][return res]
wait 0.5
unless error? res: try [read url][return res]
res
]

get-url: func [url [url!] return: [map!]
/local res res2
][
Expand Down
13 changes: 0 additions & 13 deletions wallet.red
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,6 @@ throw-error: func [msg [string! block!]][

process-events: does [loop 10 [do-events/no-wait]]

network-delay?: yes

try-read: func [url][
;-- workaround for speed limitation of some WebAPIs
loop 2 [
if network-delay? [
wait 0.5
]
unless error? res: try [read url][return res]
]
res
]

#include %libs/int256.red
#include %libs/ethereum.red
#include %libs/bitcoin.red
Expand Down

0 comments on commit 73dbb94

Please sign in to comment.