universa 3.9.14.5 → 3.9.14.7
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/lib/universa/client.rb +29 -6
- data/lib/universa/fs_store/entry.rb +1 -1
- data/lib/universa/stored_contract.rb +3 -1
- data/lib/universa/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa4b8c59d86810948f6b69236fcb0ec642c88c7281a6994935ffed57d7e9c6e6
|
4
|
+
data.tar.gz: b547a7d4fd353a29c01aafa6ac8d4c7e4a74f284cffb570294878f85fdfa3fdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f5f308c6b089b97635dd2eeb3f9136efccbd40077d19084e49a0b7ae71348e4b767cdcd3e915096df9a816d88a1d8c068958205d9a947fc20d7d3c7761d67b1
|
7
|
+
data.tar.gz: 4fb19404da64e8e87d3215207c2c38c29a3c66d14479ecf89ea958170ff6fab59ce14ab7685368c489d0635de388ba0e71979b596a8fa2fbbe81c23641c33228
|
data/lib/universa/client.rb
CHANGED
@@ -67,14 +67,37 @@ module Universa
|
|
67
67
|
(0...size).to_a.sample(number).map {|n| self[n]}
|
68
68
|
end
|
69
69
|
|
70
|
-
# Perform fast consensus state check with a given trust level,
|
71
|
-
#
|
72
|
-
# trust level is, the faster the answer will be found.
|
70
|
+
# Perform fast consensus state check with a given trust level, determining whether the item is approved or not.
|
71
|
+
# Blocks for 1 minute or until the network solution will be collected for a given trust level.
|
73
72
|
#
|
74
|
-
# @param [Contract | HashId] obj contract to check
|
73
|
+
# @param [Contract | HashId | String | Binary] obj contract to check
|
75
74
|
# @param [Object] trust level, should be between 0.1 (10% of network) and 0.9 (90% of the network)
|
76
|
-
# @return
|
77
|
-
def
|
75
|
+
# @return true if the contract state is approved by the network with a given trust level, false otherwise.
|
76
|
+
def is_approved? obj, trust: 0.3
|
77
|
+
hash_id = case obj
|
78
|
+
when HashId
|
79
|
+
obj
|
80
|
+
when Contract
|
81
|
+
obj.hash_id
|
82
|
+
when String
|
83
|
+
if obj.encoding == Encoding::ASCII_8BIT
|
84
|
+
HashId.from_digest(obj)
|
85
|
+
else
|
86
|
+
HashId.from_string(obj)
|
87
|
+
end
|
88
|
+
else
|
89
|
+
raise ArgumentError "wrong type of object to check approval"
|
90
|
+
end
|
91
|
+
@client.isApprovedByNetwork(hash_id, trust.to_f, 60000)
|
92
|
+
end
|
93
|
+
# Perform fast consensus state check with a given trust level, as the fraction of the whole network size.
|
94
|
+
# It checks the network nodes randomly until get enough positive or negative states. The lover the required
|
95
|
+
# trust level is, the faster the answer will be found.
|
96
|
+
#
|
97
|
+
# @param [Contract | HashId] obj contract to check
|
98
|
+
# @param [Object] trust level, should be between 0.1 (10% of network) and 0.9 (90% of the network)
|
99
|
+
# @return [ContractState] of some final node check It does not calculates average time (yet)
|
100
|
+
def get_state obj, trust: 0.3
|
78
101
|
raise ArgumentError, "trusst must be in 0.1..0.9 range" if trust < 0.1 || trust > 0.9
|
79
102
|
result = Concurrent::IVar.new
|
80
103
|
negative_votes = Concurrent::AtomicFixnum.new((size * 0.1).round + 1)
|
@@ -11,7 +11,7 @@ module Universa::FSStore
|
|
11
11
|
# @!method amount
|
12
12
|
# @return [BigDecimal] +contract.state.data.amount+ or nil. See {Contract#amount} for more.
|
13
13
|
#
|
14
|
-
class Entry < Universa::
|
14
|
+
class Entry < Universa::StoredContractBase
|
15
15
|
|
16
16
|
extend Forwardable
|
17
17
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Universa
|
2
2
|
|
3
|
+
# under construction, pls on not use yet
|
4
|
+
#
|
3
5
|
# this is a base class for a contract stored in some contract chain. The implementation
|
4
6
|
# must inherit and implement its {#load} and {#save} methods at least. To do it,
|
5
7
|
# inherit and implement {ChainStore} to work with it.
|
@@ -9,7 +11,7 @@ module Universa
|
|
9
11
|
# - contract could be assigned only once, no matter how, so its fields could be cached.
|
10
12
|
# - origin, hash_id and parent are cached. So other contract parameters should be.
|
11
13
|
#
|
12
|
-
class
|
14
|
+
class StoredContractBase
|
13
15
|
|
14
16
|
# {ChainStore} instance to which it is connected
|
15
17
|
attr :chain_store
|
data/lib/universa/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: universa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.9.14.
|
4
|
+
version: 3.9.14.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sergeych
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: farcall
|