create account

Update for beem: improved account history handling by holger80

View this thread on: hive.blogpeakd.comecency.com
· @holger80 ·
$68.01
Update for beem: improved account history handling


## Repository

https://github.com/holgern/beem<center>
![beem-logo](https://cdn.steemitimages.com/DQmcRrwLPSywSYMierfP6um6mejeMNGjN9Rxw7audJqTDgb/beem-logo)
</center>

[beem](https://github.com/holgern/beem) is a python library and command line tool for HIVE.  The current version is 0.24.18.

There is also a discord channel for beem: https://discord.gg/4HM592V

The newest beem version can be installed by:

```
pip install -U beem
```

Check that you are using hive nodes. The following command 

```
beempy updatenodes --hive
```

updates the nodelist and uses only hive nodes. After setting hive as default_chain, `beempy updatenodes` can be used.

The list of nodes can be checked with

```
beempy config
```

and

```
beempy currentnode
```

shows the currently connected node.

## Changelog for 0.24.18
* Adapt account history on api changes and fixes issue #267
* Speed up history call, when limit is below 1000
* Improve unit tests for account history
* Fix estimate_virtual_op_num, when get_account_history returns an empty entry for an index
* Implement _get_operation_filter and use filter operations in history and history_reverse on the https://api.hive.blog api node

## Changelog for 0.24.17
* Fixed a bug when using skip_account_check=True
* Refactor code in Account
* Add more unit tests

## Changelog for 0.24.16
* Fix bug in bytes representation of an Amount which prevents sending certain amounts (e.g. 8.19 HIVE)
* Added unit tests to check if 8.190 is correctly working

## Fixing rounding errors in transfers
In version 0.24.16, a rounding bug was fixed which prevents sending 8.19 HIVE. This bug leads to a wrong signature, which then prevents broadcasting the transfer op. This is now fixed.

## Improved error handling in account history
The account history and history_reverse functions have now a better error handling.
The returned index is now checked, which prevents that account history elements were added twice to the output.

## New filtered account history
Currently the new filter parameter are only implemented at "https://api.hive.blog" API node.

On this node, the get_account_history call has two more parameters: operation_filter_low and operation_filter_high.
These parameters are a bitmask of all possible operation names.
They can be obtained with the `_get_operation_filter` function:
```
operation_filter_low, operation_filter_high = account._get_operation_filter(only_ops=["transfer", "vote"])
```
which results in operation_filter_low=5 and operation_filter_high=0.

The `history` and `history_reverse` function from beem will now use the operation_filter when 
"https://api.hive.blog" is set as node. This speeds up receiving account history data up to 100 %.


### History reverse with operation_filter
```
from beem.account import Account
from beem import Hive
import time
hive = Hive("https://api.hive.blog")
acc = Account("holger80", blockchain_instance=hive)
start_time = time.time()
n_op = acc.virtual_op_count()
transfer_ops = list(acc.history_reverse(only_ops=["transfer"]))
print("Time needed to search all transfers in %d history elements: %.2f s" % (n_op, (time.time() - start_time)))
print("%d transfer op have been found" % (len(transfer_ops)))
```

returns
```
Time needed to search all transfers in 283514 history elements: 145.66 s
4666 transfer op have been found
```

### History with operation_filter
```
from beem.account import Account
from beem import Hive
import time
hive = Hive("https://api.hive.blog")
acc = Account("holger80", blockchain_instance=hive)
start_time = time.time()
n_op = acc.virtual_op_count()
transfer_ops = list(acc.history(only_ops=["transfer"]))
print("Time needed to search all transfers in %d history elements: %.2f s" % (n_op, (time.time() - start_time)))
print("%d transfer op have been found" % (len(transfer_ops)))
```
returns
```
Time needed to search all transfers in 283517 history elements: 144.55 s
4666 transfer op have been found
```

### History without operation filter
Now we do the same without filtering:
```
from beem.account import Account
from beem import Hive
import time
hive = Hive("https://api.hive.blog")
acc = Account("holger80", blockchain_instance=hive)
start_time = time.time()
n_op = acc.virtual_op_count()
transfer_ops = []
for op in acc.history():
    if op["type"] == "transfer":
        transfer_ops.append(op)
print("Time needed to search all transfers in %d history elements: %.2f s" % (n_op, (time.time() - start_time)))
print("%d transfer op have been found" % (len(transfer_ops)))
```
returns
```
Time needed to search all transfers in 283518 history elements: 261.63 s
4666 transfer op have been found
```


___

*If you like what I do, consider casting a vote for me as witness on [Hivesigner](https://hivesigner.com/sign/account-witness-vote?witness=holger80&approve=1) or on [PeakD](https://peakd.com/witnesses)*
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 478 others
properties (23)
authorholger80
permlinkupdate-for-beem-improved-account-history-handling
categoryhive-139531
json_metadata"{"canonical_url": "https://hive.blog/hive-139531/@holger80/update-for-beem-improved-account-history-handling", "community": "hive-139531", "app": "beempy/0.24.18", "links": ["https://github.com/holgern/beem", "https://cdn.steemitimages.com/DQmcRrwLPSywSYMierfP6um6mejeMNGjN9Rxw7audJqTDgb/beem-logo", "https://discord.gg/4HM592V", "https://api.hive.blog", "https://hivesigner.com/sign/account-witness-vote?witness=holger80&approve=1", "https://peakd.com/witnesses"], "tags": ["development", "beem", "python", "#267"]}"
created2020-11-06 23:29:39
last_update2020-11-06 23:29:39
depth0
children7
last_payout2020-11-13 23:29:39
cashout_time1969-12-31 23:59:59
total_payout_value37.960 HBD
curator_payout_value30.052 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,856
author_reputation358,857,509,568,825
root_title"Update for beem: improved account history handling"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,422,691
net_rshares301,234,085,868,573
author_curate_reward""
vote details (542)
@co2admin ·
Upvoted to thank you @holger80 for supporting the [CO2Fund](https://peakd.com/@co2fund) by, e.g., supporting posts, banner presentation, SP/HP delegation, dustsweeper gifts, helpful tools, etc.
properties (22)
authorco2admin
permlinkre-update-for-beem-improved-account-history-handling-20201106t233236z
categoryhive-139531
json_metadata"{"app": "rewarding/0.1.0"}"
created2020-11-06 23:32:36
last_update2020-11-06 23:32:36
depth1
children0
last_payout2020-11-13 23:32:36
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_length193
author_reputation3,792,666,189
root_title"Update for beem: improved account history handling"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,422,726
net_rshares0
@hivebuzz ·
Congratulations @holger80! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :

<table><tr><td><img src="https://images.hive.blog/60x70/http://hivebuzz.me/@holger80/upvotes.png?202011202137"></td><td>You distributed more than 22000 upvotes. Your next target is to reach 23000 upvotes.</td></tr>
</table>

<sub>_You can view your badges on [your board](https://hivebuzz.me/@holger80) and compare yourself to others in the [Ranking](https://hivebuzz.me/ranking)_</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>

properties (22)
authorhivebuzz
permlinkhivebuzz-notify-holger80-20201120t220435000z
categoryhive-139531
json_metadata{"image":["http://hivebuzz.me/notify.t6.png"]}
created2020-11-20 22:04:36
last_update2020-11-20 22:04:36
depth1
children0
last_payout2020-11-27 22:04:36
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_length631
author_reputation369,328,609,310,964
root_title"Update for beem: improved account history handling"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,615,655
net_rshares0
@holybread ·
Leaderboard Vote
Your current Rank (124) in the battle Arena of Holybread has granted you an Upvote of 30%
properties (22)
authorholybread
permlinkre-update-for-beem-improved-account-history-handling-20201106t233448z
categoryhive-139531
json_metadata"{"app": "beem/0.24.4"}"
created2020-11-06 23:34:48
last_update2020-11-06 23:34:48
depth1
children0
last_payout2020-11-13 23:34:48
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_length89
author_reputation11,886,070,775,640
root_title"Update for beem: improved account history handling"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,422,750
net_rshares0
@tan.app ·
<center>
<sup>Congratulations @holger80, You Earned <b>2.051 TAN</b> & Curators Made <b>2.051 TAN</b>.</sup>

<img src="https://files.peakd.com/file/peakd-hive/theguruasia/DWYqznFx-TANToken70.png" alt="tangent.token">

---
<sup>Join [CORE / VAULT Token Discord Channel](https://discord.gg/XYMrvyr) or Trade [TANGENT Token](https://hive-engine.com/?p=market&t=TAN)</sup>
<sup>[TAN Current Market Price](https://hive-engine.com/?p=market&t=TAN) : <b>0.250 HIVE</b></sup>
</center>
properties (22)
authortan.app
permlink20201110t021630467z
categoryhive-139531
json_metadata{"tags":["tan","tangent"],"app":"tan-bot/1.1","format":"markdown"}
created2020-11-10 02:16:30
last_update2020-11-10 02:16:30
depth1
children0
last_payout2020-11-17 02:16:30
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_length486
author_reputation164,160,871,793
root_title"Update for beem: improved account history handling"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,464,857
net_rshares0
@theguruasia · (edited)
@holger80,
Very useful, thank you for your effort!
$tangent

Cheers~
properties (22)
authortheguruasia
permlinkre-holger80-qjfypg
categoryhive-139531
json_metadata{"tags":["hive-139531"],"app":"peakd/2020.10.9"}
created2020-11-07 19:41:42
last_update2020-11-08 12:51:45
depth1
children1
last_payout2020-11-14 19:41:42
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_length68
author_reputation72,543,463,798,960
root_title"Update for beem: improved account history handling"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,432,946
net_rshares0
@tan.bot ·
<center>
<sup>Congratulations, @theguruasia You Successfully Trended The Post Shared By @holger80.</sup>
<sup>You Utilized <b>3/3</b> Daily Summon Bot Calls.</sup>
---
<sup>[TAN Current Market Price](https://hive-engine.com/?p=market&t=TAN) : <b>0.203 HIVE</b></sup>
</center>
properties (22)
authortan.bot
permlink20201108t125157234z
categoryhive-139531
json_metadata{"tags":["tan","tangent"],"app":"tan-bot/1.1","format":"markdown"}
created2020-11-08 12:51:57
last_update2020-11-08 12:51:57
depth2
children0
last_payout2020-11-15 12:51:57
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_length276
author_reputation44,172,891,181
root_title"Update for beem: improved account history handling"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,442,032
net_rshares0
@themarkymark ·
Thanks!
properties (22)
authorthemarkymark
permlinkre-holger80-qjeeq7
categoryhive-139531
json_metadata{"tags":["hive-139531"],"app":"peakd/2020.10.9"}
created2020-11-06 23:32:30
last_update2020-11-06 23:32:30
depth1
children0
last_payout2020-11-13 23:32:30
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_length7
author_reputation1,774,203,102,043,512
root_title"Update for beem: improved account history handling"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,422,724
net_rshares0