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

feat: add dagula walk to print CIDs as we walk the DAG #2

Closed
wants to merge 1 commit into from

Conversation

olizilla
Copy link
Contributor

I wanted a quick way to check if a remote node has an entire DAG without needing to save the block data locally, so I added dagula walk.

It could be also be called refs to match what ipfs refs does, but I went with walk.

License: MIT
Signed-off-by: Oli Evans oli@protocol.ai

I wanted a quick way to check if a remote node has an entire DAG without needing to save the block data locally, so I added `dagula walk`.

It could be also be called `refs` to match what `ipfs refs` does, but I went with `walk`.

License: MIT
Signed-off-by: Oli Evans <oli@protocol.ai>
Copy link
Member

@alanshaw alanshaw left a comment

Choose a reason for hiding this comment

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

LGTM - I'd kinda also love to have a "pretty" version that looks like the output from npm ls

@olizilla
Copy link
Contributor Author

no rush, but if you make me a maintainer, or move this to a shared org... and same for the npm module... I could merge and release.

@olizilla
Copy link
Contributor Author

I make a fancy tree one... closing this one.

@olizilla olizilla closed this Aug 26, 2022
olizilla added a commit to olizilla/dagula that referenced this pull request Aug 26, 2022
- `dagula ls` – I wanted a quick way to check if a remote node has an entire DAG without needing to save the block data locally (see web3-storage#2)
- `dagula tree` - You wanted a pretty way to see a DAG (see web3-storage#2)

So why not both!? This PR takes the liberty of yeilding the decoded Block rather than the `{ cid, bytes }` combo, so it can access the links info. It's neat because a decoded Block also as cid, and bytes, so it work! 🎉

License: MIT
Signed-off-by: Oli Evans <oli@protocol.ai>
alanshaw pushed a commit that referenced this pull request Sep 16, 2022
- `dagula ls` – I wanted a quick way to check if a remote node has an entire DAG without needing to save the block data locally (see #2)
- `dagula tree` - You wanted a pretty way to see a DAG

So why not both!? This PR takes the liberty of yeilding the decoded Block rather than the `{ cid, bytes }` combo, so it can access the links info. It's neat because a decoded Block also as cid, and bytes, so it work! 🎉

On a snapshot of the dagula source we get:

### `ls`
```console
❯ ./bin.js ls bafybeianow3xqswlzqmmqp4enj4mul3snpg52rya4rvpanip5tycw43elm
bafybeianow3xqswlzqmmqp4enj4mul3snpg52rya4rvpanip5tycw43elm
bafkreifjt56wbljg574jp3ij3iz56rr3ligwf3tmcwmyqufabuhytiirq4
bafkreibsrowqy5n4jpr7en25pepmw2psg6mnhoxzm6yodqubw6uqkl3nau
bafkreid52wbs2t5bjl7k4jqvcmvmpwnwifnvresgdmstcpwhw3h2wb4h6e
bafkreienidxwfi26e7zz54wgkugorvzuugrkaijievwwbrjal37qsnmvye
bafkreicaz5es35z2z2rpu63wukkg2ij2vctmsogmviudlbeb4dfpjfya2u
bafkreicsmlfxu3b4d2ubhlkk5bjo46nnxs5foee7x5bndnn5tpq7ghpo34
bafybeife4dxf7mfar2qsqgexkhze6b4w43a46rvfeoesnkooc5ktdc4uim
bafkreieaixgg2evxchw4wwzzcegecjayq2dn7ka7dblps425royn7ujg5m
bafkreiekuaqztmk7upvdftvq5lwjfmwbg3ffsl7l2oxayrjlqlbj3egcwm
bafkreihblq7u4qvbte34agifm7cjhaerpwxt5q53xy4jnfw47im5hzlqdi
bafkreifpiqrfihldtiziyos6u2k35lf45qrewid2hoylaj5uyi35u5xmbq
bafkreihrp4ceuqkpfl7ytv4kk5qn2ztsyi2weka6gmc346iixlqzupmw5a
bafkreiencnfom77cudkikff7dyy7osc5e22vqset7vpotcyudv274xilq4
bafkreihvxng4xlbbpqrd2ob67btegs3pnocsqf6bq7ahqqo7ofyx7payhy
bafkreic3qg76debp4uwj5hnfpawaqbcv6qyptwn2sz4oxp73md66kdtree
bafkreia5kv2iq3ewgdravhtrlz7zeywhm6cynwx5xieggjl4dlysv772t4
bafkreiejwjgkdtnox6pulwpa4gyjyuczbz4t3k7waeq64i5lgbxjdfifri
```

### `tree`
```console
❯ ./bin.js tree bafybeianow3xqswlzqmmqp4enj4mul3snpg52rya4rvpanip5tycw43elm
bafybeianow3xqswlzqmmqp4enj4mul3snpg52rya4rvpanip5tycw43elm
├── bafkreifpiqrfihldtiziyos6u2k35lf45qrewid2hoylaj5uyi35u5xmbq
├── bafkreic3qg76debp4uwj5hnfpawaqbcv6qyptwn2sz4oxp73md66kdtree
├── bafkreihrp4ceuqkpfl7ytv4kk5qn2ztsyi2weka6gmc346iixlqzupmw5a
├── bafkreicaz5es35z2z2rpu63wukkg2ij2vctmsogmviudlbeb4dfpjfya2u
├── bafkreihblq7u4qvbte34agifm7cjhaerpwxt5q53xy4jnfw47im5hzlqdi
├─┬ bafybeife4dxf7mfar2qsqgexkhze6b4w43a46rvfeoesnkooc5ktdc4uim
│ ├── bafkreia5kv2iq3ewgdravhtrlz7zeywhm6cynwx5xieggjl4dlysv772t4
│ └── bafkreiejwjgkdtnox6pulwpa4gyjyuczbz4t3k7waeq64i5lgbxjdfifri
├── bafkreieaixgg2evxchw4wwzzcegecjayq2dn7ka7dblps425royn7ujg5m
├── bafkreienidxwfi26e7zz54wgkugorvzuugrkaijievwwbrjal37qsnmvye
├── bafkreid52wbs2t5bjl7k4jqvcmvmpwnwifnvresgdmstcpwhw3h2wb4h6e
├── bafkreifjt56wbljg574jp3ij3iz56rr3ligwf3tmcwmyqufabuhytiirq4
├── bafkreicsmlfxu3b4d2ubhlkk5bjo46nnxs5foee7x5bndnn5tpq7ghpo34
├── bafkreibsrowqy5n4jpr7en25pepmw2psg6mnhoxzm6yodqubw6uqkl3nau
├── bafkreihvxng4xlbbpqrd2ob67btegs3pnocsqf6bq7ahqqo7ofyx7payhy
├── bafkreiencnfom77cudkikff7dyy7osc5e22vqset7vpotcyudv274xilq4
└── bafkreiekuaqztmk7upvdftvq5lwjfmwbg3ffsl7l2oxayrjlqlbj3egcwm
```

_i believe we are seeing the `gen` dir at bafybeife4dxf7mfar2qsqgexkhze6b4w43a46rvfeoesnkooc5ktdc4uim with 2 children..._ YES! IT TRUE https://bafybeife4dxf7mfar2qsqgexkhze6b4w43a46rvfeoesnkooc5ktdc4uim.ipfs.w3s.link

License: MIT
Signed-off-by: Oli Evans <oli@protocol.ai>

License: MIT
Signed-off-by: Oli Evans <oli@protocol.ai>
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.

None yet

2 participants