HiveSQL - Dynamic Global Properties
Let's try to understand what Hive dynamic global properties are. According to Hive Developer Portal:
Dynamic Global Properties represent a set of values that are calculated during normal chain operations and reflect the current values of global blockchain properties.
The API returns an object containing information that changes every block interval such as the head block number, the total vesting fund, etc.
Ok. So this is my understanding based on the above description.
- These are values/properties that have to do with Hive blockchain itself as a whole, rather than individual accounts or transactions on the chain.
- And these values more likely to change after each block production.
- There is an API call that returns these values when needed.
Feel free to go to https://hivelibrarian.herokuapp.com/ and click "Get DGP" in dynamic global properties section to see what they are.
First, I tried to get these dynamic global properties using HiveSQL. Why? Because I needed one or two of them in my code. About that in a little bit.
But then I also tried to get the same dynamic global properties using Beem and using Lighthive. I didn't get all identical results from them. And I don't mean identical values, I mean I didn't get same amount of properties returned.
Let's start with Lighthive.
from lighthive.client import Client import pprint client = Client() props = client.get_dynamic_global_properties() pprint.pprint(props) print(len(props))
This returned 38 properties with their values.
Now let's try with Beem.
from beem import Hive from beem.nodelist import NodeList from beem.amount import Amount import pprint nodelist = NodeList() nodelist.update_nodes() nodes = nodelist.get_hive_nodes() hive = Hive(node=nodes) globalprops = hive.get_dynamic_global_properties() count = 1 for prop in globalprops: print(count, prop, globalprops[prop]) count +=1 print(count-1)
Beeem returned 39 properties with their values. It seems LightHive doesn't include
id. Ok, I don't need id anyway.
But when we try to get the same dynamic global properties from HiveSQL we get 58 properties with values returned. Let's try.
import os import pymssql import datetime as dt from pprint import pprint def hive_sql(SQLCommand, limit): db = os.environ['HIVESQL'].split() conn = pymssql.connect(server=db, user=db, password=db, database=db) cursor = conn.cursor() cursor.execute(SQLCommand) result = cursor.fetchmany(limit) conn.close() return result SQLCommand = ''' SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'DynamicGlobalProperties' ''' result = hive_sql(SQLCommand, 100) col_names =  for col_name in result: col_names.append(col_name) SQLCommand = ''' SELECT * FROM DynamicGlobalProperties ''' result = hive_sql(SQLCommand, 100) col_values =  for col_value in result: col_values.append(col_value) dgp = dict(zip(col_names, col_values)) pprint(dgp) print(len(dgp))
The returned results for dynamic global properties from HiveSQL are at the end of the post.
As I was trying to understand why HiveSQL returns more properties compared to Beem or LightHive, I noticed how HiveSQL splits some of the properties into two, especially to differentiate the asset names like Hive, HBD, and VESTS. That's kinda helpful. I like that.
However, that's not it. There are more properties that HiveSQL returns that do not appear on returned results from Beem and LightHive at all. These properties are:
I don't know there is this discrepancy. But it a helpful discrepancy. Because I have been using
hve_per_vest a lot to convert vests to hp. That is super helpful. I can also see
price_hbd_usd to be really helpful.
I am assuming those referring to steem, sbd, and smts might be old column names. I don't know. If anybody can explain that will be great. Especially, please tell me what
confidential_supply is? :)
Anyway, it is great to have easy access to these properties and values. You never know when you might need them. Now everybody can get them. Hive is not confidential. lol
One more thing.
Hive Developer Portal is still referring to assets as sbd and steem. That probably needs to be updated to HBD and Hive.
Here is the list of dynamic global properties and current values:
Posted Using LeoFinance Beta