create account

HiveSQL new feature - Delegation state table available by arcange

View this thread on: hive.blogpeakd.comecency.com
· @arcange · (edited)
$6.76
HiveSQL new feature - Delegation state table available
![](https://i.imgur.com/FE9D32t.png)

Retrieving information about Hive Power delegations can be a bit tricky.

While the Hive API makes it easy to know to whom an account is delegating using `condenser_api.get_vesting_delegations`, the opposite is more difficult. As far as I know, there is no API call to know who has delegated to an account.

### HiveSQL to the rescue - Episode 1

Fortunately, HiveSQL allows you to easily retrieve this information thanks to the `TxDelegateVestingShares` table which includes all creation, modification or removal of delegation operations carried out by users.

However, the main difficulty comes from the fact that you have to check the last `delegate_vesting_share` operation involving two accounts to get the state of the delegation between these accounts.

In addition, there is a very particular event that must also be taken into account: the hardfork 23 that happened when the Hive blockchain split from Steem.

Indeed, at this time, several accounts have not been airdropped with HIVE tokens, so their existing delegations were instantly removed.

However, there were no operations of type `delegate_vesting_share` relating to this. This was recorded in the blockchain with `hardfork_hive` virtual  operations, stored in the `VOHardforkHives` table in HiveSQL

### HiveSQL to the rescue - Episode 2

Due to all the technical reasons mentioned above, retrieving an accurate list of delegators or delegatees has become much more complex and resources consuming.

That's why I added a new non-consensus state table named `Delegations` to the HiveSQL database in order to allow its users to retrieve delegations data quickly and easily.

It contains the list of all active delegations with the following info:

|Column|Description|
|-|-|
|delegator|The account delegating Hive Power|
|delegating|The account receiving Hive Power delegation|
|vests|The amount of Vesting Shares delegated|

## Support

If you have any questions or remarks, support is provided on the [HiveSQL Discord Channel](https://discord.gg/kyEFDfT).

Thank you.

---
<center>

### Check out my apps and services
<a href="/hive/@hive.engage/stay-connected-with-your-hive-audience-and-catch-attention"><img src="https://i.imgur.com/GiNJqlm.png"></a><a href="/@hivebuzz"><img src="https://i.imgur.com/B4UTun2.png"></a><a href="/@hivesql"><img src="https://i.imgur.com/EPN8RW6.png"></a><a href="/hive/@arcange/introducing-hive-account-recovery"><img src="https://i.imgur.com/6TWeW7V.png"></a><a href="/@hive.autoclaim"><img src="https://i.imgur.com/ih2pEOw.png"></a></center>
<center>

### [Vote for me as a witness ![](https://i.imgur.com/2bi4SnT.png)](https://hivesigner.com/sign/account-witness-vote?witness=arcange&approve=1)
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 171 others
properties (23)
authorarcange
permlinkhivesql-new-feature-delegation-state-table-availaible
categoryhive-139531
json_metadata"{"app":"peakd/2020.10.9","format":"markdown","description":"Retrieving information about Hive Power delegations can be a bit tricky. Thanks to HiveSQL, it's now easier than ever.","tags":["hivesql","hive","sql","database","hive-139531"],"users":["hive.engage","hivebuzz","hivesql","arcange","hive.autoclaim"],"links":["https://discord.gg/kyEFDfT","/hive/@hive.engage/stay-connected-with-your-hive-audience-and-catch-attention","/@hivebuzz","/@hivesql","/hive/@arcange/introducing-hive-account-recovery","/@hive.autoclaim","https://hivesigner.com/sign/account-witness-vote?witness=arcange&amp;approve=1"],"image":["https://i.imgur.com/FE9D32t.png","https://i.imgur.com/GiNJqlm.png","https://i.imgur.com/B4UTun2.png","https://i.imgur.com/EPN8RW6.png","https://i.imgur.com/6TWeW7V.png","https://i.imgur.com/ih2pEOw.png","https://i.imgur.com/2bi4SnT.png"]}"
created2020-11-03 14:32:42
last_update2020-11-03 17:08:27
depth0
children6
last_payout2020-11-10 14:32:42
cashout_time1969-12-31 23:59:59
total_payout_value3.548 HBD
curator_payout_value3.212 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,738
author_reputation1,146,633,668,945,473
root_title"HiveSQL new feature - Delegation state table available"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,374,709
net_rshares32,663,335,430,877
author_curate_reward""
vote details (235)
@abh12345 ·
Nice!
👍  
properties (23)
authorabh12345
permlinkre-arcange-qj8ed7
categoryhive-139531
json_metadata{"tags":["hive-139531"],"app":"peakd/2020.10.9"}
created2020-11-03 17:39:09
last_update2020-11-03 17:39:09
depth1
children1
last_payout2020-11-10 17:39:09
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_length5
author_reputation1,408,615,966,842,648
root_title"HiveSQL new feature - Delegation state table available"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,376,858
net_rshares53,212,303,529
author_curate_reward""
vote details (1)
@arcange ·
Hehe, I knew you would like it 😉<div class="pull-right"><a href="/@hive.engage">![](https://i.imgur.com/XsrNmcl.png)</a></div>
properties (22)
authorarcange
permlinkre-re-arcange-qj8ed7
categoryhive-139531
json_metadata{"app":"engage"}
created2020-11-03 19:48:12
last_update2020-11-03 19:48:12
depth2
children0
last_payout2020-11-10 19:48:12
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_length126
author_reputation1,146,633,668,945,473
root_title"HiveSQL new feature - Delegation state table available"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,378,288
net_rshares0
@hivebuzz ·
$0.03
Congratulations @arcange! 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/@arcange/upvoted.png?202011031437"></td><td>You received more than 350000 upvotes. Your next target is to reach 360000 upvotes.</td></tr>
</table>

<sub>_You can view your badges on [your board](https://hivebuzz.me/@arcange) 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>



**Do not miss the last post from @hivebuzz:**
<table><tr><td><a href="/hivebuzz/@hivebuzz/pud-202011-feedback"><img src="https://images.hive.blog/64x128/https://i.imgur.com/lZQYVmN.png"></a></td><td><a href="/hivebuzz/@hivebuzz/pud-202011-feedback">Feedback from the November 1st Hive Power Up Day</a></td></tr></table>
👍  
properties (23)
authorhivebuzz
permlinkhivebuzz-notify-arcange-20201103t145135000z
categoryhive-139531
json_metadata{"image":["http://hivebuzz.me/notify.t6.png"]}
created2020-11-03 14:51:33
last_update2020-11-03 14:51:33
depth1
children0
last_payout2020-11-10 14:51:33
cashout_time1969-12-31 23:59:59
total_payout_value0.016 HBD
curator_payout_value0.016 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length948
author_reputation369,406,463,435,726
root_title"HiveSQL new feature - Delegation state table available"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,374,959
net_rshares259,520,683,486
author_curate_reward""
vote details (1)
@pixresteemer ·
<center>![pixresteemer_incognito_angel_mini.png](https://files.peakd.com/file/peakd-hive/pixresteemer/8h7BBw1w-pixresteemer_incognito_angel_mini.png)</center><center>Bang, I did it again... I just rehived your post!</center><center>Week 30 of my [contest](/hive-179017/@pixresteemer/the-re-hive-contest-results-week-29-and-start-week-30) just started...you can now check the winners of the previous week!</center><center><sub>9</sub></center>
properties (22)
authorpixresteemer
permlink20201103t144842011z
categoryhive-139531
json_metadata{"tags":["pixresteemer"],"app":"pixresteemer"}
created2020-11-03 14:48:42
last_update2020-11-03 14:48:42
depth1
children0
last_payout2020-11-10 14:48: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_length442
author_reputation121,314,585,119,707
root_title"HiveSQL new feature - Delegation state table available"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,374,926
net_rshares0
@vimm ·
Beautiful! This should simplify things a bit.
properties (22)
authorvimm
permlinkre-arcange-qj88eg
categoryhive-139531
json_metadata{"tags":["hive-139531"],"app":"peakd/2020.10.9"}
created2020-11-03 15:30:15
last_update2020-11-03 15:30:15
depth1
children1
last_payout2020-11-10 15:30:15
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_length45
author_reputation142,339,878,687,537
root_title"HiveSQL new feature - Delegation state table available"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,375,407
net_rshares0
@arcange ·
That's the goal 😉<div class="pull-right"><a href="/@hive.engage">![](https://i.imgur.com/XsrNmcl.png)</a></div>
properties (22)
authorarcange
permlinkre-re-arcange-qj88eg
categoryhive-139531
json_metadata{"app":"engage"}
created2020-11-03 16:25:00
last_update2020-11-03 16:25:00
depth2
children0
last_payout2020-11-10 16:25:00
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_length111
author_reputation1,146,633,668,945,473
root_title"HiveSQL new feature - Delegation state table available"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,376,052
net_rshares0