-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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 support for inlinling via the id-hash #5281
Changes from 2 commits
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 |
---|---|---|
|
@@ -18,6 +18,7 @@ import ( | |
cmds "gx/ipfs/QmPTfgFTo9PFr1PvPKyKoeMgBvYPh6cX3aDP7DHKVbnCbi/go-ipfs-cmds" | ||
mh "gx/ipfs/QmPnFwZ2JXKnXgMw8CdBPxn7FWh6LLdjUjxV1fKHuJnkr8/go-multihash" | ||
pb "gx/ipfs/QmPtj12fdwuAqj9sBSTNUxBNu8kCGNp8b3o8yUzMm5GHpq/pb" | ||
cidutil "gx/ipfs/QmPyxJ2QS7L5FhGkNYkNcXHGjDhvGHueJ4auqAstFHYxy5/go-cidutil" | ||
cmdkit "gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit" | ||
files "gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit/files" | ||
offline "gx/ipfs/QmZxjqR9Qgompju73kakSoUj3rbVndAzky3oCDiBNCxPs1/go-ipfs-exchange-offline" | ||
|
@@ -44,6 +45,8 @@ const ( | |
fstoreCacheOptionName = "fscache" | ||
cidVersionOptionName = "cid-version" | ||
hashOptionName = "hash" | ||
inlineOptionName = "inline" | ||
inlineLimitOptionName = "inline-limit" | ||
) | ||
|
||
const adderOutChanSize = 8 | ||
|
@@ -120,6 +123,8 @@ 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.BoolOption(inlineOptionName, "Inline small blocks into CIDs. (experimental)"), | ||
cmdkit.IntOption(inlineLimitOptionName, "Maximum block size to inline. (experimental)").WithDefault(64), | ||
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. @whyrusleeping says: don't add this right now, just make it 64. If users complain, we can revisit it later; this is the most conservative approach and should be good enough for pretty much all cases. That fine with you? 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 would like to know the reasons for this. Is it the change in the API string because of the use of WithDefault() or something else? 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. The reasoning is simply "fewer knobs" (or "be conservative"). That is, we don't really need this knob so we might as well add it later when needed (when a user presents a use-case for changing the default). 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 don't necessarily agree with that philosophy but won't object strongly. I can see a case of wanting either 32 or 64 and don't think there is a clear answer. I am okay with limiting it to either 32 or 64 if you think that will be better. 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. User here looking forward to this feature, I'm mirroring a large-ish dataset using filestore to avoid disk duplication, in this case there is a few files being updated often which is causing issues with missing data, these are 41-42 bytes in size. example: http://distfiles.gentoo.org/experimental/timestamp.x 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. The issue is that we may actually need to define a limit on the maximum CID size and 64 bytes is really long (see my comment below). However, having to define a new block for a ~40 byte file really does suck. Let's wait for the browser working group to comment. 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. Yes 64 bytes is long, but if it is part of a directory entry, the user is ever unlikely to need to actual CID and it won't show up as part of the URL. All the more reason to keep this option. I could change the default to 32 though so it won't create a problem. When someone knows what they are doing they can increase it to suit there needs. 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. Unless a user just adds a file directly. E.g., 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.
Correct. So make the default 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.
(nvm, didn't see the response from lidel) |
||
}, | ||
PreRun: func(req *cmds.Request, env cmds.Environment) error { | ||
quiet, _ := req.Options[quietOptionName].(bool) | ||
|
@@ -173,6 +178,8 @@ 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) | ||
inline, _ := req.Options[inlineOptionName].(bool) | ||
inlineLimit, _ := req.Options[inlineLimitOptionName].(int) | ||
|
||
// The arguments are subject to the following constraints. | ||
// | ||
|
@@ -279,7 +286,14 @@ You can now check what blocks have been created by: | |
fileAdder.Silent = silent | ||
fileAdder.RawLeaves = rawblks | ||
fileAdder.NoCopy = nocopy | ||
fileAdder.CidBuilder = &prefix | ||
fileAdder.CidBuilder = prefix | ||
|
||
if inline { | ||
fileAdder.CidBuilder = cidutil.InlineBuilder{ | ||
Builder: fileAdder.CidBuilder, | ||
Limit: inlineLimit, | ||
} | ||
} | ||
|
||
if hash { | ||
md := dagtest.Mock() | ||
|
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.
Oops sorry. :)
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.
Np. I didn't want to bother you with it (and then made more work for myself by forgetting about GitCop 🙄).