Skip to content

Commit

Permalink
adder: tweaks
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Kevin Atkinson <k@kevina.org>
  • Loading branch information
kevina committed Mar 8, 2017
1 parent 921afcc commit 2ba6d8a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/commands/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ You can now refer to the added file in a gateway, like so:
cmds.BoolOption(rawLeavesOptionName, "Use raw blocks for leaf nodes. (experimental)"),
cmds.BoolOption(noCopyOptionName, "Add the file using filestore. (experimental)"),
cmds.BoolOption(fstoreCacheOptionName, "Check the filestore for pre-existing blocks. (experimental)"),
cmds.IntOption(cidVersionOptionName, "Cid version. (experimental)").Default(0),
cmds.IntOption(cidVersionOptionName, "Cid version. Non-zero value will change default of 'raw-leaves' to true. (experimental)").Default(0),
},
PreRun: func(req cmds.Request) error {
quiet, _, _ := req.Option(quietOptionName).Bool()
Expand Down
2 changes: 1 addition & 1 deletion importer/helpers/dagbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type DagBuilderParams struct {
// instead of using the unixfs TRaw type
RawLeaves bool

// Prefix specifies cid version and hashing function
// CID Version to use
CidVersion dag.CidVersion

// DAGService to write blocks to (required)
Expand Down
12 changes: 7 additions & 5 deletions merkledag/cidversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ type CidVersion struct {
version uint64
}

var (
CID0 = CidVersion{0}
CID1 = CidVersion{1}
)

func NewCidVersion(version int) (CidVersion, error) {
switch version {
case 0:
return CidVersion{0}, nil
case 1:
return CidVersion{1}, nil
case 0, 1:
return CidVersion{uint64(version)}, nil
default:
return CidVersion{}, fmt.Errorf("unknown CID version: %d", version)
}
Expand All @@ -23,4 +26,3 @@ func NewCidVersion(version int) (CidVersion, error) {
func (v CidVersion) Version() uint64 {
return v.version
}

0 comments on commit 2ba6d8a

Please sign in to comment.