Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

block: add toJSON and fromJSON to Block. #12

Closed
wants to merge 3 commits into from

Conversation

chjj
Copy link
Member

@chjj chjj commented May 18, 2014

Now that we have a Block framer, I thought this would be nice to add, in case we ever want to (or a user wants to) store full blocks.

var raw = utils.toArray(json.block, 'hex');

var block = new bcoin.block(json.subtype === 'merkleblock'
? new bcoin.protocol.parser().parseMerkleBlock(raw)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please put ? and : at the end of the lines.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, wouldn't it make sense to create parser on the previous line and use it in both cases?

@chjj
Copy link
Member Author

chjj commented May 18, 2014

Should be good to go. :)

@indutny
Copy link
Collaborator

indutny commented May 18, 2014

Test? ;)

@chjj
Copy link
Member Author

chjj commented May 18, 2014

Added tests for the framer/new .render method too. :)

@indutny
Copy link
Collaborator

indutny commented May 18, 2014

Thank you, landed!

@indutny indutny closed this May 18, 2014
tuxcanfly added a commit that referenced this pull request Jun 20, 2018
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.

2 participants