feat(api): add Content/VoteState/Beneficiary for condenser_api.get_content - #18
Merged
Conversation
…ntent
Add Content (the discussion object returned by condenser_api.get_content),
VoteState (active_votes element), and Beneficiary to protocol/api, for
steemdb-sync's comment rescanner.
Field types match the on-chain JSON exactly (verified against live
get_content responses + steemd source):
- share_type / large-int group (net_rshares, abs_rshares, vote_rshares,
children_abs_rshares, author_rewards, author_reputation,
total_vote_weight) and active_votes[].weight/rshares/reputation use
json.RawMessage: steemd serializes these inconsistently as JSON number
(within int32 range) or JSON string (larger), with both forms coexisting
within a single response. A typed field would fail to decode on one or
the other (same class of bug as ExtendedAccount/Manabar, b1d22f9).
- assets and timestamps stay string; id/depth/children/net_votes/etc.
stay int; allow_* stay bool.
- first_reblogged_by/on are pointers (optional on chain -> nil when absent).
The original spec draft assumed these share_type fields were always strings;
live testing showed they are int/string-mixed, so json.RawMessage is required.
Fixes the post_id field name (chain emits id, not post_id) and adds 13
fields the spec draft omitted (body_length, reward_weight,
percent_steem_dollars, root_author, root_permlink, allow_votes/replies/
curation_rewards, beneficiaries, reblogged_by, first_reblogged_by/on, id).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
Content(the discussion object),VoteState(active_votes element), andBeneficiarytoprotocol/api, for steemdb-sync's comment rescanner (Batch 5). steemgosdk will consume this via a newGetContentwrapper (separate PR, depends on a new tag here).The original spec assumed the share_type fields were always JSON strings ("实测都是 string"). Live testing against
condenser_api.get_contentshowed they are int/string-mixed, so the struct had to be corrected before landing:active_votes[].rshareshas both a JSON number (2125781185) and a JSON string ("221646137396") coexisting.net_rshares/abs_rsharesarrive as strings (large values), whiletotal_vote_weightarrives as a number (small value).Using a typed
stringfield would fail to decode the number form (and vice versa) — the same class of bug asExtendedAccount(a2cad55) andManabar.CurrentMana(b1d22f9). So all 10 such fields usejson.RawMessage, matching the established pattern.Verified against three sources: live
get_contentresponses (old + recent post), steemd C++ source (condenser_api.hpp/tags_api.hpp/types.hpp), and jussi upstream routing (get_content is not rewritten).Other corrections vs the spec
post_id→id(the chain emitsid, notpost_id).body_length,reward_weight,percent_steem_dollars,root_author,root_permlink,allow_votes/allow_replies/allow_curation_rewards,beneficiaries,reblogged_by,first_reblogged_by/first_reblogged_on(pointers, optional on chain),id.Field type strategy (matches
ExtendedAccount)"100.000 SBD")stringParseAssetstringjson.RawMessageintallow_*boolintbeneficiaries[]Beneficiary{account,weight}arrayTests
go build ./...+go test ./...all green; existing tests unaffected.TestUnmarshal_Content_FullFixture— recent post fixture; covers RawMessage string form (net_rshares) + number form (total_vote_weight), and mixedactive_votes[].rsharesforms within one response.TestUnmarshal_Content_OldPost— legacy post; covers the other half (small values as numbers, plus weight as string / rshares as number).After merge
This needs a
v0.0.30tag so steemgosdk can consume it.