stellar_spectrum 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/stellar_spectrum.rb +5 -1
- data/lib/stellar_spectrum/services/get_channel_account_info.rb +23 -0
- data/lib/stellar_spectrum/services/send_payment.rb +1 -1
- data/lib/stellar_spectrum/services/sending_payment/attempt_release_lock.rb +19 -0
- data/lib/stellar_spectrum/services/unlocking/attempt_release.rb +42 -0
- data/lib/stellar_spectrum/services/unlocking/check_sequence_number.rb +25 -0
- data/lib/stellar_spectrum/services/unlocking/unlock.rb +17 -0
- data/lib/stellar_spectrum/version.rb +1 -1
- metadata +6 -2
- data/lib/stellar_spectrum/services/unlock.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15c1e0a0f9aa47c73f9c75d915fa48156c53368f618874fcca352c2fc3724288
|
4
|
+
data.tar.gz: e53e539e65c3e3821c7f23635a255b5e3d9f2c5f6e415dd6f00f96bc1ae58bda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 268a94fefd0608dd5bc0ad71574816b6298713f76e22a9dd648f57fcafca344fe9b9e2cb9c804b448e2f937a8c6d9b4d821b900caceafe545252dff227a227d1
|
7
|
+
data.tar.gz: e098fd73295d499bbe323b30aa9949582abe49901aa9edef2bee8da62f28bb44a2a2de64accda3ea6a17232cd60aed048d01650be40d6b1697d7aca85883c543
|
data/CHANGELOG.md
CHANGED
@@ -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.1.3] - 2018-12-13
|
8
|
+
### Fixed
|
9
|
+
- Check if the sequence number in horizon has bumped up before unlocking
|
10
|
+
|
7
11
|
## [1.1.2] - 2018-12-13
|
8
12
|
### Fixed
|
9
13
|
- Do not blow up if `Faraday::ClientError#response` is nil
|
data/Gemfile.lock
CHANGED
data/lib/stellar_spectrum.rb
CHANGED
@@ -8,6 +8,7 @@ require "active_support/core_ext/hash/except"
|
|
8
8
|
require "active_support/core_ext/object/blank"
|
9
9
|
require 'active_support/core_ext/integer/inflections'
|
10
10
|
require "stellar_spectrum/services/get_available_channels"
|
11
|
+
require "stellar_spectrum/services/get_channel_account_info"
|
11
12
|
require "stellar_spectrum/services/get_channel_accounts"
|
12
13
|
require "stellar_spectrum/services/get_key_for_address"
|
13
14
|
require "stellar_spectrum/services/get_locked_accounts"
|
@@ -18,9 +19,12 @@ require "stellar_spectrum/services/init_stellar_client"
|
|
18
19
|
require "stellar_spectrum/services/lock_channel"
|
19
20
|
require "stellar_spectrum/services/pick_channel"
|
20
21
|
require "stellar_spectrum/services/send_payment"
|
22
|
+
require "stellar_spectrum/services/sending_payment/attempt_release_lock"
|
21
23
|
require "stellar_spectrum/services/sending_payment/retry"
|
22
24
|
require "stellar_spectrum/services/sending_payment/send_asset"
|
23
|
-
require "stellar_spectrum/services/
|
25
|
+
require "stellar_spectrum/services/unlocking/attempt_release"
|
26
|
+
require "stellar_spectrum/services/unlocking/check_sequence_number"
|
27
|
+
require "stellar_spectrum/services/unlocking/unlock"
|
24
28
|
|
25
29
|
module StellarSpectrum
|
26
30
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module StellarSpectrum
|
2
|
+
class GetChannelAccountInfo
|
3
|
+
|
4
|
+
extend LightService::Action
|
5
|
+
expects :locked_accounts, :channel_account
|
6
|
+
promises :channel_account_info, :unlock_response
|
7
|
+
|
8
|
+
executed do |c|
|
9
|
+
c.channel_account_info = c.locked_accounts[c.channel_account.address]
|
10
|
+
|
11
|
+
c.unlock_response = nil
|
12
|
+
next c if c.channel_account_info.present?
|
13
|
+
|
14
|
+
c.unlock_response = true
|
15
|
+
|
16
|
+
message = "#{c.channel_account.address} has been unlocked by some " \
|
17
|
+
"other mechanism like ttl expiration or by something else, " \
|
18
|
+
"so this is a success"
|
19
|
+
c.skip_remaining!(message)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module StellarSpectrum
|
2
|
+
module SendingPayment
|
3
|
+
class AttemptReleaseLock
|
4
|
+
|
5
|
+
extend LightService::Action
|
6
|
+
expects :stellar_client, :redis, :channel_account, :channel_accounts
|
7
|
+
|
8
|
+
executed do |c|
|
9
|
+
Unlocking::AttemptRelease.(
|
10
|
+
stellar_client: c.stellar_client,
|
11
|
+
redis: c.redis,
|
12
|
+
channel_account: c.channel_account,
|
13
|
+
channel_accounts: c.channel_accounts,
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module StellarSpectrum
|
2
|
+
module Unlocking
|
3
|
+
class AttemptRelease
|
4
|
+
|
5
|
+
WAIT_TIME_IN_SECONDS = 5
|
6
|
+
|
7
|
+
extend LightService::Organizer
|
8
|
+
def self.call(redis:, channel_accounts:, channel_account:, stellar_client:)
|
9
|
+
result = with(
|
10
|
+
stellar_client: stellar_client,
|
11
|
+
redis: redis,
|
12
|
+
channel_account: channel_account,
|
13
|
+
channel_accounts: channel_accounts,
|
14
|
+
).reduce(actions)
|
15
|
+
|
16
|
+
if result.failure?
|
17
|
+
puts "Failed to unlock, retry..."
|
18
|
+
sleep WAIT_TIME_IN_SECONDS
|
19
|
+
result = self.(
|
20
|
+
stellar_client: stellar_client,
|
21
|
+
redis: redis,
|
22
|
+
channel_account: channel_account,
|
23
|
+
channel_accounts: channel_accounts,
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
result
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.actions
|
31
|
+
[
|
32
|
+
GetLockedAccounts,
|
33
|
+
GetChannelAccountInfo,
|
34
|
+
GetSequenceNumber,
|
35
|
+
CheckSequenceNumber,
|
36
|
+
Unlock,
|
37
|
+
]
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module StellarSpectrum
|
2
|
+
module Unlocking
|
3
|
+
class CheckSequenceNumber
|
4
|
+
|
5
|
+
extend LightService::Action
|
6
|
+
expects :current_sequence_number, :channel_account, :channel_account_info
|
7
|
+
|
8
|
+
executed do |c|
|
9
|
+
address_sequence_number = c.channel_account_info[:sequence_number].to_i
|
10
|
+
current_sequence_number = c.current_sequence_number
|
11
|
+
|
12
|
+
next c if current_sequence_number >= address_sequence_number
|
13
|
+
|
14
|
+
address = c.channel_account.address
|
15
|
+
|
16
|
+
message = "Not releasing #{address}: sequence number locked at " \
|
17
|
+
"#{address_sequence_number} is > current sequence number " \
|
18
|
+
"#{current_sequence_number}"
|
19
|
+
|
20
|
+
c.fail_and_return! message
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module StellarSpectrum
|
2
|
+
module Unlocking
|
3
|
+
class Unlock
|
4
|
+
|
5
|
+
extend LightService::Action
|
6
|
+
expects :redis, :channel_account
|
7
|
+
promises :unlock_response
|
8
|
+
|
9
|
+
executed do |c|
|
10
|
+
address_key = GetKeyForAddress.execute(c.channel_account.address)
|
11
|
+
puts "Will unlock #{address_key}"
|
12
|
+
c.unlock_response = c.redis.del(address_key)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
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.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ramon Tayag
|
@@ -176,6 +176,7 @@ files:
|
|
176
176
|
- lib/stellar_spectrum.rb
|
177
177
|
- lib/stellar_spectrum/client.rb
|
178
178
|
- lib/stellar_spectrum/services/get_available_channels.rb
|
179
|
+
- lib/stellar_spectrum/services/get_channel_account_info.rb
|
179
180
|
- lib/stellar_spectrum/services/get_channel_accounts.rb
|
180
181
|
- lib/stellar_spectrum/services/get_key_for_address.rb
|
181
182
|
- lib/stellar_spectrum/services/get_locked_accounts.rb
|
@@ -186,9 +187,12 @@ files:
|
|
186
187
|
- lib/stellar_spectrum/services/lock_channel.rb
|
187
188
|
- lib/stellar_spectrum/services/pick_channel.rb
|
188
189
|
- lib/stellar_spectrum/services/send_payment.rb
|
190
|
+
- lib/stellar_spectrum/services/sending_payment/attempt_release_lock.rb
|
189
191
|
- lib/stellar_spectrum/services/sending_payment/retry.rb
|
190
192
|
- lib/stellar_spectrum/services/sending_payment/send_asset.rb
|
191
|
-
- lib/stellar_spectrum/services/
|
193
|
+
- lib/stellar_spectrum/services/unlocking/attempt_release.rb
|
194
|
+
- lib/stellar_spectrum/services/unlocking/check_sequence_number.rb
|
195
|
+
- lib/stellar_spectrum/services/unlocking/unlock.rb
|
192
196
|
- lib/stellar_spectrum/version.rb
|
193
197
|
- stellar_spectrum.gemspec
|
194
198
|
homepage: https://github.com/bloom-solutions/stellar_spectrum-ruby
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module StellarSpectrum
|
2
|
-
class Unlock
|
3
|
-
|
4
|
-
extend LightService::Action
|
5
|
-
expects :redis, :channel_account
|
6
|
-
promises :unlock_response
|
7
|
-
|
8
|
-
executed do |c|
|
9
|
-
address_key = GetKeyForAddress.execute(c.channel_account.address)
|
10
|
-
c.unlock_response = c.redis.del(address_key)
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|