pickynode-bchd 0.1.3 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/FUNDING.yml +1 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +81 -4
- data/.ruby-version +1 -1
- data/.travis.yml +2 -2
- data/Gemfile +10 -7
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/Rakefile +0 -0
- data/lib/pickynode_bchd.rb +10 -4
- data/pickynode_bchd.gemspec +9 -7
- data/spec/mocks.rb +79 -79
- data/spec/pickynode_spec.rb +30 -30
- metadata +54 -27
- data/Gemfile.lock +0 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9cef9d2200745f2f7d2124bbbce1a2597acd8e3c59aea68ee51ede1a5d689963
|
4
|
+
data.tar.gz: c73f40313db4ef35225fa98bdba6e78ff4b744caf02bd781ef6bc936094b2861
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e498d208e905026643e7b3a0530652f2f8340bd05a5b2562a14a7e3bb1fde989166bddc21b41aa354410935e4d0184de458d984f4dd1eccdca0c467fd41795c8
|
7
|
+
data.tar.gz: 0c0e8da3d2310209d6a85619365a835451a5547e83221eca4bc2537d22dad17cceac66328ba578112dc71ad4be7c9136c98b9ba09812f18e41f7bbef17024f32
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
github: [zquestz]
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,8 +1,85 @@
|
|
1
|
-
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.5
|
3
|
+
NewCops: disable
|
4
|
+
Metrics/ClassLength:
|
2
5
|
Enabled: false
|
3
6
|
Metrics/BlockLength:
|
4
|
-
ExcludedMethods: [
|
5
|
-
Style/IndentHeredoc:
|
6
|
-
Enabled: false
|
7
|
+
ExcludedMethods: ["describe", "context"]
|
7
8
|
Style/NumericPredicate:
|
8
9
|
Enabled: false
|
10
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
11
|
+
Enabled: true
|
12
|
+
Layout/SpaceAroundMethodCallOperator:
|
13
|
+
Enabled: true
|
14
|
+
Layout/LineLength:
|
15
|
+
Enabled: true
|
16
|
+
Lint/DeprecatedOpenSSLConstant:
|
17
|
+
Enabled: true
|
18
|
+
Lint/MixedRegexpCaptureTypes:
|
19
|
+
Enabled: true
|
20
|
+
Lint/RaiseException:
|
21
|
+
Enabled: true
|
22
|
+
Lint/StructNewOverride:
|
23
|
+
Enabled: true
|
24
|
+
Style/ExponentialNotation:
|
25
|
+
Enabled: true
|
26
|
+
Style/HashEachMethods:
|
27
|
+
Enabled: true
|
28
|
+
Style/HashTransformKeys:
|
29
|
+
Enabled: true
|
30
|
+
Style/HashTransformValues:
|
31
|
+
Enabled: true
|
32
|
+
Style/RedundantRegexpCharacterClass:
|
33
|
+
Enabled: true
|
34
|
+
Style/RedundantRegexpEscape:
|
35
|
+
Enabled: true
|
36
|
+
Style/SlicingWithRange:
|
37
|
+
Enabled: true
|
38
|
+
Lint/DuplicateElsifCondition:
|
39
|
+
Enabled: true
|
40
|
+
Style/AccessorGrouping:
|
41
|
+
Enabled: true
|
42
|
+
Style/ArrayCoercion:
|
43
|
+
Enabled: true
|
44
|
+
Style/BisectedAttrAccessor:
|
45
|
+
Enabled: true
|
46
|
+
Style/CaseLikeIf:
|
47
|
+
Enabled: true
|
48
|
+
Style/HashAsLastArrayItem:
|
49
|
+
Enabled: true
|
50
|
+
Style/HashLikeCase:
|
51
|
+
Enabled: true
|
52
|
+
Style/RedundantAssignment:
|
53
|
+
Enabled: true
|
54
|
+
Style/RedundantFetchBlock:
|
55
|
+
Enabled: true
|
56
|
+
Style/RedundantFileExtensionInRequire:
|
57
|
+
Enabled: true
|
58
|
+
Lint/BinaryOperatorWithIdenticalOperands:
|
59
|
+
Enabled: true
|
60
|
+
Lint/DuplicateRescueException:
|
61
|
+
Enabled: true
|
62
|
+
Lint/EmptyConditionalBody:
|
63
|
+
Enabled: true
|
64
|
+
Lint/FloatComparison:
|
65
|
+
Enabled: true
|
66
|
+
Lint/MissingSuper:
|
67
|
+
Enabled: true
|
68
|
+
Lint/OutOfRangeRegexpRef:
|
69
|
+
Enabled: true
|
70
|
+
Lint/SelfAssignment:
|
71
|
+
Enabled: true
|
72
|
+
Lint/TopLevelReturnWithArgument:
|
73
|
+
Enabled: true
|
74
|
+
Lint/UnreachableLoop:
|
75
|
+
Enabled: true
|
76
|
+
Style/ExplicitBlockArgument:
|
77
|
+
Enabled: true
|
78
|
+
Style/GlobalStdStream:
|
79
|
+
Enabled: true
|
80
|
+
Style/OptionalBooleanParameter:
|
81
|
+
Enabled: true
|
82
|
+
Style/SingleArgumentDig:
|
83
|
+
Enabled: true
|
84
|
+
Style/StringConcatenation:
|
85
|
+
Enabled: true
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.5.8
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
source 'https://rubygems.org'
|
4
|
-
ruby '>= 2.
|
4
|
+
ruby '>= 2.5'
|
5
5
|
|
6
|
-
gem 'awesome_print', '
|
7
|
-
gem '
|
8
|
-
gem '
|
9
|
-
gem '
|
10
|
-
|
11
|
-
gem '
|
6
|
+
gem 'awesome_print', '> 1.8.0'
|
7
|
+
gem 'base64'
|
8
|
+
gem 'optimist', '> 3.0.1'
|
9
|
+
gem 'ostruct'
|
10
|
+
|
11
|
+
gem 'rake', '~> 13.0.1'
|
12
|
+
gem 'rspec', '~> 3.9.0'
|
13
|
+
gem 'rubocop', '~> 0.89.0'
|
14
|
+
gem 'simplecov', '~> 0.18.5', require: false, group: :test
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[![Gem Version](https://badge.fury.io/rb/pickynode-bchd.svg)](https://badge.fury.io/rb/pickynode-bchd) [![Build Status](https://travis-ci.
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/pickynode-bchd.svg)](https://badge.fury.io/rb/pickynode-bchd) [![Build Status](https://app.travis-ci.com/zquestz/pickynode-bchd.svg?token=6MFuGdxALHX597TYtD8j&branch=master)](https://app.travis-ci.com/zquestz/pickynode-bchd) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
|
2
2
|
# pickynode-bchd
|
3
3
|
|
4
4
|
Some people are picky about the bitcoin cash nodes they connect to with bchd.
|
data/Rakefile
CHANGED
File without changes
|
data/lib/pickynode_bchd.rb
CHANGED
@@ -9,7 +9,7 @@ require 'uri'
|
|
9
9
|
# Allows you to easily add/remove/connect/disconnect nodes
|
10
10
|
# based on User Agent.
|
11
11
|
class PickynodeBCHD
|
12
|
-
VERSION = '0.
|
12
|
+
VERSION = '0.2.2'
|
13
13
|
|
14
14
|
def initialize(opts = {})
|
15
15
|
@opts = opts
|
@@ -24,6 +24,7 @@ class PickynodeBCHD
|
|
24
24
|
.select { |_, v| v.include?(filter) }
|
25
25
|
.each_with_index do |(k, _), i|
|
26
26
|
break if limit == i
|
27
|
+
|
27
28
|
run_cmd(%(bchctl addnode "#{k}" add))
|
28
29
|
end
|
29
30
|
end
|
@@ -37,6 +38,7 @@ class PickynodeBCHD
|
|
37
38
|
.select { |_, v| v.include?(filter) }
|
38
39
|
.each_with_index do |(k, _), i|
|
39
40
|
break if limit == i
|
41
|
+
|
40
42
|
run_cmd(%(bchctl node remove "#{k}"))
|
41
43
|
end
|
42
44
|
end
|
@@ -50,6 +52,7 @@ class PickynodeBCHD
|
|
50
52
|
.select { |_, v| v.include?(filter) }
|
51
53
|
.each_with_index do |(k, _), i|
|
52
54
|
break if limit == i
|
55
|
+
|
53
56
|
run_cmd(%(bchctl node connect "#{k}"))
|
54
57
|
end
|
55
58
|
end
|
@@ -63,6 +66,7 @@ class PickynodeBCHD
|
|
63
66
|
.select { |_, v| v.include?(filter) }
|
64
67
|
.each_with_index do |(k, _), i|
|
65
68
|
break if limit == i
|
69
|
+
|
66
70
|
run_cmd(%(bchctl node disconnect "#{k}"))
|
67
71
|
end
|
68
72
|
end
|
@@ -104,6 +108,7 @@ class PickynodeBCHD
|
|
104
108
|
|
105
109
|
def addr_types
|
106
110
|
return @addr_types if @addr_types
|
111
|
+
|
107
112
|
nodes = getpeerinfo
|
108
113
|
parsed_nodes = JSON.parse(nodes)
|
109
114
|
@addr_types = parsed_nodes.map do |n|
|
@@ -115,10 +120,11 @@ class PickynodeBCHD
|
|
115
120
|
|
116
121
|
def blockchair_addr_types
|
117
122
|
return @blockchair_addr_types if @blockchair_addr_types
|
123
|
+
|
118
124
|
parsed_nodelist = JSON.parse(blockchair_snapshot)
|
119
|
-
@blockchair_addr_types = parsed_nodelist['data']['nodes'].
|
120
|
-
|
121
|
-
end
|
125
|
+
@blockchair_addr_types = parsed_nodelist['data']['nodes'].transform_values do |v|
|
126
|
+
v['version']
|
127
|
+
end
|
122
128
|
rescue JSON::ParserError
|
123
129
|
{}
|
124
130
|
end
|
data/pickynode_bchd.gemspec
CHANGED
@@ -15,13 +15,15 @@ bitcoin cash nodes they connect to with bchd."
|
|
15
15
|
s.executables << 'pickynode-bchd'
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.require_paths = ['lib']
|
18
|
-
s.required_ruby_version = '>= 2.
|
18
|
+
s.required_ruby_version = '>= 2.5'
|
19
19
|
|
20
|
-
s.add_dependency 'awesome_print', '
|
21
|
-
s.add_dependency '
|
20
|
+
s.add_dependency 'awesome_print', '> 1.8.0'
|
21
|
+
s.add_dependency 'base64'
|
22
|
+
s.add_dependency 'optimist', '> 3.0.1'
|
23
|
+
s.add_dependency 'ostruct'
|
22
24
|
|
23
|
-
s.add_development_dependency '
|
24
|
-
s.add_development_dependency '
|
25
|
-
s.add_development_dependency 'rubocop', '~> 0.
|
26
|
-
s.add_development_dependency 'simplecov', '~> 0.
|
25
|
+
s.add_development_dependency 'rake', '~> 13.0.1'
|
26
|
+
s.add_development_dependency 'rspec', '~> 3.9.0'
|
27
|
+
s.add_development_dependency 'rubocop', '~> 0.88.0'
|
28
|
+
s.add_development_dependency 'simplecov', '~> 0.18.5'
|
27
29
|
end
|
data/spec/mocks.rb
CHANGED
@@ -1,90 +1,90 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
BLOCKCHAIR_SNAPSHOT =
|
4
|
-
{
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
3
|
+
BLOCKCHAIR_SNAPSHOT = <<~HEREDOC
|
4
|
+
{
|
5
|
+
"data": {
|
6
|
+
"nodes": {
|
7
|
+
"88.99.199.87:8333": {
|
8
|
+
"version": "\/BitcoinUnlimited:1.0.2(EB16; AD12)\/",
|
9
|
+
"country": "US",
|
10
|
+
"height": 555417,
|
11
|
+
"flags": 37
|
12
|
+
},
|
13
|
+
"[2a01:e34:ee3a:5730:21f:5bff:fec5:e356]:8333": {
|
14
|
+
"version": "\/Bitcoin ABC:0.18.2(EB32.0)\/",
|
15
|
+
"country": "US",
|
16
|
+
"height": 555416,
|
17
|
+
"flags": 37
|
18
|
+
}
|
18
19
|
}
|
19
20
|
}
|
20
21
|
}
|
21
|
-
}
|
22
|
-
HEREDOC
|
23
|
-
|
24
|
-
NODE_INFO = <<-HEREDOC
|
25
|
-
{
|
26
|
-
"version": 120000,
|
27
|
-
"protocolversion": 70013,
|
28
|
-
"blocks": 310554,
|
29
|
-
"timeoffset": 0,
|
30
|
-
"connections": 41,
|
31
|
-
"proxy": "",
|
32
|
-
"difficulty": 17336316978.50783,
|
33
|
-
"testnet": false,
|
34
|
-
"relayfee": 0.00001,
|
35
|
-
"errors": ""
|
36
|
-
}
|
37
22
|
HEREDOC
|
38
23
|
|
39
|
-
|
40
|
-
[
|
41
|
-
{
|
42
|
-
"id": 10,
|
43
|
-
"addr": "131.114.88.218:33422",
|
44
|
-
"addrlocal": "67.188.11.253:8333",
|
45
|
-
"services": "00000001",
|
46
|
-
"servicesStr": "SFNodeNetwork",
|
47
|
-
"relaytxes": true,
|
48
|
-
"lastsend": 1541490162,
|
49
|
-
"lastrecv": 1541490162,
|
50
|
-
"bytessent": 1587,
|
51
|
-
"bytesrecv": 3258,
|
52
|
-
"conntime": 1541486322,
|
53
|
-
"timeoffset": 0,
|
54
|
-
"pingtime": 125312,
|
55
|
-
"version": 70013,
|
56
|
-
"subver": "/FirstClient/",
|
57
|
-
"inbound": false,
|
58
|
-
"startingheight": 555420,
|
59
|
-
"currentheight": 555420,
|
60
|
-
"banscore": 0,
|
61
|
-
"whitelisted": false,
|
62
|
-
"feefilter": 18,
|
63
|
-
"syncnode": false
|
64
|
-
},
|
24
|
+
NODE_INFO = <<~HEREDOC
|
65
25
|
{
|
66
|
-
"
|
67
|
-
"
|
68
|
-
"
|
69
|
-
"services": "00000053",
|
70
|
-
"servicesStr": "SFNodeNetwork|SFNodeBloom|SFNodeXthin|SFNodeBitcoinCash",
|
71
|
-
"relaytxes": true,
|
72
|
-
"lastsend": 1541490073,
|
73
|
-
"lastrecv": 1541490140,
|
74
|
-
"bytessent": 2163,
|
75
|
-
"bytesrecv": 6515,
|
76
|
-
"conntime": 1541486352,
|
26
|
+
"version": 120000,
|
27
|
+
"protocolversion": 70013,
|
28
|
+
"blocks": 310554,
|
77
29
|
"timeoffset": 0,
|
78
|
-
"
|
79
|
-
"
|
80
|
-
"
|
81
|
-
"
|
82
|
-
"
|
83
|
-
"
|
84
|
-
"banscore": 0,
|
85
|
-
"whitelisted": false,
|
86
|
-
"feefilter": 0,
|
87
|
-
"syncnode": false
|
30
|
+
"connections": 41,
|
31
|
+
"proxy": "",
|
32
|
+
"difficulty": 17336316978.50783,
|
33
|
+
"testnet": false,
|
34
|
+
"relayfee": 0.00001,
|
35
|
+
"errors": ""
|
88
36
|
}
|
89
|
-
|
37
|
+
HEREDOC
|
38
|
+
|
39
|
+
PEER_INFO = <<~HEREDOC
|
40
|
+
[
|
41
|
+
{
|
42
|
+
"id": 10,
|
43
|
+
"addr": "131.114.88.218:33422",
|
44
|
+
"addrlocal": "67.188.11.253:8333",
|
45
|
+
"services": "00000001",
|
46
|
+
"servicesStr": "SFNodeNetwork",
|
47
|
+
"relaytxes": true,
|
48
|
+
"lastsend": 1541490162,
|
49
|
+
"lastrecv": 1541490162,
|
50
|
+
"bytessent": 1587,
|
51
|
+
"bytesrecv": 3258,
|
52
|
+
"conntime": 1541486322,
|
53
|
+
"timeoffset": 0,
|
54
|
+
"pingtime": 125312,
|
55
|
+
"version": 70013,
|
56
|
+
"subver": "/FirstClient/",
|
57
|
+
"inbound": false,
|
58
|
+
"startingheight": 555420,
|
59
|
+
"currentheight": 555420,
|
60
|
+
"banscore": 0,
|
61
|
+
"whitelisted": false,
|
62
|
+
"feefilter": 18,
|
63
|
+
"syncnode": false
|
64
|
+
},
|
65
|
+
{
|
66
|
+
"id": 12,
|
67
|
+
"addr": "[2a01:e34:ee3a:5730:21f:5bff:fec5:e356]:8333",
|
68
|
+
"addrlocal": "[2a01:e34:ee3a:5730:21f:5bff:fec5:e356]:8333",
|
69
|
+
"services": "00000053",
|
70
|
+
"servicesStr": "SFNodeNetwork|SFNodeBloom|SFNodeXthin|SFNodeBitcoinCash",
|
71
|
+
"relaytxes": true,
|
72
|
+
"lastsend": 1541490073,
|
73
|
+
"lastrecv": 1541490140,
|
74
|
+
"bytessent": 2163,
|
75
|
+
"bytesrecv": 6515,
|
76
|
+
"conntime": 1541486352,
|
77
|
+
"timeoffset": 0,
|
78
|
+
"pingtime": 180911,
|
79
|
+
"version": 80003,
|
80
|
+
"subver": "/SecondClient/",
|
81
|
+
"inbound": false,
|
82
|
+
"startingheight": 555420,
|
83
|
+
"currentheight": 555420,
|
84
|
+
"banscore": 0,
|
85
|
+
"whitelisted": false,
|
86
|
+
"feefilter": 0,
|
87
|
+
"syncnode": false
|
88
|
+
}
|
89
|
+
]
|
90
90
|
HEREDOC
|
data/spec/pickynode_spec.rb
CHANGED
@@ -29,7 +29,7 @@ describe PickynodeBCHD do
|
|
29
29
|
describe '.add' do
|
30
30
|
it 'should add nodes based on user agent' do
|
31
31
|
expect(subject).to receive(:blockchair_snapshot).once
|
32
|
-
|
32
|
+
.and_return(BLOCKCHAIR_SNAPSHOT)
|
33
33
|
expect(subject).to receive(:run_cmd)
|
34
34
|
.with(%(bchctl addnode "#{ipv6_ip}" add))
|
35
35
|
subject.add('ABC')
|
@@ -47,7 +47,7 @@ describe PickynodeBCHD do
|
|
47
47
|
|
48
48
|
it 'should recover gracefully if json is malformed' do
|
49
49
|
expect(subject).to receive(:blockchair_snapshot).once
|
50
|
-
|
50
|
+
.and_return(json_error)
|
51
51
|
expect(subject).to_not receive(:run_cmd)
|
52
52
|
subject.add('Anything')
|
53
53
|
end
|
@@ -62,7 +62,7 @@ describe PickynodeBCHD do
|
|
62
62
|
context 'with a limit' do
|
63
63
|
it 'should respect a limit parameter of 1' do
|
64
64
|
expect(subject).to receive(:blockchair_snapshot).once
|
65
|
-
|
65
|
+
.and_return(BLOCKCHAIR_SNAPSHOT)
|
66
66
|
expect(subject).to receive(:run_cmd)
|
67
67
|
.with('bchctl addnode "88.99.199.87:8333" add')
|
68
68
|
subject.add('i', 1)
|
@@ -70,7 +70,7 @@ describe PickynodeBCHD do
|
|
70
70
|
|
71
71
|
it 'should respect a limit parameter greater than 1' do
|
72
72
|
expect(subject).to receive(:blockchair_snapshot).once
|
73
|
-
|
73
|
+
.and_return(BLOCKCHAIR_SNAPSHOT)
|
74
74
|
expect(subject).to receive(:run_cmd)
|
75
75
|
.with('bchctl addnode "88.99.199.87:8333" add')
|
76
76
|
expect(subject).to receive(:run_cmd)
|
@@ -83,7 +83,7 @@ describe PickynodeBCHD do
|
|
83
83
|
describe '.remove' do
|
84
84
|
it 'should remove nodes based on user agent' do
|
85
85
|
expect(subject).to receive(:`).once
|
86
|
-
|
86
|
+
.and_return(PEER_INFO)
|
87
87
|
expect(subject).to receive(:run_cmd)
|
88
88
|
.with(%(bchctl node remove "#{ipv6_ip}"))
|
89
89
|
subject.remove('SecondClient')
|
@@ -101,7 +101,7 @@ describe PickynodeBCHD do
|
|
101
101
|
|
102
102
|
it 'should recover gracefully if json is malformed' do
|
103
103
|
expect(subject).to receive(:`).once
|
104
|
-
|
104
|
+
.and_return(json_error)
|
105
105
|
expect(subject).to_not receive(:run_cmd)
|
106
106
|
subject.remove('Anything')
|
107
107
|
end
|
@@ -110,7 +110,7 @@ describe PickynodeBCHD do
|
|
110
110
|
describe '.connect' do
|
111
111
|
it 'should connect to nodes based on user agent' do
|
112
112
|
expect(subject).to receive(:blockchair_snapshot).once
|
113
|
-
|
113
|
+
.and_return(BLOCKCHAIR_SNAPSHOT)
|
114
114
|
expect(subject).to receive(:run_cmd)
|
115
115
|
.with('bchctl node connect "88.99.199.87:8333"')
|
116
116
|
subject.connect('Unlimited')
|
@@ -128,7 +128,7 @@ describe PickynodeBCHD do
|
|
128
128
|
|
129
129
|
it 'should recover gracefully if json is malformed' do
|
130
130
|
expect(subject).to receive(:blockchair_snapshot).once
|
131
|
-
|
131
|
+
.and_return(json_error)
|
132
132
|
expect(subject).to_not receive(:run_cmd)
|
133
133
|
subject.connect('Anything')
|
134
134
|
end
|
@@ -143,7 +143,7 @@ describe PickynodeBCHD do
|
|
143
143
|
context 'with a limit' do
|
144
144
|
it 'should respect a limit parameter of 1' do
|
145
145
|
expect(subject).to receive(:blockchair_snapshot).once
|
146
|
-
|
146
|
+
.and_return(BLOCKCHAIR_SNAPSHOT)
|
147
147
|
expect(subject).to receive(:run_cmd)
|
148
148
|
.with('bchctl node connect "88.99.199.87:8333"')
|
149
149
|
subject.connect('i', 1)
|
@@ -151,7 +151,7 @@ describe PickynodeBCHD do
|
|
151
151
|
|
152
152
|
it 'should respect a limit parameter greater than 1' do
|
153
153
|
expect(subject).to receive(:blockchair_snapshot).once
|
154
|
-
|
154
|
+
.and_return(BLOCKCHAIR_SNAPSHOT)
|
155
155
|
expect(subject).to receive(:run_cmd)
|
156
156
|
.with('bchctl node connect "88.99.199.87:8333"')
|
157
157
|
expect(subject).to receive(:run_cmd)
|
@@ -164,7 +164,7 @@ describe PickynodeBCHD do
|
|
164
164
|
describe '.disconnect' do
|
165
165
|
it 'should disconnect nodes based on user agent' do
|
166
166
|
expect(subject).to receive(:`).once
|
167
|
-
|
167
|
+
.and_return(PEER_INFO)
|
168
168
|
expect(subject).to receive(:run_cmd)
|
169
169
|
.with(%(bchctl node disconnect "#{ipv6_ip}"))
|
170
170
|
subject.disconnect('SecondClient')
|
@@ -182,7 +182,7 @@ describe PickynodeBCHD do
|
|
182
182
|
|
183
183
|
it 'should recover gracefully if json is malformed' do
|
184
184
|
expect(subject).to receive(:`).once
|
185
|
-
|
185
|
+
.and_return(json_error)
|
186
186
|
expect(subject).to_not receive(:run_cmd)
|
187
187
|
subject.disconnect('Anything')
|
188
188
|
end
|
@@ -191,14 +191,14 @@ describe PickynodeBCHD do
|
|
191
191
|
describe '.display' do
|
192
192
|
it 'should display connected nodes' do
|
193
193
|
expect(subject).to receive(:`).once
|
194
|
-
|
194
|
+
.and_return(PEER_INFO)
|
195
195
|
expect(subject).to receive(:ap).with(node_hash).and_return(node_hash)
|
196
196
|
expect(subject.display).to eq(node_hash)
|
197
197
|
end
|
198
198
|
|
199
199
|
it 'should recover gracefully if json is malformed' do
|
200
200
|
expect(subject).to receive(:`).once
|
201
|
-
|
201
|
+
.and_return(json_error)
|
202
202
|
expect(subject).to receive(:ap).with({}).and_return({})
|
203
203
|
expect(subject.display).to eq({})
|
204
204
|
end
|
@@ -207,15 +207,15 @@ describe PickynodeBCHD do
|
|
207
207
|
describe '.info' do
|
208
208
|
it 'should display local node info' do
|
209
209
|
expect(subject).to receive(:`).once
|
210
|
-
|
210
|
+
.and_return(NODE_INFO)
|
211
211
|
expect(subject).to receive(:ap).with(parsed_node_info)
|
212
|
-
|
212
|
+
.and_return(parsed_node_info)
|
213
213
|
expect(subject.info).to eq(parsed_node_info)
|
214
214
|
end
|
215
215
|
|
216
216
|
it 'should recover gracefully if json is malformed' do
|
217
217
|
expect(subject).to receive(:`).once
|
218
|
-
|
218
|
+
.and_return(json_error)
|
219
219
|
expect(subject).to receive(:ap).with({}).and_return({})
|
220
220
|
expect(subject.info).to eq({})
|
221
221
|
end
|
@@ -237,15 +237,15 @@ describe PickynodeBCHD do
|
|
237
237
|
|
238
238
|
it 'should call add, connect, remove, disconnect and info' do
|
239
239
|
expect(subject).to receive(:blockchair_snapshot).once
|
240
|
-
|
240
|
+
.and_return(BLOCKCHAIR_SNAPSHOT)
|
241
241
|
expect(subject).to receive(:getpeerinfo).once
|
242
|
-
|
242
|
+
.and_return(PEER_INFO)
|
243
243
|
expect(subject).to receive(:add).with(opts[:add], opts[:limit])
|
244
|
-
|
244
|
+
.and_call_original
|
245
245
|
expect(subject).to receive(:connect).with(opts[:connect], opts[:limit])
|
246
|
-
|
246
|
+
.and_call_original
|
247
247
|
expect(subject).to receive(:remove).with(opts[:remove], opts[:limit])
|
248
|
-
|
248
|
+
.and_call_original
|
249
249
|
expect(subject).to receive(:disconnect)
|
250
250
|
.with(opts[:disconnect], opts[:limit])
|
251
251
|
.and_call_original
|
@@ -256,9 +256,9 @@ describe PickynodeBCHD do
|
|
256
256
|
|
257
257
|
it 'should recover gracefully if json is malformed' do
|
258
258
|
expect(subject).to receive(:blockchair_snapshot).at_least(1)
|
259
|
-
|
259
|
+
.and_return(json_error)
|
260
260
|
expect(subject).to receive(:getpeerinfo).at_least(1)
|
261
|
-
|
261
|
+
.and_return(json_error)
|
262
262
|
expect(subject).to receive(:`)
|
263
263
|
.and_return(json_error)
|
264
264
|
expect(subject).to receive(:info)
|
@@ -276,7 +276,7 @@ describe PickynodeBCHD do
|
|
276
276
|
|
277
277
|
it 'should call display' do
|
278
278
|
expect(subject).to receive(:`).once
|
279
|
-
|
279
|
+
.and_return(PEER_INFO)
|
280
280
|
expect(subject).to receive(:ap).with(node_hash).and_return(node_hash)
|
281
281
|
expect(subject).to receive(:display).and_call_original
|
282
282
|
subject.run
|
@@ -284,7 +284,7 @@ describe PickynodeBCHD do
|
|
284
284
|
|
285
285
|
it 'should recover gracefully if json is malformed' do
|
286
286
|
expect(subject).to receive(:`).once
|
287
|
-
|
287
|
+
.and_return(json_error)
|
288
288
|
expect(subject).to_not receive(:run_cmd)
|
289
289
|
expect(subject).to_not receive(:info)
|
290
290
|
expect(subject).to receive(:ap).with({}).and_return({})
|
@@ -296,7 +296,7 @@ describe PickynodeBCHD do
|
|
296
296
|
describe 'clear_cache' do
|
297
297
|
it 'should clear the bitnodes cache' do
|
298
298
|
expect(subject).to receive(:blockchair_snapshot).once
|
299
|
-
|
299
|
+
.and_return(BLOCKCHAIR_SNAPSHOT)
|
300
300
|
expect(subject).to receive(:run_cmd)
|
301
301
|
.with(%(bchctl addnode "#{ipv6_ip}" add))
|
302
302
|
expect(subject).to receive(:run_cmd)
|
@@ -305,7 +305,7 @@ describe PickynodeBCHD do
|
|
305
305
|
subject.add('Unlimited')
|
306
306
|
subject.clear_cache
|
307
307
|
expect(subject).to receive(:blockchair_snapshot).once
|
308
|
-
|
308
|
+
.and_return(BLOCKCHAIR_SNAPSHOT)
|
309
309
|
expect(subject).to receive(:run_cmd)
|
310
310
|
.with(%(bchctl addnode "#{ipv6_ip}" add))
|
311
311
|
subject.add('ABC')
|
@@ -313,7 +313,7 @@ describe PickynodeBCHD do
|
|
313
313
|
|
314
314
|
it 'should clear the getpeerinfo cache' do
|
315
315
|
expect(subject).to receive(:getpeerinfo).once
|
316
|
-
|
316
|
+
.and_return(PEER_INFO)
|
317
317
|
expect(subject).to receive(:run_cmd)
|
318
318
|
.with('bchctl node remove "131.114.88.218:33422"')
|
319
319
|
expect(subject).to receive(:run_cmd)
|
@@ -322,7 +322,7 @@ describe PickynodeBCHD do
|
|
322
322
|
subject.remove('SecondClient')
|
323
323
|
subject.clear_cache
|
324
324
|
expect(subject).to receive(:getpeerinfo).once
|
325
|
-
|
325
|
+
.and_return(PEER_INFO)
|
326
326
|
expect(subject).to receive(:run_cmd)
|
327
327
|
.with('bchctl node remove "131.114.88.218:33422"')
|
328
328
|
subject.remove('FirstClient')
|
metadata
CHANGED
@@ -1,99 +1,127 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pickynode-bchd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Ellithorpe
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.8.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.8.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: base64
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: optimist
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - "
|
45
|
+
- - ">"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
47
|
+
version: 3.0.1
|
34
48
|
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - "
|
52
|
+
- - ">"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
54
|
+
version: 3.0.1
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
56
|
+
name: ostruct
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
44
72
|
requirements:
|
45
73
|
- - "~>"
|
46
74
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
75
|
+
version: 13.0.1
|
48
76
|
type: :development
|
49
77
|
prerelease: false
|
50
78
|
version_requirements: !ruby/object:Gem::Requirement
|
51
79
|
requirements:
|
52
80
|
- - "~>"
|
53
81
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
82
|
+
version: 13.0.1
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
84
|
+
name: rspec
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
58
86
|
requirements:
|
59
87
|
- - "~>"
|
60
88
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
89
|
+
version: 3.9.0
|
62
90
|
type: :development
|
63
91
|
prerelease: false
|
64
92
|
version_requirements: !ruby/object:Gem::Requirement
|
65
93
|
requirements:
|
66
94
|
- - "~>"
|
67
95
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
96
|
+
version: 3.9.0
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: rubocop
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
72
100
|
requirements:
|
73
101
|
- - "~>"
|
74
102
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
103
|
+
version: 0.88.0
|
76
104
|
type: :development
|
77
105
|
prerelease: false
|
78
106
|
version_requirements: !ruby/object:Gem::Requirement
|
79
107
|
requirements:
|
80
108
|
- - "~>"
|
81
109
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
110
|
+
version: 0.88.0
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
112
|
name: simplecov
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
86
114
|
requirements:
|
87
115
|
- - "~>"
|
88
116
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
117
|
+
version: 0.18.5
|
90
118
|
type: :development
|
91
119
|
prerelease: false
|
92
120
|
version_requirements: !ruby/object:Gem::Requirement
|
93
121
|
requirements:
|
94
122
|
- - "~>"
|
95
123
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
124
|
+
version: 0.18.5
|
97
125
|
description: Some people are picky about the bitcoin cash nodes they connect to with
|
98
126
|
bchd.
|
99
127
|
email: quest@mac.com
|
@@ -102,13 +130,13 @@ executables:
|
|
102
130
|
extensions: []
|
103
131
|
extra_rdoc_files: []
|
104
132
|
files:
|
133
|
+
- ".github/FUNDING.yml"
|
105
134
|
- ".gitignore"
|
106
135
|
- ".rubocop.yml"
|
107
136
|
- ".ruby-gemset"
|
108
137
|
- ".ruby-version"
|
109
138
|
- ".travis.yml"
|
110
139
|
- Gemfile
|
111
|
-
- Gemfile.lock
|
112
140
|
- LICENSE
|
113
141
|
- README.md
|
114
142
|
- Rakefile
|
@@ -123,7 +151,7 @@ homepage: http://github.com/zquestz/pickynode-bchd
|
|
123
151
|
licenses:
|
124
152
|
- MIT
|
125
153
|
metadata: {}
|
126
|
-
post_install_message:
|
154
|
+
post_install_message:
|
127
155
|
rdoc_options: []
|
128
156
|
require_paths:
|
129
157
|
- lib
|
@@ -131,16 +159,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
131
159
|
requirements:
|
132
160
|
- - ">="
|
133
161
|
- !ruby/object:Gem::Version
|
134
|
-
version: '2.
|
162
|
+
version: '2.5'
|
135
163
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
164
|
requirements:
|
137
165
|
- - ">="
|
138
166
|
- !ruby/object:Gem::Version
|
139
167
|
version: '0'
|
140
168
|
requirements: []
|
141
|
-
|
142
|
-
|
143
|
-
signing_key:
|
169
|
+
rubygems_version: 3.0.9
|
170
|
+
signing_key:
|
144
171
|
specification_version: 4
|
145
172
|
summary: Manage connections to your bchd node
|
146
173
|
test_files: []
|
data/Gemfile.lock
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: https://rubygems.org/
|
3
|
-
specs:
|
4
|
-
ast (2.3.0)
|
5
|
-
awesome_print (1.7.0)
|
6
|
-
diff-lcs (1.3)
|
7
|
-
docile (1.1.5)
|
8
|
-
json (2.1.0)
|
9
|
-
optimist (3.0.0)
|
10
|
-
parser (2.4.0.0)
|
11
|
-
ast (~> 2.2)
|
12
|
-
powerpack (0.1.1)
|
13
|
-
rainbow (2.2.2)
|
14
|
-
rake
|
15
|
-
rake (12.0.0)
|
16
|
-
rspec (3.6.0)
|
17
|
-
rspec-core (~> 3.6.0)
|
18
|
-
rspec-expectations (~> 3.6.0)
|
19
|
-
rspec-mocks (~> 3.6.0)
|
20
|
-
rspec-core (3.6.0)
|
21
|
-
rspec-support (~> 3.6.0)
|
22
|
-
rspec-expectations (3.6.0)
|
23
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
-
rspec-support (~> 3.6.0)
|
25
|
-
rspec-mocks (3.6.0)
|
26
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
-
rspec-support (~> 3.6.0)
|
28
|
-
rspec-support (3.6.0)
|
29
|
-
rubocop (0.48.1)
|
30
|
-
parser (>= 2.3.3.1, < 3.0)
|
31
|
-
powerpack (~> 0.1)
|
32
|
-
rainbow (>= 1.99.1, < 3.0)
|
33
|
-
ruby-progressbar (~> 1.7)
|
34
|
-
unicode-display_width (~> 1.0, >= 1.0.1)
|
35
|
-
ruby-progressbar (1.8.1)
|
36
|
-
simplecov (0.14.1)
|
37
|
-
docile (~> 1.1.0)
|
38
|
-
json (>= 1.8, < 3)
|
39
|
-
simplecov-html (~> 0.10.0)
|
40
|
-
simplecov-html (0.10.1)
|
41
|
-
unicode-display_width (1.2.1)
|
42
|
-
|
43
|
-
PLATFORMS
|
44
|
-
ruby
|
45
|
-
|
46
|
-
DEPENDENCIES
|
47
|
-
awesome_print (~> 1.7)
|
48
|
-
optimist (~> 3.0)
|
49
|
-
rake (~> 12.0)
|
50
|
-
rspec (~> 3.6)
|
51
|
-
rubocop (~> 0.48)
|
52
|
-
simplecov (~> 0.14)
|
53
|
-
|
54
|
-
RUBY VERSION
|
55
|
-
ruby 2.3.4p301
|
56
|
-
|
57
|
-
BUNDLED WITH
|
58
|
-
1.17.1
|