stellar_spectrum 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a03e0f25c992788e8b3f4b13713ab69d23331e3194bd5e61f2e53550c3226df9
4
- data.tar.gz: cceb241d7e1f988857ee682e81f1a56f41f02af198d200d685f378a7e8c1594a
3
+ metadata.gz: e42c3edaf38084503ffb4be0c4c8444b8c1ccbe26ecd5ac15736d7dad7f07cf2
4
+ data.tar.gz: 6c5fadae0a06979888c64b06147299fcf563a01d58a317b3a2df968e0d8c79df
5
5
  SHA512:
6
- metadata.gz: bac931885f03c9ee063ab57e164c642f707e5d5498eef5ba3db341692f9db17b0aceb161b7f240a3434a5385969d59dfa34d2524cbe0a4087026ae1730ba91a5
7
- data.tar.gz: 1aec0f8499eddc6698df89fdf6792a7135d288d30029706bad79a782dac7c1a8bb6dbc81738a01cbeb32cb57de6a5efd6b739af2d117bc705dec1cfb64a26361
6
+ metadata.gz: 13e82996a13fc2a5a47fdc8a7be91fc7c0f87280ab081339e044ea8c214cd38c6a2182af95b0ed4f780e0285860cf8055454903c48abc49971f948d46bef3f8f
7
+ data.tar.gz: 012a52068e0d1883749dcfc333770713472e21fbfd2ad32a34d4d83d5fd65777bfbaf6b91bf27a3ec8771ae1dea8e53332bea7e148111da3e293e666d670b8fe
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [1.3.1] - 2019-02-16
8
+ ### Fixed
9
+ - During retry, do not sleep more than the max lock time
10
+
7
11
  ## [1.3.0] - 2019-01-29
8
12
  ### Fixed
9
13
  - Do not retry forever (and hitting the stack limit)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stellar_spectrum (1.3.0)
4
+ stellar_spectrum (1.3.1)
5
5
  activesupport
6
6
  gem_config
7
7
  light-service
@@ -38,7 +38,7 @@ GEM
38
38
  net-http-digest_auth (~> 1.4)
39
39
  faraday_hal_middleware (0.1.0)
40
40
  faraday_middleware (~> 0.9)
41
- faraday_middleware (0.13.0)
41
+ faraday_middleware (0.13.1)
42
42
  faraday (>= 0.7.4, < 1.0)
43
43
  ffi (1.10.0)
44
44
  gem_config (0.3.1)
@@ -25,6 +25,7 @@ require "stellar_spectrum/services/send_payment"
25
25
  require "stellar_spectrum/services/sending_payment/attempt_release_lock"
26
26
  require "stellar_spectrum/services/sending_payment/retry"
27
27
  require "stellar_spectrum/services/sending_payment/send_asset"
28
+ require "stellar_spectrum/services/sending_payment/get_sleep_for_retry"
28
29
  require "stellar_spectrum/services/unlocking/attempt_release"
29
30
  require "stellar_spectrum/services/unlocking/check_sequence_number"
30
31
  require "stellar_spectrum/services/unlocking/unlock"
@@ -0,0 +1,16 @@
1
+ module StellarSpectrum
2
+ module SendingPayment
3
+ class GetSleepForRetry
4
+
5
+ MAX = Client::MAX_LOCK_TIME_IN_SECONDS
6
+ LEEWAY = 5.freeze
7
+
8
+ def self.call(n)
9
+ fibo = Fibo.(n)
10
+ return fibo if fibo < MAX
11
+ MAX - LEEWAY
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -20,7 +20,7 @@ module StellarSpectrum
20
20
  promises :send_asset_response
21
21
 
22
22
  executed do |c|
23
- sleep Fibo.(c.tries)
23
+ sleep GetSleepForRetry.(c.tries)
24
24
 
25
25
  args = EXPECTS.each_with_object({}) do |attr, hash|
26
26
  hash[attr] = c.send(attr)
@@ -34,7 +34,7 @@ module StellarSpectrum
34
34
  # fail_and_return for now until we figure out a way to stop all actions
35
35
  # from reduce_if
36
36
  # See https://github.com/adomokos/light-service/pull/164
37
- message = "Closing try #{c.tries}"
37
+ message = "Closing #{c.tries.ordinalize} try"
38
38
  c.fail_and_return! message
39
39
  end
40
40
 
@@ -30,9 +30,19 @@ module StellarSpectrum
30
30
  sequence: c.next_sequence_number,
31
31
  )
32
32
  rescue Faraday::ClientError => e
33
- fail if c.tries >= StellarSpectrum.configuration.max_tries
33
+ max_tries = StellarSpectrum.configuration.max_tries
34
+ if c.tries >= max_tries
35
+ Log.warn(
36
+ "Surpassed maximum number of tries of #{max_tries}, " \
37
+ "stop retrying"
38
+ )
39
+ fail
40
+ end
34
41
 
35
- Log.warn("Retrying SendingPayment::SendAsset - #{e.inspect}")
42
+ Log.warn(
43
+ "Retrying (#{c.tries.ordinalize} time) " \
44
+ "SendingPayment::SendAsset - #{e.inspect}"
45
+ )
36
46
  retry_result = Retry.execute(
37
47
  stellar_client: c.stellar_client,
38
48
  from: c.from,
@@ -1,3 +1,3 @@
1
1
  module StellarSpectrum
2
- VERSION = "1.3.0"
2
+ VERSION = "1.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stellar_spectrum
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ramon Tayag
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-01-29 00:00:00.000000000 Z
12
+ date: 2019-02-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -191,6 +191,7 @@ files:
191
191
  - lib/stellar_spectrum/services/pick_channel.rb
192
192
  - lib/stellar_spectrum/services/send_payment.rb
193
193
  - lib/stellar_spectrum/services/sending_payment/attempt_release_lock.rb
194
+ - lib/stellar_spectrum/services/sending_payment/get_sleep_for_retry.rb
194
195
  - lib/stellar_spectrum/services/sending_payment/retry.rb
195
196
  - lib/stellar_spectrum/services/sending_payment/send_asset.rb
196
197
  - lib/stellar_spectrum/services/unlocking/attempt_release.rb
@@ -222,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
223
  version: '0'
223
224
  requirements: []
224
225
  rubyforge_project:
225
- rubygems_version: 2.7.7
226
+ rubygems_version: 2.7.8
226
227
  signing_key:
227
228
  specification_version: 4
228
229
  summary: Use Stellar payment channels in Ruby with ease