-
Notifications
You must be signed in to change notification settings - Fork 128
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
Chainwork DB upgrade. Hashrate and Chainwork charts. #808
Conversation
We're discussing in Slack if dcrd/rpcclient and dcrd/dcrjson are ready for a new version tag so we can bump the module without using a pseudo-version. |
f4cdd98
to
c6ddde7
Compare
I kept all the changes in this PR, even though the title is a little outdated. This will add a new column to your PostgreSQL blocks table. I've just been dropping the column from the table on the command line as needed. I took a couple of liberties with the units. Since chainwork is a 32-byte hex string representing a number > 2^64, for use in JSON/charts I converted work to exahash and hashrate to terahash/s. |
a12b0a3
to
f8b56fa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, the node may not have orphaned/side chain blocks that in dcrdata's database. If it does not have a non-mainchain block, the "Block not found" error from dcrd can be ignored and the loop continued at the next row.
For instance, I get:
2018-11-23 13:37:36.794 [INF] PSQL: Adding column chainwork to table blocks...
2018-11-23 13:37:36.795 [INF] PSQL: Syncing chainwork. This might take a while...
2018-11-23 13:38:25.521 [ERR] PSQL: GetChainWork failed (000000000000000044b4a0c4ff6fdf5d32396a31333ab0fe3013ee9262e21b99). Aborting chainwork sync.: -5: Block not found: 000000000000000044b4a0c4ff6fdf5d32396a31333ab0fe3013ee9262e21b99
2018-11-23 13:38:25.535 [INF] DATD: Closing connection to dcrd.
2018-11-23 13:38:25.535 [INF] DATD: Bye!
2018-11-23 13:38:25.786 [ERR] DATD: failed to upgrade blocks table to version 3.7.0. Error: new chainwork column upgrade of blocks table ended prematurely after 289471 rows.Error: -5: Block not found: 000000000000000044b4a0c4ff6fdf5d32396a31333ab0fe3013ee9262e21b99
BTW, I was testing a rebased version: https://github.com/chappjc/dcrdata/tree/chainwork-api |
f8b56fa
to
d071475
Compare
This adds chainwork to the dcrpg blocks table to support hashrate and work charts. This performs a PostgreSQL DB upgrade, adding a TEXT column, chainwork. Relevant block insertion routines are updated to grab the newly available chainwork value from dcrd. Having chainwork also enables quick calculation of network hashrate data. A network hashrate chart and "total work" chart have been added to /charts.
Resolves #744 and #723.
This PR performs a PostgreSQL DB upgrade, adding a
TEXT
column,chainwork
. Relevant block insertion routines are updated to grab the newly available chainwork value from dcrd. Having chainwork also enables quick calculation of network hashrate data. A network hashrate chart and "total work" chart have been added to/charts
.