Condenser uses steemd's get_state to fetch a large state tree, provided a URL path. Internally, get_state branches on request path and makes a number of API calls, bundling them into a single response. (view implementation)
Issues with this approach
core reliance on get_state contributes to condenser inflexibility
the data get_state provides is being moved to a number of different services
with appbase release, get_state is deprecated
extraneous data we don't use
General response format
The response is saved in condenser's state.global.
{
"current_route": <url>,
"props": <get_dynamic_global_properties()> // basic chain properties. a few keys are relevant
"tag_idx": {
"trending": <get_trending_tags().map(name)> // simple array of trending tags used on homepage etc
},
"tags": <get_trending_tags()>, // only used for tag "explorer" page
"content": {*url: post_object} // posts keyed by author/permlink
"accounts": {*name: account_object} // relevant accounts keyed by name
"pow_queue": [], // unused/ignore
"witnesses": <get_witnesses_by_vote()>, // only used for /~witnesses
"discussion_idx": {....}, // ordered post keys, keyed by (1) current tag (or ""), (2), active sort (e.g. created/trending)
"witness_schedule": {<get_witness_schedule_object()>} // unused/ignore
"feed_price": {<get_current_median_history_price()>} // referenced from: wallet, market, and signup_bonus(unused?)
"error": ""
}
Distinct request types
The structure changes depending on the request type. I will document these in greater detail later.
RT1. lists of posts (e.g. /created, /trending, /@user/feed, @user/blog)
RT2. discussion thread (/category/user/permlink)
RT3. tag "explorer" (/tags)
RT4. witness page (/~witnesses)
RT5. account history (/user/transfers)
RT6. "invalid" / misc -- condenser calls get_state on every URL, even for paths which it does not explicitly handle (e.g. /market). in these cases, steemd returns a basic skeleton which does includes the props key and feed_price key, which condenser uses.
First course of action
Handle the RT6 "invalid" case, i.e. do not call get_state on pages it's not meant to explicitly handle. This means we need to remove core reliance (which is fairly minimal, as shown below) on state.global and move general info into tidy branches.
props can be attained by calling get_dynamic_global_properties. total_vesting_* are only referenced in src/app/utils/StateFunctions.js and used to convert SP to VESTS and vice versa. I haven't looked into the full extent of their usage, but this is generally useful to have at hand. sbd_interest_rate is only used on the wallet page.
feed_price is attained by calling get_current_median_history_price, and it's only used on (a) the wallet page (to calculate estimated wallet balance), (b) the market (though commented out), and (c) to calculate state.offchain.signup_bonus which I'm not sure is used anymore.
Second course of action
RT5: remove get_state from /user/transfers, replace with get_account() and get_account_history()
RT4: remove get_state reliance on /~witnesses; all that's needed to populate that page is a get_witnesses_by_vote call.
RT3: (optional) remove get_state from /tags, replace with get_trending_tags() call
RT1, RT2 can remain in place for now; hivemind will provide a compatible API for them until we move to new APIs. That will be a separate project.
Condenser uses steemd's
get_state
to fetch a large state tree, provided a URL path. Internally,get_state
branches on request path and makes a number of API calls, bundling them into a single response. (view implementation)Issues with this approach
General response format
The response is saved in condenser's
state.global
.Distinct request types
The structure changes depending on the request type. I will document these in greater detail later.
RT1. lists of posts (e.g.
/created
,/trending
,/@user/feed
,@user/blog
) RT2. discussion thread (/category/user/permlink
) RT3. tag "explorer" (/tags
) RT4. witness page (/~witnesses
) RT5. account history (/user/transfers
) RT6. "invalid" / misc -- condenser calls get_state on every URL, even for paths which it does not explicitly handle (e.g./market
). in these cases, steemd returns a basic skeleton which does includes theprops
key andfeed_price
key, which condenser uses.First course of action
Handle the RT6 "invalid" case, i.e. do not call
get_state
on pages it's not meant to explicitly handle. This means we need to remove core reliance (which is fairly minimal, as shown below) onstate.global
and move general info into tidy branches.Here's the get_state response for invalid URLs:
Here's the subset of the response which is actually (potentially) relevant:
props
can be attained by callingget_dynamic_global_properties
.total_vesting_*
are only referenced insrc/app/utils/StateFunctions.js
and used to convert SP to VESTS and vice versa. I haven't looked into the full extent of their usage, but this is generally useful to have at hand.sbd_interest_rate
is only used on the wallet page.feed_price
is attained by callingget_current_median_history_price
, and it's only used on (a) the wallet page (to calculate estimated wallet balance), (b) the market (though commented out), and (c) to calculatestate.offchain.signup_bonus
which I'm not sure is used anymore.Second course of action
get_state
from/user/transfers
, replace withget_account()
andget_account_history()
get_state
reliance on/~witnesses
; all that's needed to populate that page is aget_witnesses_by_vote
call.get_state
from/tags
, replace withget_trending_tags()
callRT1, RT2 can remain in place for now; hivemind will provide a compatible API for them until we move to new APIs. That will be a separate project.