Skip to content

Make raw data optional in API Requests - #996

Merged
PaulBernier merged 4 commits into
FactomProject:FD-1225_wax_rollupfrom
WhoSoup:WhoSoup-no_raw
Aug 21, 2020
Merged

PaulBernier merged 4 commits into
FactomProject:FD-1225_wax_rollupfrom
WhoSoup:WhoSoup-no_raw

Conversation

@WhoSoup

@WhoSoup WhoSoup commented May 6, 2020

Copy link
Copy Markdown
Member

I was analyzing D/EC blocks for an unrelated issue and noticed that the API will always send both the json data and the raw message, even if you don't need both. This wastes quite a bit of bandwidth particularly for EC blocks (they're huge due to PegNet). There already is a "get-raw" endpoint for those that only need the raw data but no way to get just the json without the raw.

This changes the following endpoints:

  • admin-block
  • factoid-block
  • entrycredit-block
  • dblock-by-height
  • ecblock-by-height
  • fblock-by-height
  • ablock-by-height

("directory-block" itself doesn't even have a raw option, oddly enough)

It adds an optional "noraw" argument to the json call that accepts either "true" or "false". If "noraw" is not present, everything works as before. If "noraw" is true, the API won't return the raw data.

Benchmarked on a LAN copy of factomd, trying to download 3,000 ecblocks (240650 to 243650):

Time Size
w/ raw 18.6817609s 286.29941082 Mebibyte
no raw 13.887978s 160.519980431 Mebibyte

A ~44% reduction in size and 26% reduction in transfer duration.

Comment thread wsapi/wsapiStructs.go
PaulSnow
PaulSnow previously approved these changes Jun 3, 2020

@PaulSnow PaulSnow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low level request to clarify the negative boolean, but not a blocking issue.

Comment thread wsapi/wsapiStructs.go
@WhoSoup

WhoSoup commented Jun 4, 2020

Copy link
Copy Markdown
Member Author

Added both suggestions

@PaulBernier
PaulBernier changed the base branch from master to FD-1225_wax_rollup August 19, 2020 01:11
@PaulBernier
PaulBernier changed the base branch from FD-1225_wax_rollup to master August 19, 2020 01:11
@PaulBernier

Copy link
Copy Markdown
Contributor

This is looking good, can you rebase the PR against wax rollup @WhoSoup

@WhoSoup
WhoSoup changed the base branch from master to FD-1225_wax_rollup August 19, 2020 08:01
@WhoSoup

WhoSoup commented Aug 19, 2020 •

Copy link
Copy Markdown
Member Author

It's rebased. The test that fails is in the p2p package and unrelated to this PR. I have run the wsapi package test locally and it passed.

Edit: #1023

Comment thread wsapi/wsapiStructs.go Outdated
@PaulBernier
PaulBernier merged commit 3708810 into FactomProject:FD-1225_wax_rollup Aug 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants