create account

Ruby Client for Hive: hive-ruby-1.0.3 by inertia

View this thread on: hive.blogpeakd.comecency.com
· @inertia ·
$33.64
Ruby Client for Hive: hive-ruby-1.0.3
<div class="pull-right">
  <img src="https://files.peakd.com/file/peakd-hive/inertia/aJnQFjOw-logo-128.png" />
</div>

This is a version bump and should not adversely affect existing applications that use the `hive-ruby` gem.  Changes are focused on performance improvements to `Hive::Stream` subroutines.

The main change is that we no longer have to rely on `json-rpc-batch` to stream blocks.  Prior to this change, if the API node supported batched requests, it would ask for up to 50 blocks using [this published standard](https://www.jsonrpc.org/specification#batch).

But not all API endpoints supported the standard.  In HF24, we got the [`block_api.get_block_range`](https://developers.hive.io/apidefinitions/#block_api.get_block_range) method.  And although not all endpoints support this method, it's much more supported than `json-rpc-batch`.

Hive Ruby will try whatever the endpoint will provide, starting with `get_block_range`, then `json-rpc-batch`, and then just fall back on non-batched requests.

In addition to this new method, if you area streaming virtual operations, Hive Ruby will now use [`account_history_api.enum_virtual_ops`](https://developers.hive.io/apidefinitions/#account_history_api.enum_virtual_ops) (if supported).  This will improve performance and reliability, even when streaming virtual operations from the head block.

See rev.: [94142bc](
https://gitlab.syncad.com/hive/hive-ruby/-/commit/94142bc9b21a662ce8f467c60f1e039a7e62d832)

To update your application:

```bash
bundle update hive-ruby
```

See previous `hive-ruby` posts: [peakd.com/c/hive-139531/search?q=hive-ruby](https://peakd.com/c/hive-139531/search?q=hive-ruby)
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 48 others
properties (23)
authorinertia
permlinkruby-client-for-hive-hive-ruby-103
categoryhive-139531
json_metadata"{"app":"peakd/2021.04.2","format":"markdown","description":"Updated mostly for block streaming clients.","tags":["hive","ruby"],"links":["https://www.jsonrpc.org/specification#batch","https://developers.hive.io/apidefinitions/#block_api.get_block_range","https://developers.hive.io/apidefinitions/#account_history_api.enum_virtual_ops","https://gitlab.syncad.com/hive/hive-ruby/-/commit/94142bc9b21a662ce8f467c60f1e039a7e62d832","https://peakd.com/c/hive-139531/search?q=hive-ruby"],"image":["https://files.peakd.com/file/peakd-hive/inertia/aJnQFjOw-logo-128.png"]}"
created2021-04-23 05:05:09
last_update2021-04-23 05:05:09
depth0
children1
last_payout2021-04-30 05:05:09
cashout_time1969-12-31 23:59:59
total_payout_value18.722 HBD
curator_payout_value14.913 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,668
author_reputation344,124,293,856,703
root_title"Ruby Client for Hive: hive-ruby-1.0.3"
beneficiaries
0.
accountpeakd
weight500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id103,227,551
net_rshares35,571,184,262,819
author_curate_reward""
vote details (112)
@shadowmyst ·
```
require 'hive'

params = {
  voter: 'xxxxx',
  author: 'xxxxx',
  permlink: 'xxxxx',
  weight: 10000
}

Hive::Broadcast.vote(wif: 'xxxxxxxxx', params: params) do |result|
  puts result
end
```

I was following the documentation and according to me I have put the code correctly to make the vote, but when I use it I get the following error.

```

/home/shadowmyst/.rvm/gems/ruby-3.1.1/gems/hive-ruby-1.0.3/lib/hive/api.rb:46:in `api_name=': can't modify frozen #<Class:#<Class:0x00007f8ac055ebd0>>: #<Class:0x00007f8ac055ebd0> (FrozenError)
        from /home/shadowmyst/.rvm/gems/ruby-3.1.1/gems/hive-ruby-1.0.3/lib/hive.rb:88:in `const_missing'
        from /home/shadowmyst/.rvm/gems/ruby-3.1.1/gems/hive-ruby-1.0.3/lib/hive/transaction_builder.rb:46:in `initialize'
        from /home/shadowmyst/.rvm/gems/ruby-3.1.1/gems/hive-ruby-1.0.3/lib/hive/broadcast.rb:1367:in `new'
        from /home/shadowmyst/.rvm/gems/ruby-3.1.1/gems/hive-ruby-1.0.3/lib/hive/broadcast.rb:1367:in `process'
        from /home/shadowmyst/.rvm/gems/ruby-3.1.1/gems/hive-ruby-1.0.3/lib/hive/broadcast.rb:70:in `vote'
```

I would like to know what is the mistake I made, or what is the reason why it is not working for me?
👍  
properties (23)
authorshadowmyst
permlinkre-inertia-rbi3ts
categoryhive-139531
json_metadata{"tags":["hive-139531"],"app":"peakd/2022.05.4"}
created2022-05-07 07:08:18
last_update2022-05-07 07:08:18
depth1
children0
last_payout2022-05-14 07:08:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,206
author_reputation189,254,431,316,230
root_title"Ruby Client for Hive: hive-ruby-1.0.3"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id112,983,727
net_rshares4,410,753,935
author_curate_reward""
vote details (1)