-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 initial support for identity hashes. #4910
Changes from 4 commits
f7b6e67
6a6fd90
42ee69d
bb4a520
f0a4f29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import ( | |
dag "github.com/ipfs/go-ipfs/merkledag" | ||
dagtest "github.com/ipfs/go-ipfs/merkledag/test" | ||
mfs "github.com/ipfs/go-ipfs/mfs" | ||
cide "github.com/ipfs/go-ipfs/thirdparty/cidextra" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this is temporary. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More or less, I would like to get something working first, merge this p.r. and then worry about finding a better place for the two new packages in thirdparty. |
||
ft "github.com/ipfs/go-ipfs/unixfs" | ||
|
||
mh "gx/ipfs/QmZyZDi491cCNTLfAhwcaDii2Kg4pwKRkhqQzURGDvY6ua/go-multihash" | ||
|
@@ -43,6 +44,7 @@ const ( | |
fstoreCacheOptionName = "fscache" | ||
cidVersionOptionName = "cid-version" | ||
hashOptionName = "hash" | ||
idHashLimitOptionName = "id-hash-limit" | ||
) | ||
|
||
const adderOutChanSize = 8 | ||
|
@@ -119,6 +121,7 @@ You can now check what blocks have been created by: | |
cmdkit.BoolOption(fstoreCacheOptionName, "Check the filestore for pre-existing blocks. (experimental)"), | ||
cmdkit.IntOption(cidVersionOptionName, "CID version. Defaults to 0 unless an option that depends on CIDv1 is passed. (experimental)"), | ||
cmdkit.StringOption(hashOptionName, "Hash function to use. Implies CIDv1 if not sha2-256. (experimental)").WithDefault("sha2-256"), | ||
cmdkit.IntOption(idHashLimitOptionName, "Id hash maxium size. -1 disables. (experimental)").WithDefault(-1), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally, I wouldn't make this this configurable. I'd have a fixed option and set the size to 64 bytes. I doubt there are any valid reasons for picking a non-standard value here (other than, maybe choosing between 32 bytes and 64 bytes). I would not allow more than 64 bytes as CIDs are supposed to be small. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay I will add an "--inline" option and keep this option, but set the default to 64. Note there is an internal check that prevents this value from being set to the maximum id-hash size which is currently 64. |
||
}, | ||
PreRun: func(req *cmds.Request, env cmds.Environment) error { | ||
quiet, _ := req.Options[quietOptionName].(bool) | ||
|
@@ -172,6 +175,7 @@ You can now check what blocks have been created by: | |
fscache, _ := req.Options[fstoreCacheOptionName].(bool) | ||
cidVer, cidVerSet := req.Options[cidVersionOptionName].(int) | ||
hashFunStr, _ := req.Options[hashOptionName].(string) | ||
idHashLimit, _ := req.Options[idHashLimitOptionName].(int) | ||
|
||
// The arguments are subject to the following constraints. | ||
// | ||
|
@@ -279,13 +283,19 @@ You can now check what blocks have been created by: | |
fileAdder.Silent = silent | ||
fileAdder.RawLeaves = rawblks | ||
fileAdder.NoCopy = nocopy | ||
fileAdder.Prefix = &prefix | ||
fileAdder.CidOpts = &cide.Opts{Prefix: prefix} | ||
|
||
err = fileAdder.CidOpts.SetIdHashLimit(idHashLimit) | ||
if err != nil { | ||
res.SetError(err, cmdkit.ErrNormal) | ||
return | ||
} | ||
|
||
if hash { | ||
md := dagtest.Mock() | ||
emptyDirNode := ft.EmptyDirNode() | ||
// Use the same prefix for the "empty" MFS root as for the file adder. | ||
emptyDirNode.Prefix = *fileAdder.Prefix | ||
emptyDirNode.CidOpts = *fileAdder.CidOpts | ||
mr, err := mfs.NewRoot(req.Context, md, emptyDirNode, nil) | ||
if err != nil { | ||
res.SetError(err, cmdkit.ErrNormal) | ||
|
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.
What does
w
inwbs
stand for?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.
"wrapped"