istox 0.2.14 → 0.2.15.pre.50
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/.rubocop.yml +0 -0
- data/.solargraph.yml +0 -0
- data/CODE_OF_CONDUCT.md +0 -0
- data/Gemfile +0 -0
- data/Gemfile.lock +3 -3
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/lib/istox/constants/error.rb +0 -0
- data/lib/istox/helpers/blockchain_service.rb +3 -0
- data/lib/istox/helpers/f_math.rb +14 -2
- data/lib/istox/helpers/gruf_listener_hook.rb +0 -0
- data/lib/istox/helpers/my_open_struct.rb +0 -0
- data/lib/istox/helpers/race_condition_helper.rb +15 -1
- data/lib/istox/helpers/rate_limit.rb +0 -0
- data/lib/istox/helpers/regex_helper.rb +0 -0
- data/lib/istox/helpers/result_handler.rb +0 -0
- data/lib/istox/helpers/vault.rb +0 -0
- data/lib/istox/interfaces/chainhub/transaction.rb +0 -0
- data/lib/istox/models/blockchain_receipt.rb +2 -0
- data/lib/istox/models/concerns/blockchain_receipt_query.rb +0 -0
- data/lib/istox/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0756458578f3bf4fdd2a7cef528e51c741a2858f9c4208eea69a74768639ad8c'
|
4
|
+
data.tar.gz: 736d38e168557939cd3649673817d07b47139278fd32e68473316c44bc0cc37f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 708a1326e1abe667a3a3b9303a1ef506f599051e1948b3fb7cfc530dacb263471c359f4e156765e39846b64a2b8c5f883002ed359eacd4d153def6b5273b4da7
|
7
|
+
data.tar.gz: 3eea7531af5cb2c1d7016da222410d31b52d766eaf65105669042feca0e0f7df3a1b7066272ebec0829825c4f96f13e52cd22e297eea82ed7fb08e9e4aa7682a
|
data/.gitignore
CHANGED
File without changes
|
data/.rubocop.yml
CHANGED
File without changes
|
data/.solargraph.yml
CHANGED
File without changes
|
data/CODE_OF_CONDUCT.md
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
istox (0.2.
|
4
|
+
istox (0.2.15)
|
5
5
|
amazing_print
|
6
6
|
awesome_print
|
7
7
|
aws-sdk-sns (~> 1)
|
@@ -134,7 +134,7 @@ GEM
|
|
134
134
|
ffi (1.15.3)
|
135
135
|
globalid (0.4.2)
|
136
136
|
activesupport (>= 4.2.0)
|
137
|
-
google-protobuf (3.17.3)
|
137
|
+
google-protobuf (3.17.3-universal-darwin)
|
138
138
|
googleapis-common-protos-types (1.1.0)
|
139
139
|
google-protobuf (~> 3.14)
|
140
140
|
graphlient (0.5.0)
|
@@ -145,7 +145,7 @@ GEM
|
|
145
145
|
graphql-client (0.16.0)
|
146
146
|
activesupport (>= 3.0)
|
147
147
|
graphql (~> 1.8)
|
148
|
-
grpc (1.38.0)
|
148
|
+
grpc (1.38.0-universal-darwin)
|
149
149
|
google-protobuf (~> 3.15)
|
150
150
|
googleapis-common-protos-types (~> 1.0)
|
151
151
|
grpc-tools (1.38.0)
|
data/README.md
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
File without changes
|
@@ -44,6 +44,9 @@ module Istox
|
|
44
44
|
## for request there we need a lock to prevent there is not duplicate request exist for single model
|
45
45
|
::Istox::RaceConditionHelper.acquire!(key) if is_request
|
46
46
|
|
47
|
+
## validate the request, this validation is overridable by inherited class
|
48
|
+
receipt.validate_request!(model.class.name, model.id) if is_request
|
49
|
+
|
47
50
|
# delete the previous existing blockchain receipts
|
48
51
|
klass.where(resource_name: model.class.name, resource_id: model.id).destroy_all
|
49
52
|
|
data/lib/istox/helpers/f_math.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# rubocop:disable Naming/UncommunicativeMethodParamName
|
2
1
|
module Istox
|
3
2
|
class FMath
|
4
3
|
class << self
|
@@ -74,6 +73,20 @@ module Istox
|
|
74
73
|
::BigDecimal.new(x.to_s).round(digits).to_s
|
75
74
|
end
|
76
75
|
|
76
|
+
def round_half_up(x, digits)
|
77
|
+
BigDecimal.mode(BigDecimal::ROUND_MODE, :half_up)
|
78
|
+
x = 0 if x.blank?
|
79
|
+
::BigDecimal.new(x.to_s).round(digits).to_s
|
80
|
+
end
|
81
|
+
|
82
|
+
def round(x, digits, rounding_mechanism: :natural)
|
83
|
+
return round_up(x, digits) if rounding_mechanism == 'up'
|
84
|
+
|
85
|
+
return round_down(x, digits) if rounding_mechanism == 'down'
|
86
|
+
|
87
|
+
round_half_up(x, digits)
|
88
|
+
end
|
89
|
+
|
77
90
|
private
|
78
91
|
|
79
92
|
def to_fixed(x)
|
@@ -86,4 +99,3 @@ module Istox
|
|
86
99
|
end
|
87
100
|
end
|
88
101
|
end
|
89
|
-
# rubocop:enable Naming/UncommunicativeMethodParamName
|
File without changes
|
File without changes
|
@@ -10,12 +10,26 @@ module Istox
|
|
10
10
|
def acquire(key, expired_seconds: 20)
|
11
11
|
result = request_redis.set('race-condition||' + key.to_s, 'EMPTY', nx: true, ex: expired_seconds.to_i.seconds)
|
12
12
|
|
13
|
+
log.info("Acquiring lock for key: #{key}, expired in #{expired_seconds} seconds, result: #{result}")
|
14
|
+
|
13
15
|
# if result false means the key already exist
|
14
|
-
result
|
16
|
+
[true, 1].include?(result)
|
15
17
|
end
|
16
18
|
|
17
19
|
def release(key)
|
18
20
|
request_redis.del('race-condition||' + key.to_s)
|
21
|
+
|
22
|
+
log.info("Releasing lock for key: #{key}")
|
23
|
+
end
|
24
|
+
|
25
|
+
### lock with block
|
26
|
+
def lock!(key, expired_seconds: 20)
|
27
|
+
acquire!(key, expired_seconds: expired_seconds)
|
28
|
+
yield
|
29
|
+
release(key)
|
30
|
+
rescue StandardError => e
|
31
|
+
release(key)
|
32
|
+
raise e
|
19
33
|
end
|
20
34
|
|
21
35
|
def request_redis
|
File without changes
|
File without changes
|
File without changes
|
data/lib/istox/helpers/vault.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/lib/istox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: istox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.15.pre.50
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Siong Leng
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: amazing_print
|
@@ -530,11 +530,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
530
530
|
version: '0'
|
531
531
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
532
532
|
requirements:
|
533
|
-
- - "
|
533
|
+
- - ">"
|
534
534
|
- !ruby/object:Gem::Version
|
535
|
-
version:
|
535
|
+
version: 1.3.1
|
536
536
|
requirements: []
|
537
|
-
rubygems_version: 3.
|
537
|
+
rubygems_version: 3.2.11
|
538
538
|
signing_key:
|
539
539
|
specification_version: 4
|
540
540
|
summary: istox backend shared gem
|