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

Add blocks/bytes uploaded/downloaded stats #557

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

HDegroote
Copy link
Contributor

If you prefer, we can also use

blocks: { uploaded: 0, downloaded: 0 }

Instead of

blocksUploaded: 0,
blocksDownloaded: 0

But I found that looked a bit strange (particularly for bytes)

@@ -2004,6 +2017,10 @@ module.exports = class Replicator {

_ondata (peer, req, data) {
if (data.block !== null) {
this.stats.blocksDownloaded++
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please double check that this code runs if-and-only-if a block was downloaded. I think this is the correct shared path, but not 100% sure

@@ -2004,6 +2017,10 @@ module.exports = class Replicator {

_ondata (peer, req, data) {
if (data.block !== null) {
this.stats.blocksDownloaded++
this.stats.bytesDownloaded += data.block.value.byteLength
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: this will crash if a block ever does not contain a Buffer block.value entry. The code assumes this never happens (which I think is true, but good to confirm)

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.

1 participant