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

rpcserver: Handle genesis in getblockchaininfo. #2237

Merged
merged 1 commit into from
Jul 2, 2020

Conversation

rstaudt2
Copy link
Member

@rstaudt2 rstaudt2 commented Jul 2, 2020

This updates handleGetBlockchainInfo to properly return blockchain info
in the case of an empty blockchain where only the genesis block exists.

Also added tests to cover handleGetBlockchainInfo.

This can be tested manually with an empty blockchain by running dcrd with --connect=127.0.0.1 (so that it doesn't connect to any peers) and --datadir=~/some-tmp-dir to give it an empty database.

Fixes #2235

rpcserver.go Outdated Show resolved Hide resolved
rpcserverhandlers_test.go Outdated Show resolved Hide resolved
rpcserverhandlers_test.go Outdated Show resolved Hide resolved
This updates handleGetBlockchainInfo to properly return blockchain info
in the case of an empty blockchain where only the genesis block exists.
@rstaudt2 rstaudt2 force-pushed the getblockchaininfo-empty-blockchain branch from 8ed0f4a to db6b44d Compare July 2, 2020 10:32
Copy link
Member

@matheusd matheusd left a comment

Choose a reason for hiding this comment

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

Thank you for the speedy fix! :P

Copy link
Member

@davecgh davecgh left a comment

Choose a reason for hiding this comment

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

I also tested that it works correctly both on an empty and non-empty chain.

@davecgh davecgh merged commit cee62c3 into decred:master Jul 2, 2020
@rstaudt2 rstaudt2 mentioned this pull request Jul 4, 2020
76 tasks
@rstaudt2 rstaudt2 deleted the getblockchaininfo-empty-blockchain branch January 15, 2021 12:43
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.

rpcserver: getblockchaininfo is not queryable on an empty blockchain
3 participants