Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Extract sharding awareness to UnixFS #86

Closed
schomatis opened this issue May 5, 2021 · 0 comments · Fixed by #88
Closed

Extract sharding awareness to UnixFS #86

schomatis opened this issue May 5, 2021 · 0 comments · Fixed by #88
Labels
need/triage Needs initial labeling and prioritization

Comments

@schomatis
Copy link
Contributor

The current state of MFS and its coupling with UnixFS don't make this a high priority issue; this is only valuable in connection with ipfs/kubo#8106: if we can refactor this code outside of the repo we can avoid adding more sharding logic here that just extends the technical debt.

MFS should deal only with the UnixFS Directory interface and not with its (basic and HAMT) implementations:

go-mfs/dir.go

Lines 374 to 385 in 9c9a0fe

func (d *Directory) addUnixFSChild(c child) error {
if uio.UseHAMTSharding {
// If the directory HAMT implementation is being used and this
// directory is actually a basic implementation switch it to HAMT.
if basicDir, ok := d.unixfsDir.(*uio.BasicDirectory); ok {
hamtDir, err := basicDir.SwitchToSharding(d.ctx)
if err != nil {
return err
}
d.unixfsDir = hamtDir
}
}

go-mfs/dir.go

Lines 166 to 167 in 9c9a0fe

case ft.TDirectory, ft.THAMTShard:
ndir, err := NewDirectory(d.ctx, name, nd, d, d.dagService)

The tradeoff of removing this here is adding another layer of indirection in UnixFS that can transition from one implementation to another when needed (as MFS does here).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
need/triage Needs initial labeling and prioritization
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant