universa 0.2.1 → 0.2.2
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/exe/universa +3 -2
- data/exe/utool +86 -0
- data/lib/universa/client.rb +33 -5
- data/lib/universa/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1f8f12f908c49ce5756071ab22a00025ebc80e302a88dbb19d791a2a2ee0af7
|
4
|
+
data.tar.gz: 0ebfdd822d9e54dff53e5476e14d0efb0efdc19eeecb0ccea7ac2b084f4e9871
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87571212aa8c01d333209a63a0d0357210a794990e9de3461849e6e7e4cca80bcdbcf94fcd026172c18e209018ce2ed2d97d2c384c67c9a8a6a5c4eefc1246f5
|
7
|
+
data.tar.gz: a01b21eea03a9512c36e06f59ca104bbc08a9df01fd1f4bf9bb47ecf2d0b8a4cf36c095afdd3db62fa1d7588e46541f880ed99a650d0f89a0d5b670b27a9ab35
|
data/exe/universa
CHANGED
data/exe/utool
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
|
4
|
+
begin
|
5
|
+
$:.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
|
6
|
+
require 'universa'
|
7
|
+
rescue LoadError => e
|
8
|
+
require 'universa'
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'optparse'
|
12
|
+
|
13
|
+
include Universa
|
14
|
+
|
15
|
+
options = OpenStruct.new
|
16
|
+
options.key_path = "~/.universa/test_access.private.unikey"
|
17
|
+
options.key_password = nil
|
18
|
+
|
19
|
+
opt_parser = OptionParser.new {|opts|
|
20
|
+
opts.banner = "Universa Node tool #{Universa::VERSION}"
|
21
|
+
opts.separator ""
|
22
|
+
|
23
|
+
opts.on("-k", "--key KEY_FILE",
|
24
|
+
"load the access key from the specified file. By default, looks in", "#{options.key_path}") do |file_name|
|
25
|
+
options.key_path = File.expand_path(file_name)
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on("-n", "--node name", "node to connect, without protocol, e.g. 'node-7-com.universa.io'") do |node|
|
29
|
+
options.node = node
|
30
|
+
end
|
31
|
+
|
32
|
+
opts.separator ""
|
33
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
34
|
+
puts opts
|
35
|
+
exit
|
36
|
+
end
|
37
|
+
|
38
|
+
opts.on_tail("-v", "--version", "Show versions") do
|
39
|
+
puts "UNodeTool version: #{Universa::VERSION}"
|
40
|
+
puts "UMI version : #{Service.umi.version}"
|
41
|
+
exit
|
42
|
+
end
|
43
|
+
}
|
44
|
+
|
45
|
+
def seconds_to_hms seconds
|
46
|
+
mm, ss = seconds.divmod(60)
|
47
|
+
hh, mm = mm.divmod(60)
|
48
|
+
"%d:%02d:%02d" % [hh, mm, ss]
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
opt_parser.parse!
|
53
|
+
|
54
|
+
begin
|
55
|
+
node = options.node or raise "please specify node name with --node"
|
56
|
+
key = PrivateKey.from_packed(
|
57
|
+
open(File.expand_path options.key_path, 'rb').read,
|
58
|
+
password: options.key_password
|
59
|
+
) rescue nil
|
60
|
+
raise "failed to load private key from #{options.key_path}" unless key
|
61
|
+
conn = Client.new(key)[node]
|
62
|
+
stats = conn.execute("getStats", showDays: 60)
|
63
|
+
|
64
|
+
puts
|
65
|
+
puts "--------------- UNIVERSA NODE ##{stats.nodeNumber} (#{conn.name}) REPORT : -------------------------"
|
66
|
+
puts
|
67
|
+
puts "Server uptime (since last restart): #{seconds_to_hms stats.uptime} (#{stats.uptime}\")"
|
68
|
+
puts "Active ledger records : #{stats.ledgerSize}"
|
69
|
+
puts "Software version : #{stats.coreVersion}"
|
70
|
+
puts
|
71
|
+
stats.payments.each_slice(4) {|pss|
|
72
|
+
puts pss.map {|pdata| "#{pdata.date}: %4dU" % pdata.units}.join("\t")
|
73
|
+
}
|
74
|
+
|
75
|
+
rescue RuntimeError
|
76
|
+
puts $!.message
|
77
|
+
puts "Try --help fo see usage information"
|
78
|
+
rescue
|
79
|
+
p $!.class.name
|
80
|
+
$stderr.puts "Excetion: #{$!.message}"
|
81
|
+
$stderr.puts $!.backtrace.join("\n")
|
82
|
+
puts "\n\ntry --help"
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
# key = PrivateKey.from_packed
|
data/lib/universa/client.rb
CHANGED
@@ -70,6 +70,9 @@ module Universa
|
|
70
70
|
@nodes.sample(count)
|
71
71
|
end
|
72
72
|
|
73
|
+
def [] name
|
74
|
+
@nodes.find {|x| x.url =~ /#{name}/}
|
75
|
+
end
|
73
76
|
|
74
77
|
private
|
75
78
|
|
@@ -143,6 +146,13 @@ module Universa
|
|
143
146
|
def < other
|
144
147
|
rate < other.rate
|
145
148
|
end
|
149
|
+
|
150
|
+
def name
|
151
|
+
@name ||= begin
|
152
|
+
url =~ /^https{0,1}:\/\/([^:]*)/
|
153
|
+
$1
|
154
|
+
end
|
155
|
+
end
|
146
156
|
end
|
147
157
|
|
148
158
|
|
@@ -211,6 +221,22 @@ module Universa
|
|
211
221
|
connection.command name.to_s, *kwargs.to_a.flatten
|
212
222
|
end
|
213
223
|
|
224
|
+
# def stats days=0
|
225
|
+
# connection.getStats(days.to_i)
|
226
|
+
# end
|
227
|
+
|
228
|
+
def url
|
229
|
+
@node_info.url
|
230
|
+
end
|
231
|
+
|
232
|
+
def name
|
233
|
+
@node_info.name
|
234
|
+
end
|
235
|
+
|
236
|
+
def number
|
237
|
+
@node_info.number
|
238
|
+
end
|
239
|
+
|
214
240
|
def to_s
|
215
241
|
"Conn<#{@node_info.url}>"
|
216
242
|
end
|
@@ -223,11 +249,13 @@ module Universa
|
|
223
249
|
|
224
250
|
def connection
|
225
251
|
@connection ||= retry_with_timeout(15, 3) {
|
226
|
-
Service.umi.instantiate
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
252
|
+
conn = Service.umi.instantiate("com.icodici.universa.node2.network.Client",
|
253
|
+
@node_info.url,
|
254
|
+
@client.private_key,
|
255
|
+
nil,
|
256
|
+
false)
|
257
|
+
.getClient(@node_info.number - 1)
|
258
|
+
conn
|
231
259
|
}
|
232
260
|
end
|
233
261
|
|
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: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sergeych
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: farcall
|
@@ -113,6 +113,7 @@ email:
|
|
113
113
|
- real.sergeych@gmail.com
|
114
114
|
executables:
|
115
115
|
- universa
|
116
|
+
- utool
|
116
117
|
extensions: []
|
117
118
|
extra_rdoc_files: []
|
118
119
|
files:
|
@@ -152,6 +153,7 @@ files:
|
|
152
153
|
- bin/umi/lib/org.typelevel.macro-compat_2.12-1.1.1.jar
|
153
154
|
- bin/umi/lib/org.yaml.snakeyaml-1.18.jar
|
154
155
|
- exe/universa
|
156
|
+
- exe/utool
|
155
157
|
- lib/universa.rb
|
156
158
|
- lib/universa/binder.rb
|
157
159
|
- lib/universa/chain_store.rb
|