nanook 2.3.0 → 2.4.0

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
- SHA1:
3
- metadata.gz: 4453793303eb12685b219bed3586cfe92f09909f
4
- data.tar.gz: 0b4a3a21470ba6b7916a8fe7304234be89fd6234
2
+ SHA256:
3
+ metadata.gz: 632d341b2aa122d7c5049077fbebf1fd67097abb9bc0a4814ae938d2a5d70356
4
+ data.tar.gz: 9e640aadc4074e46b95e2ceafff4a67808aeca2f181dd95d530fb1d52fb5be30
5
5
  SHA512:
6
- metadata.gz: 1dc885c8cf50d2773de155e3b970cdf3f400641d9cc5a378996cc544ba18b96eab0a97dfc01592a33bf027fac2df6fa3f29bdf886e8c7fecaf827f4bcc848968
7
- data.tar.gz: ff5a87c994fa30e96730336a9ea5ee6c14939302ee2dd329dd83faa01a4479cbd0dfcd79dc0374a44d9c7562813e6799038d532b0c0f05c75fd30aa5c3214ebc
6
+ metadata.gz: a697f30061015b19d30075698e7d08fb4c868d886abfb8c420367e929dbf94b800b49f735785f1c6a72cda9ae8287704a90532b553c37c1ac0e8130118197b53
7
+ data.tar.gz: 79ecfa816e0c6d2b7b2c671ac99a28bc8840dfff71a5c6e5608a5700a80c3dcf18632141b91d76d9d31219cb111395d220bb05b9ca744513415238cc6003ab1a
@@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## 2.4.0
8
+
9
+ ### Added
10
+
11
+ - New `Nanook::Node#confirmation_history` method.
12
+ - New `Nanook::Block#confirm` method.
13
+ - New `Nanook::Block#confirmed_recently?` method.
14
+
15
+ ### Changed
16
+
17
+ - `Nanook::Block#generate_work` now can take optional `use_peers` argument.
18
+
7
19
  ## 2.3.0
8
20
 
9
21
  ### Added
data/README.md CHANGED
@@ -11,7 +11,7 @@ This is a Ruby library for managing a [nano currency](https://nano.org/) node, i
11
11
  Add this line to your application's Gemfile:
12
12
 
13
13
  ```ruby
14
- gem 'nanook', "~> 2.3"
14
+ gem 'nanook'
15
15
  ```
16
16
 
17
17
  And then execute:
@@ -120,11 +120,11 @@ wallet.receive(block_id, into: account_id)
120
120
 
121
121
  ## All commands
122
122
 
123
- Below is a quick reference list of commands. See the [full Nanook documentation](https://lukes.github.io/nanook/2.3.0/) for a searchable detailed description of every class and method, what the arguments mean, and example responses (Tip: the classes are listed under the "**Nanook** < Object" item in the sidebar).
123
+ Below is a quick reference list of commands. See the [full Nanook documentation](https://lukes.github.io/nanook/2.4.0/) for a searchable detailed description of every class and method, what the arguments mean, and example responses (Tip: the classes are listed under the "**Nanook** < Object" item in the sidebar).
124
124
 
125
125
  ### Wallets
126
126
 
127
- See the [full documentation for Nanook::Wallet](https://lukes.github.io/nanook/2.3.0/Nanook/Wallet.html) for a detailed description of each method and example responses.
127
+ See the [full documentation for Nanook::Wallet](https://lukes.github.io/nanook/2.4.0/Nanook/Wallet.html) for a detailed description of each method and example responses.
128
128
 
129
129
  #### Create wallet:
130
130
 
@@ -189,7 +189,7 @@ Nanook.new.wallet(wallet_id).account.create(5)
189
189
 
190
190
  #### Working with a single account:
191
191
 
192
- See the [full documentation for Nanook::WalletAccount](https://lukes.github.io/nanook/2.3.0/Nanook/WalletAccount.html) for a detailed description of each method and example responses.
192
+ See the [full documentation for Nanook::WalletAccount](https://lukes.github.io/nanook/2.4.0/Nanook/WalletAccount.html) for a detailed description of each method and example responses.
193
193
 
194
194
  ```ruby
195
195
  account = Nanook.new.wallet(wallet_id).account(account_id)
@@ -229,7 +229,7 @@ account.destroy
229
229
 
230
230
  #### Working with any account (not necessarily in your wallet):
231
231
 
232
- See the [full documentation for Nanook::Account](https://lukes.github.io/nanook/2.3.0/Nanook/Account.html) for a detailed description of each method and example responses.
232
+ See the [full documentation for Nanook::Account](https://lukes.github.io/nanook/2.4.0/Nanook/Account.html) for a detailed description of each method and example responses.
233
233
 
234
234
  ```ruby
235
235
  account = Nanook.new.account(account_id)
@@ -262,7 +262,7 @@ account.weight
262
262
 
263
263
  ### Blocks
264
264
 
265
- See the [full documentation for Nanook::Block](https://lukes.github.io/nanook/2.3.0/Nanook/Block.html) for a detailed description of each method and example responses.
265
+ See the [full documentation for Nanook::Block](https://lukes.github.io/nanook/2.4.0/Nanook/Block.html) for a detailed description of each method and example responses.
266
266
 
267
267
  ```ruby
268
268
  block = Nanook.new.block(block_id)
@@ -272,6 +272,8 @@ block.info(allow_unchecked: true) # Verified blocks AND unchecked synchronizing
272
272
  block.account
273
273
  block.chain
274
274
  block.chain(limit: 10)
275
+ block.confirm
276
+ block.confirmed_recently?
275
277
  block.history
276
278
  block.history(limit: 10)
277
279
  block.republish
@@ -283,13 +285,14 @@ block.successors
283
285
  block.successors(limit: 10)
284
286
 
285
287
  block.generate_work
288
+ block.generate_work(use_peers: true)
286
289
  block.cancel_work
287
290
  block.is_valid_work?(work_id)
288
291
  ```
289
292
 
290
293
  ### Managing your nano node
291
294
 
292
- See the [full documentation for Nanook::Node](https://lukes.github.io/nanook/2.3.0/Nanook/Node.html) for a detailed description of each method and example responses.
295
+ See the [full documentation for Nanook::Node](https://lukes.github.io/nanook/2.4.0/Nanook/Node.html) for a detailed description of each method and example responses.
293
296
 
294
297
  ```ruby
295
298
  node = Nanook.new.node
@@ -299,6 +302,7 @@ node.block_count
299
302
  node.block_count_by_type
300
303
  node.bootstrap_any
301
304
  node.bootstrap(address: "::ffff:138.201.94.249", port: 7075)
305
+ node.confirmation_history
302
306
  node.peers
303
307
  node.representatives
304
308
  node.representatives(unit: :raw)
@@ -66,14 +66,54 @@ class Nanook
66
66
  Nanook::Util.coerce_empty_string_to_type(response, Array)
67
67
  end
68
68
 
69
+ # Request confirmation for a block from online representative nodes.
70
+ # Will return immediately with a boolean to indicate if the request for
71
+ # confirmation was successful. Note that this boolean does not indicate
72
+ # the confirmation status of the block. If confirmed, your block should
73
+ # appear in {Nanook::Node#confirmation_history} within a short amount of
74
+ # time, or you can use the convenience method {Nanook::Block#confirmed_recently?}
75
+ #
76
+ # ==== Example:
77
+ # block.confirm # => true
78
+ #
79
+ # @return [Boolean] if the confirmation request was sent successful
80
+ def confirm
81
+ rpc(:block_confirm, :hash)[:started] == 1
82
+ end
83
+
84
+ # Check if the block appears in the list of recently confirmed blocks by
85
+ # online representatives. The full list of blocks can be queried for with {Nanook::Node#confirmation_history}.
86
+ #
87
+ # This method can work in conjunction with {Nanook::Block#confirm},
88
+ # whereby you can send any block (old or new) out to online representatives to
89
+ # confirm. The confirmation process can take up to a couple of minutes.
90
+ #
91
+ # The method returning +false+ can indicate that the block is still in the process of being
92
+ # confirmed and that you should call the method again soon, or that it
93
+ # was confirmed earlier than the list available in {Nanook::Node#confirmation_history},
94
+ # or that it was not confirmed.
95
+ #
96
+ # ==== Example:
97
+ # block.confirmed_recently? # => true
98
+ #
99
+ # @return [Boolean] +true+ if the block has been recently confirmed by
100
+ # online representatives.
101
+ def confirmed_recently?
102
+ @rpc.call(:confirmation_history)[:confirmations].map{|h| h[:hash]}.include?(@block)
103
+ end
104
+ alias_method :recently_confirmed?, :confirmed_recently?
105
+
69
106
  # Generate work for a block.
70
107
  #
71
108
  # ==== Example:
72
109
  # block.generate_work # => "2bf29ef00786a6bc"
73
110
  #
111
+ # @param use_peers [Boolean] if set to +true+, then the node will query
112
+ # its work peers (if it has any, see {Nanook::WorkPeer#list}).
113
+ # When +false+, the node will only generate work locally (default is +false+)
74
114
  # @return [String] the work id of the work completed.
75
- def generate_work
76
- rpc(:work_generate, :hash)[:work]
115
+ def generate_work(use_peers: false)
116
+ rpc(:work_generate, :hash, use_peers: use_peers)[:work]
77
117
  end
78
118
 
79
119
  # Returns Array of Hashes containing information about a chain of
@@ -90,6 +90,34 @@ class Nanook
90
90
  rpc(:bootstrap_any).has_key?(:success)
91
91
  end
92
92
 
93
+ # Returns block and tally weight (in raw) for recent elections winners
94
+ #
95
+ # ==== Example:
96
+ #
97
+ # node.confirmation_history
98
+ #
99
+ # Example response:
100
+ #
101
+ # [
102
+ # {
103
+ # block: "EA70B32C55C193345D625F766EEA2FCA52D3F2CCE0B3A30838CC543026BB0FEA",
104
+ # tally: 80394786589602980996311817874549318248
105
+ # },
106
+ # {
107
+ # block: "F2F8DA6D2CA0A4D78EB043A7A29E12BDE5B4CE7DE1B99A93A5210428EE5B8667",
108
+ # tally: 68921714529890443063672782079965877749
109
+ # }
110
+ # ]
111
+ #
112
+ # @return [Hash{Symbol=>String|Integer}]
113
+ def confirmation_history
114
+ rpc(:confirmation_history)[:confirmations].map do |history|
115
+ # Rename hash key to block
116
+ block = history.delete(:hash)
117
+ {block: block}.merge(history)
118
+ end
119
+ end
120
+
93
121
  # @return [String]
94
122
  def inspect
95
123
  "#{self.class.name}(object_id: \"#{"0x00%x" % (object_id << 1)}\")"
@@ -141,7 +169,7 @@ class Nanook
141
169
  #
142
170
  # @return [Array<String>] array of representative account ids
143
171
  def representatives_online
144
- response = rpc(:representatives_online)[:representatives].keys.map(&:to_s)
172
+ rpc(:representatives_online)[:representatives].keys.map(&:to_s)
145
173
  end
146
174
 
147
175
  # Safely shuts down the node.
@@ -1,3 +1,3 @@
1
1
  class Nanook
2
- VERSION = "2.3.0"
2
+ VERSION = "2.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanook
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Duncalfe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-24 00:00:00.000000000 Z
11
+ date: 2018-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  version: '0'
183
183
  requirements: []
184
184
  rubyforge_project:
185
- rubygems_version: 2.4.5.1
185
+ rubygems_version: 2.7.7
186
186
  signing_key:
187
187
  specification_version: 4
188
188
  summary: Library for managing a nano currency node, including making and receiving