nanook 0.6.0 → 0.6.3

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
  SHA1:
3
- metadata.gz: 96226472bd51f8f70ef9462fa26ddf6b6f16da85
4
- data.tar.gz: 014690cf0466ed78b0aa95a92ad9dd2f15a7581b
3
+ metadata.gz: 38e4a248c6ea62d44a35964f3f06287cfead6987
4
+ data.tar.gz: 02eadb7cf364bcadddceec3983af2fce00ff669b
5
5
  SHA512:
6
- metadata.gz: 5571c48e4ce49a3e75487d7632d51ed4b7b5edc5ccb3aed14e3c7e18f92cd18c582606e2152ea4eb21bca238a077068a48b12db1036a43043d924c29e112fff2
7
- data.tar.gz: cf515b77fe27f4cb882a36a04b8c109943388cdcd33db3c34a018f586a7c41f8c0a8dc406a048048dcfad21edde62bbae6e468d0131efa96202990f45eb170f1
6
+ metadata.gz: 89a7f7be437584c723f121440d4c771805466a1d1447e1368d83a79e39d9048317dbf0f3d83b75121ec664a995ba19f8f331135322564bd146804b408a88d13b
7
+ data.tar.gz: 41d112321008ed82fb4c4be00cb1fe343c7bc385b25b240d1eb2ca7103fa1fc9496aa4a28548fde665dd239a4df4746e85410b31e609c83ea0379378529501a7
data/.circleci/config.yml CHANGED
@@ -46,7 +46,7 @@ jobs:
46
46
  command: |
47
47
  mkdir /tmp/test-results
48
48
 
49
- bundle exec rspec spec --format progress --out /tmp/test-results/rspec.xml
49
+ bundle exec rspec spec --format progress --format RspecJunitFormatter --out /tmp/test-results/rspec.xml
50
50
 
51
51
  # collect reports
52
52
  - store_test_results:
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nanook (0.6.0)
4
+ nanook (0.6.3)
5
5
  symbolized
6
6
 
7
7
  GEM
@@ -28,6 +28,8 @@ GEM
28
28
  diff-lcs (>= 1.2.0, < 2.0)
29
29
  rspec-support (~> 3.7.0)
30
30
  rspec-support (3.7.1)
31
+ rspec_junit_formatter (0.3.0)
32
+ rspec-core (>= 2, < 4, != 2.12.0)
31
33
  safe_yaml (1.0.4)
32
34
  symbolized (0.0.1)
33
35
  webmock (3.3.0)
@@ -43,6 +45,7 @@ DEPENDENCIES
43
45
  nanook!
44
46
  rake (~> 10.0)
45
47
  rspec (~> 3.2)
48
+ rspec_junit_formatter
46
49
  webmock (~> 3.3)
47
50
 
48
51
  BUNDLED WITH
data/README.md CHANGED
@@ -238,8 +238,12 @@ node.bootstrap(address: "::ffff:138.201.94.249", port: 7075)
238
238
  node.frontier_count
239
239
  node.peers
240
240
  node.representatives
241
- node.stop
241
+ node.representatives
242
+ node.sync_progress
243
+ node.synced?
242
244
  node.version
245
+
246
+ node.stop
243
247
  ```
244
248
 
245
249
  ### Work peers
data/lib/nanook.rb CHANGED
@@ -1,21 +1,11 @@
1
1
  require 'net/http'
2
2
  require 'uri'
3
3
 
4
- require 'nanook/account'
5
- require 'nanook/block'
6
- require 'nanook/error'
7
- require 'nanook/key'
8
- require 'nanook/node'
9
- require 'nanook/rpc'
10
- require 'nanook/util'
11
- require 'nanook/version'
12
- require 'nanook/wallet_account'
13
- require 'nanook/wallet'
14
- require 'nanook/work_peer'
4
+ Dir[File.dirname(__FILE__) + '/nanook/*.rb'].each {|file| require file }
15
5
 
16
6
  class Nanook
17
7
 
18
- def initialize(uri=Nanook::Rpc::DEFAULT_URI, timeout:Nanook::Rpc::DEFAULT_URI)
8
+ def initialize(uri=Nanook::Rpc::DEFAULT_URI, timeout:Nanook::Rpc::DEFAULT_TIMEOUT)
19
9
  @rpc = Nanook::Rpc.new(uri, timeout: timeout)
20
10
  end
21
11
 
data/lib/nanook/block.rb CHANGED
@@ -31,18 +31,14 @@ class Nanook
31
31
  if allow_unchecked
32
32
  # TODO not actually sure what this response looks like when it's not an unchecked block, assuming its blank
33
33
  response = rpc(:unchecked_get, :hash)
34
- return response unless response[:error] == "Block not found"
34
+ if response[:error] != "Block not found"
35
+ return _parse_info_response(response )
36
+ end
35
37
  # Continue on falling backto checked block
36
38
  end
37
39
 
38
40
  response = rpc(:block, :hash)
39
-
40
- # The contents is a stringified JSON
41
- if response[:contents]
42
- response[:contents] = JSON.parse(response[:contents])
43
- end
44
-
45
- response
41
+ _parse_info_response(response)
46
42
  end
47
43
 
48
44
  def is_valid_work?(work)
@@ -93,5 +89,13 @@ class Nanook
93
89
  end
94
90
  end
95
91
 
92
+ def _parse_info_response(response)
93
+ # The contents is a stringified JSON
94
+ if response[:contents]
95
+ response[:contents] = JSON.parse(response[:contents])
96
+ end
97
+ response
98
+ end
99
+
96
100
  end
97
101
  end
data/lib/nanook/node.rb CHANGED
@@ -37,6 +37,20 @@ class Nanook
37
37
  rpc(:stop)
38
38
  end
39
39
 
40
+ def sync_progress
41
+ response = rpc(:block_count)
42
+
43
+ count = response[:count]
44
+ unchecked = response[:unchecked]
45
+ total = count + unchecked
46
+
47
+ count.to_f * 100 / total.to_f
48
+ end
49
+
50
+ def synced?
51
+ rpc(:block_count)[:unchecked] == 0
52
+ end
53
+
40
54
  def version
41
55
  rpc(:version)
42
56
  end
data/lib/nanook/rpc.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  require 'json'
2
2
  require 'symbolized'
3
3
 
4
- require 'nanook/error'
5
-
6
4
  class Nanook
7
5
  class Rpc
8
6
 
@@ -1,3 +1,3 @@
1
1
  class Nanook
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.3"
3
3
  end
data/nanook.gemspec CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "bundler", "~> 1.16"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
26
  spec.add_development_dependency "rspec", "~> 3.2"
27
+ spec.add_development_dependency "rspec_junit_formatter"
27
28
  spec.add_development_dependency "webmock", "~> 3.3"
28
29
 
29
30
  spec.add_dependency "symbolized"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Duncalfe
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec_junit_formatter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: webmock
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -90,6 +104,7 @@ extra_rdoc_files: []
90
104
  files:
91
105
  - ".circleci/config.yml"
92
106
  - ".gitignore"
107
+ - ".rspec"
93
108
  - Gemfile
94
109
  - Gemfile.lock
95
110
  - LICENSE.txt