Skip to content

core/commands/dag/stat: improve output#10987

Closed
hsanjuan wants to merge 1 commit intomasterfrom
dag-stat-progress-improvement
Closed

core/commands/dag/stat: improve output#10987
hsanjuan wants to merge 1 commit intomasterfrom
dag-stat-progress-improvement

Conversation

@hsanjuan
Copy link
Contributor

ipfs dag stat -h says:

USAGE
  ipfs dag stat <root>... - Gets stats for a DAG.

  ipfs dag stat [--progress=false] [--] <root>...

but --progress defaults to true.

So by default it prints this :

ipfs dag stat -progress=true QmUWfSKRTZGTHuYhV4kBTrS8fJEV2GPzeXcdhxUGPuYTnJ
CID: QmUWfSKRTZGTHuYhV4kBTrS8fJEV2GPzeXcdhxUGPuYTnJ, Size: 95, NumBlocks: 1
CID: QmUWfSKRTZGTHuYhV4kBTrS8fJEV2GPzeXcdhxUGPuYTnJ, Size: 202, NumBlocks: 2
CID: QmUWfSKRTZGTHuYhV4kBTrS8fJEV2GPzeXcdhxUGPuYTnJ, Size: 8912, NumBlocks: 3
CID: QmUWfSKRTZGTHuYhV4kBTrS8fJEV2GPzeXcdhxUGPuYTnJ, Size: 271056, NumBlocks: 4
CID: QmUWfSKRTZGTHuYhV4kBTrS8fJEV2GPzeXcdhxUGPuYTnJ, Size: 533200, NumBlocks: 5
...

<actual dag stat summary>.

I find this confusing. Is this intended? This PR switches to:

ipfs dag stat QmUWfSKRTZGTHuYhV4kBTrS8fJEV2GPzeXcdhxUGPuYTnJ
CID: QmUWfSKRTZGTHuYhV4kBTrS8fJEV2GPzeXcdhxUGPuYTnJ, Size: 95, NumBlocks: -1
CID: QmaCxzMg6FZRkDi61q4ymWcCvoj6GkuBo5mVszi5DHBpb1, Size: 107, NumBlocks: -1
CID: QmUf2ynPG2wCJe3zLaASNJrQKN3BkboD2VRAKcwteDAUQB, Size: 8710, NumBlocks: -1
CID: bafkreibspggfqizukzodgaivbqusjz2xugesiaf3cutlf5rayzkfawhyry, Size: 262144, NumBlocks: -1
CID: bafkreicagz2co2ryds5auotj5kgwbqt7mvfzua4o54fv24rbycodytnmuu, Size: 262144, NumBlocks: -1
...

<actual summary>

which means it lists the nodes that are traversed as it makes progress traversing the DAG.

`ipfs dag stat -h` says:

```
USAGE
  ipfs dag stat <root>... - Gets stats for a DAG.

  ipfs dag stat [--progress=false] [--] <root>...
```

but `--progress` defaults to `true`.

So by default it prints this :

```
ipfs dag stat -progress=true QmUWfSKRTZGTHuYhV4kBTrS8fJEV2GPzeXcdhxUGPuYTnJ
CID: QmUWfSKRTZGTHuYhV4kBTrS8fJEV2GPzeXcdhxUGPuYTnJ, Size: 95, NumBlocks: 1
CID: QmUWfSKRTZGTHuYhV4kBTrS8fJEV2GPzeXcdhxUGPuYTnJ, Size: 202, NumBlocks: 2
CID: QmUWfSKRTZGTHuYhV4kBTrS8fJEV2GPzeXcdhxUGPuYTnJ, Size: 8912, NumBlocks: 3
CID: QmUWfSKRTZGTHuYhV4kBTrS8fJEV2GPzeXcdhxUGPuYTnJ, Size: 271056, NumBlocks: 4
CID: QmUWfSKRTZGTHuYhV4kBTrS8fJEV2GPzeXcdhxUGPuYTnJ, Size: 533200, NumBlocks: 5
...

<actual dag stat summary>.
```

I find this confusing. Is this intended? This PR switches to:

```
ipfs dag stat QmUWfSKRTZGTHuYhV4kBTrS8fJEV2GPzeXcdhxUGPuYTnJ
CID: QmUWfSKRTZGTHuYhV4kBTrS8fJEV2GPzeXcdhxUGPuYTnJ, Size: 95, NumBlocks: -1
CID: QmaCxzMg6FZRkDi61q4ymWcCvoj6GkuBo5mVszi5DHBpb1, Size: 107, NumBlocks: -1
CID: QmUf2ynPG2wCJe3zLaASNJrQKN3BkboD2VRAKcwteDAUQB, Size: 8710, NumBlocks: -1
CID: bafkreibspggfqizukzodgaivbqusjz2xugesiaf3cutlf5rayzkfawhyry, Size: 262144, NumBlocks: -1
CID: bafkreicagz2co2ryds5auotj5kgwbqt7mvfzua4o54fv24rbycodytnmuu, Size: 262144, NumBlocks: -1
...

<actual summary>
```

which means it lists the nodes that are traversed as it makes progress traversing the DAG.
@hsanjuan hsanjuan self-assigned this Sep 24, 2025
@hsanjuan hsanjuan requested a review from a team as a code owner September 24, 2025 09:50
Comment on lines +55 to +59
curDagstats := &DagStat{
Cid: current.Node.Cid(),
Size: currentNodeSize,
NumBlocks: -1,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If curDagstate is only used inside the if progressive { block, then can this code be moved into there?

@lidel
Copy link
Member

lidel commented Sep 30, 2025

Triage notes:

  • we need to discuss the UX, alternative is to clear the line and only update Size/ NumbBlocks, wiothout printing multiple lines.
    • maybe we could have interactive and non-interactive versions?

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