@@ -31,8 +31,8 @@ var BlockCmd = &cmds.Command{
31
31
Tagline : "Interact with raw IPFS blocks." ,
32
32
ShortDescription : `
33
33
'ipfs block' is a plumbing command used to manipulate raw IPFS blocks.
34
- Reads from stdin or writes to stdout, and <key> is a base58 encoded
35
- multihash .
34
+ Reads from stdin or writes to stdout. A block is identified by a Multihash
35
+ passed with a valid CID .
36
36
` ,
37
37
},
38
38
@@ -51,14 +51,14 @@ var blockStatCmd = &cmds.Command{
51
51
'ipfs block stat' is a plumbing command for retrieving information
52
52
on raw IPFS blocks. It outputs the following to stdout:
53
53
54
- Key - the base58 encoded multihash
54
+ Key - the CID of the block
55
55
Size - the size of the block in bytes
56
56
57
57
` ,
58
58
},
59
59
60
60
Arguments : []cmds.Argument {
61
- cmds .StringArg ("key " , true , false , "The base58 multihash of an existing block to stat." ).EnableStdin (),
61
+ cmds .StringArg ("cid " , true , false , "The CID of an existing block to stat." ).EnableStdin (),
62
62
},
63
63
Run : func (req * cmds.Request , res cmds.ResponseEmitter , env cmds.Environment ) error {
64
64
api , err := cmdenv .GetApi (env , req )
@@ -90,12 +90,12 @@ var blockGetCmd = &cmds.Command{
90
90
Tagline : "Get a raw IPFS block." ,
91
91
ShortDescription : `
92
92
'ipfs block get' is a plumbing command for retrieving raw IPFS blocks.
93
- It outputs to stdout , and <key> is a base58 encoded multihash .
93
+ It takes a <cid> , and outputs the block to stdout .
94
94
` ,
95
95
},
96
96
97
97
Arguments : []cmds.Argument {
98
- cmds .StringArg ("key " , true , false , "The base58 multihash of an existing block to get." ).EnableStdin (),
98
+ cmds .StringArg ("cid " , true , false , "The CID of an existing block to get." ).EnableStdin (),
99
99
},
100
100
Run : func (req * cmds.Request , res cmds.ResponseEmitter , env cmds.Environment ) error {
101
101
api , err := cmdenv .GetApi (env , req )
@@ -113,34 +113,41 @@ It outputs to stdout, and <key> is a base58 encoded multihash.
113
113
}
114
114
115
115
const (
116
- blockFormatOptionName = "format"
117
- blockStoreCodecOptionName = "store -codec"
118
- mhtypeOptionName = "mhtype"
119
- mhlenOptionName = "mhlen"
116
+ blockFormatOptionName = "format"
117
+ blockCidCodecOptionName = "cid -codec"
118
+ mhtypeOptionName = "mhtype"
119
+ mhlenOptionName = "mhlen"
120
120
)
121
121
122
122
var blockPutCmd = & cmds.Command {
123
123
Helptext : cmds.HelpText {
124
124
Tagline : "Store input as an IPFS block." ,
125
125
ShortDescription : `
126
126
'ipfs block put' is a plumbing command for storing raw IPFS blocks.
127
- It reads from stdin, and outputs the block's CID to stdout.
127
+ It reads data from stdin, and outputs the block's CID to stdout.
128
128
129
- Unless specified, this command returns dag-pb CIDv0 CIDs. Setting 'mhtype' to anything
130
- other than 'sha2-256' or format to anything other than 'v0' will result in CIDv1.
129
+ Unless cid-codec is specified, this command returns raw (0x55) CIDv1 CIDs.
130
+
131
+ Passing alternative --cid-codec does not modify imported data, nor run any
132
+ validation. It is provided solely for convenience for users who create blocks
133
+ in userland.
134
+
135
+ NOTE:
136
+ Do not use --format for any new code. It got superseded by --cid-codec and left
137
+ only for backward compatibility when a legacy CIDv0 is required (--format=v0).
131
138
` ,
132
139
},
133
140
134
141
Arguments : []cmds.Argument {
135
142
cmds .FileArg ("data" , true , true , "The data to be stored as an IPFS block." ).EnableStdin (),
136
143
},
137
144
Options : []cmds.Option {
138
- cmds .StringOption (blockFormatOptionName , "f" , "cid format for blocks to be created with." ),
139
- cmds .StringOption (blockStoreCodecOptionName , "s" , "multicodec name for blocks to be stored with" ),
140
- cmds .StringOption (mhtypeOptionName , "multihash hash function" ).WithDefault ("sha2-256" ),
141
- cmds .IntOption (mhlenOptionName , "multihash hash length" ).WithDefault (- 1 ),
142
- cmds .BoolOption (pinOptionName , "pin added blocks recursively" ).WithDefault (false ),
145
+ cmds .StringOption (blockCidCodecOptionName , "Multicodec to use in returned CID. Default: raw" ),
146
+ cmds .StringOption (mhtypeOptionName , "Multihash hash function" ).WithDefault ("sha2-256" ),
147
+ cmds .IntOption (mhlenOptionName , "Multihash hash length" ).WithDefault (- 1 ),
148
+ cmds .BoolOption (pinOptionName , "Pin added blocks recursively" ).WithDefault (false ),
143
149
cmdutils .AllowBigBlockOption ,
150
+ cmds .StringOption (blockFormatOptionName , "f" , "Use legacy format for returned CID (DEPRECATED)" ),
144
151
},
145
152
Run : func (req * cmds.Request , res cmds.ResponseEmitter , env cmds.Environment ) error {
146
153
api , err := cmdenv .GetApi (env , req )
@@ -159,8 +166,11 @@ other than 'sha2-256' or format to anything other than 'v0' will result in CIDv1
159
166
return errors .New ("missing option \" mhlen\" " )
160
167
}
161
168
162
- format , _ := req .Options [blockFormatOptionName ].(string )
163
- storeCodec , _ := req .Options [blockStoreCodecOptionName ].(string )
169
+ cidCodec , _ := req .Options [blockCidCodecOptionName ].(string )
170
+ format , _ := req .Options [blockFormatOptionName ].(string ) // deprecated
171
+ if format != "" && cidCodec != "" {
172
+ return fmt .Errorf ("unable to use %q (deprecated) with %q at the same time" , blockFormatOptionName , blockCidCodecOptionName )
173
+ }
164
174
165
175
pin , _ := req .Options [pinOptionName ].(bool )
166
176
@@ -173,8 +183,8 @@ other than 'sha2-256' or format to anything other than 'v0' will result in CIDv1
173
183
174
184
p , err := api .Block ().Put (req .Context , file ,
175
185
options .Block .Hash (mhtval , mhlen ),
186
+ options .Block .CidCodec (cidCodec ),
176
187
options .Block .Format (format ),
177
- options .Block .StoreCodec (storeCodec ),
178
188
options .Block .Pin (pin ))
179
189
if err != nil {
180
190
return err
@@ -216,14 +226,14 @@ type removedBlock struct {
216
226
217
227
var blockRmCmd = & cmds.Command {
218
228
Helptext : cmds.HelpText {
219
- Tagline : "Remove IPFS block(s)." ,
229
+ Tagline : "Remove IPFS block(s) from the local datastore ." ,
220
230
ShortDescription : `
221
231
'ipfs block rm' is a plumbing command for removing raw ipfs blocks.
222
- It takes a list of base58 encoded multihashes to remove.
232
+ It takes a list of CIDs to remove from the local datastore. .
223
233
` ,
224
234
},
225
235
Arguments : []cmds.Argument {
226
- cmds .StringArg ("hash " , true , true , "Bash58 encoded multihash of block(s) to remove." ),
236
+ cmds .StringArg ("cid " , true , true , "CIDs of block(s) to remove." ),
227
237
},
228
238
Options : []cmds.Option {
229
239
cmds .BoolOption (forceOptionName , "f" , "Ignore nonexistent blocks." ),
0 commit comments