@cryptotaxi247 / kubo / commits / aaa6569f2

trivial: various superficial fixes

misc/completion/ipfs-completion.bash: add `ipfs stats` to BASH completion core/commands/mount_unix.go: ensure error is not nil before printing it contribute.md: fix bibliography indexing in example core/commands/swarm.go: change tabs to spaces in USAGE message *: 80-column readability improvements License: MIT Signed-off-by: Thomas Gardner <tmg@fastmail.com>

Thomas Gardner committed Jan 24, 2016 at 14:18 UTC aaa6569f2c6673ed3119382cc1f9cedd529311da
13 files changed +59 -43
cmd/ipfs/main.go
+1 -1
@@ -57,7 +57,7 @@ type cmdInvocation struct {
57
58 // main roadmap:
59 // - parse the commandline to get a cmdInvocation
60 -// - if user requests, help, print it and exit.
60 +// - if user requests help, print it and exit.
61 // - run the command invocation
62 // - output the response
63 // - if anything fails, print error, maybe with help
commands/command.go
+12 -7
@@ -133,7 +133,8 @@ func (c *Command) Call(req Request) Response {
133 }
134 }
135
136 - // If the command specified an output type, ensure the actual value returned is of that type
136 + // If the command specified an output type, ensure the actual value
137 + // returned is of that type
138 if cmd.Type != nil && !isChan {
139 expectedType := reflect.TypeOf(cmd.Type)
140
@@ -146,7 +147,7 @@ func (c *Command) Call(req Request) Response {
147 return res
148 }
149
149 -// Resolve gets the subcommands at the given path
150 +// Resolve returns the subcommands at the given path
151 func (c *Command) Resolve(pth []string) ([]*Command, error) {
152 cmds := make([]*Command, len(pth)+1)
153 cmds[0] = c
@@ -175,7 +176,7 @@ func (c *Command) Get(path []string) (*Command, error) {
176 return cmds[len(cmds)-1], nil
177 }
178
178 -// GetOptions gets the options in the given path of commands
179 +// GetOptions returns the options in the given path of commands
180 func (c *Command) GetOptions(path []string) (map[string]Option, error) {
181 options := make([]Option, 0, len(c.Options))
182
@@ -217,12 +218,15 @@ func (c *Command) CheckArguments(req Request) error {
218 // iterate over the arg definitions
219 valueIndex := 0 // the index of the current value (in `args`)
220 for _, argDef := range c.Arguments {
220 - // skip optional argument definitions if there aren't sufficient remaining values
221 - if len(args)-valueIndex <= numRequired && !argDef.Required || argDef.Type == ArgFile {
221 + // skip optional argument definitions if there aren't
222 + // sufficient remaining values
223 + if len(args)-valueIndex <= numRequired && !argDef.Required ||
224 + argDef.Type == ArgFile {
225 continue
226 }
227
225 - // the value for this argument definition. can be nil if it wasn't provided by the caller
228 + // the value for this argument definition. can be nil if it
229 + // wasn't provided by the caller
230 v, found := "", false
231 if valueIndex < len(args) {
232 v = args[valueIndex]
@@ -254,7 +258,8 @@ func (c *Command) Subcommand(id string) *Command {
258 return c.Subcommands[id]
259 }
260
257 -// checkArgValue returns an error if a given arg value is not valid for the given Argument
261 +// checkArgValue returns an error if a given arg value is not valid for the
262 +// given Argument
263 func checkArgValue(v string, found bool, def Argument) error {
264 if !found && def.Required {
265 return fmt.Errorf("Argument '%s' is required", def.Name)
commands/files/file.go
+12 -9
@@ -11,11 +11,12 @@ var (
11 ErrNotReader = errors.New("This file is a directory, can't use Reader functions")
12 )
13
14 -// File is an interface that provides functionality for handling files/directories
15 -// as values that can be supplied to commands. For directories, child files are
16 -// accessed serially by calling `NextFile()`.
14 +// File is an interface that provides functionality for handling
15 +// files/directories as values that can be supplied to commands. For
16 +// directories, child files are accessed serially by calling `NextFile()`.
17 type File interface {
18 - // Files implement ReadCloser, but can only be read from or closed if they are not directories
18 + // Files implement ReadCloser, but can only be read from or closed if
19 + // they are not directories
20 io.ReadCloser
21
22 // FileName returns a filename path associated with this file
@@ -24,13 +25,15 @@ type File interface {
25 // FullPath returns the full path in the os associated with this file
26 FullPath() string
27
27 - // IsDirectory returns true if the File is a directory (and therefore supports calling `NextFile`)
28 - // and false if the File is a normal file (and therefor supports calling `Read` and `Close`)
28 + // IsDirectory returns true if the File is a directory (and therefore
29 + // supports calling `NextFile`) and false if the File is a normal file
30 + // (and therefor supports calling `Read` and `Close`)
31 IsDirectory() bool
32
31 - // NextFile returns the next child file available (if the File is a directory).
32 - // It will return (nil, io.EOF) if no more files are available.
33 - // If the file is a regular file (not a directory), NextFile will return a non-nil error.
33 + // NextFile returns the next child file available (if the File is a
34 + // directory). It will return (nil, io.EOF) if no more files are
35 + // available. If the file is a regular file (not a directory), NextFile
36 + // will return a non-nil error.
37 NextFile() (File, error)
38 }
39
contribute.md
+1 -1
@@ -75,7 +75,7 @@ recover quickly. This led to gateways not bootstrapping peers
75 fast enough.
76
77 The approach taken here is to do what crypto/tls does:
78 -defer the handshake until Read/Write[1]. There are a number of
78 +defer the handshake until Read/Write[0]. There are a number of
79 reasons why this is _the right thing to do_:
80 - it delays handshaking until it is known to be necessary (doing io)
81 - it "accepts" before the handshake, getting the handshake out of the
core/commands/commands.go
+5 -7
@@ -1,10 +1,8 @@
1 -/*
2 -Package commands implements the IPFS command interface
3 -
4 -Using github.com/ipfs/go-ipfs/commands to define the command line and
5 -HTTP APIs. This is the interface available to folks consuming IPFS
6 -from outside of the Go language.
7 -*/
1 +// Package commands implements the IPFS command interface
2 +//
3 +// Using github.com/ipfs/go-ipfs/commands to define the command line and HTTP
4 +// APIs. This is the interface available to folks using IPFS from outside of
5 +// the Go language.
6 package commands
7
8 import (
core/commands/mount_unix.go
+8 -1
@@ -215,8 +215,15 @@ func doMount(node *core.IpfsNode, fsdir, nsdir string) error {
215 <-done
216 <-done
217
218 + if err1 != nil {
219 + log.Errorf("error mounting: %s", err1)
220 + }
221 +
222 + if err2 != nil {
223 + log.Errorf("error mounting: %s", err2)
224 + }
225 +
226 if err1 != nil || err2 != nil {
219 - log.Errorf("error mounting: %s %s", err1, err2)
227 if fsmount != nil {
228 fsmount.Unmount()
229 }
core/commands/swarm.go
+1 -1
@@ -33,7 +33,7 @@ ipfs swarm peers - List peers with open connections
33 ipfs swarm addrs - List known addresses. Useful to debug.
34 ipfs swarm connect <address> - Open connection to a given address
35 ipfs swarm disconnect <address> - Close connection to a given address
36 -ipfs swarm filters - Manipulate filters addresses
36 +ipfs swarm filters - Manipulate filters addresses
37 `,
38 ShortDescription: `
39 'ipfs swarm' is a tool to manipulate the network swarm. The swarm is the
exchange/bitswap/decision/engine.go
+5 -3
@@ -21,7 +21,8 @@ import (
21 // batches/combines and takes all of these into consideration.
22 //
23 // Right now, messages go onto the network for four reasons:
24 -// 1. an initial `sendwantlist` message to a provider of the first key in a request
24 +// 1. an initial `sendwantlist` message to a provider of the first key in a
25 +// request
26 // 2. a periodic full sweep of `sendwantlist` messages to all providers
27 // 3. upon receipt of blocks, a `cancel` message to all peers
28 // 4. draining the priority queue of `blockrequests` from peers
@@ -34,9 +35,10 @@ import (
35 // Some examples of what would be possible:
36 //
37 // * when sending out the wantlists, include `cancel` requests
37 -// * when handling `blockrequests`, include `sendwantlist` and `cancel` as appropriate
38 +// * when handling `blockrequests`, include `sendwantlist` and `cancel` as
39 +// appropriate
40 // * when handling `cancel`, if we recently received a wanted block from a
39 -// peer, include a partial wantlist that contains a few other high priority
41 +// peer, include a partial wantlist that contains a few other high priority
42 // blocks
43 //
44 // In a sense, if we treat the decision engine as a black box, it could do
exchange/interface.go
+1 -1
@@ -11,7 +11,7 @@ import (
11
12 // Any type that implements exchange.Interface may be used as an IPFS block
13 // exchange protocol.
14 -type Interface interface {
14 +type Interface interface { // type Exchanger interface
15 // GetBlock returns the block associated with a given key.
16 GetBlock(context.Context, key.Key) (*blocks.Block, error)
17
misc/completion/ipfs-completion.bash
+1 -1
@@ -406,7 +406,7 @@ _ipfs()
406 1)
407 local opts="add bitswap block bootstrap cat commands config daemon dht \
408 diag dns file get id init log ls mount name object pin ping \
409 - refs repo swarm tour update version"
409 + refs repo stats swarm tour update version"
410 COMPREPLY=( $(compgen -W "${opts}" -- ${word}) );;
411 2)
412 local command="${COMP_WORDS[1]}"
unixfs/format.go
+3 -2
@@ -1,5 +1,6 @@
1 -// Package format implements a data format for files in the ipfs filesystem
2 -// It is not the only format in ipfs, but it is the one that the filesystem assumes
1 +// Package format implements a data format for files in the ipfs filesystem It
2 +// is not the only format in ipfs, but it is the one that the filesystem
3 +// assumes
4 package unixfs
5
6 import (
unixfs/io/dagreader.go
+4 -4
@@ -56,8 +56,8 @@ type ReadSeekCloser interface {
56 io.WriterTo
57 }
58
59 -// NewDagReader creates a new reader object that reads the data represented by the given
60 -// node, using the passed in DAGService for data retreival
59 +// NewDagReader creates a new reader object that reads the data represented by
60 +// the given node, using the passed in DAGService for data retreival
61 func NewDagReader(ctx context.Context, n *mdag.Node, serv mdag.DAGService) (*DagReader, error) {
62 pb := new(ftpb.Data)
63 if err := proto.Unmarshal(n.Data, pb); err != nil {
@@ -102,8 +102,8 @@ func NewDataFileReader(ctx context.Context, n *mdag.Node, pb *ftpb.Data, serv md
102 }
103 }
104
105 -// precalcNextBuf follows the next link in line and loads it from the DAGService,
106 -// setting the next buffer to read from
105 +// precalcNextBuf follows the next link in line and loads it from the
106 +// DAGService, setting the next buffer to read from
107 func (dr *DagReader) precalcNextBuf(ctx context.Context) error {
108 dr.buf.Close() // Just to make sure
109 if dr.linkPosition >= len(dr.promises) {
util/eventlog/loggables/loggables.go
+5 -5
@@ -1,9 +1,9 @@
1 -// Package loggables includes a bunch of transaltor functions for commonplace/stdlib
2 -// objects. This is boilerplate code that shouldn't change much, and not sprinkled
3 -// all over the place (i.e. gather it here).
1 +// Package loggables includes a bunch of translator functions for
2 +// commonplace/stdlib objects. This is boilerplate code that shouldn't change
3 +// much, and not sprinkled all over the place (i.e. gather it here).
4 //
5 // Note: it may make sense to put all stdlib Loggable functions in the eventlog
6 -// package. Putting it here for now in case we don't want to polute it.
6 +// package. Putting it here for now in case we don't want to pollute it.
7 package loggables
8
9 import (
@@ -50,7 +50,7 @@ func Dial(sys string, lid, rid peer.ID, laddr, raddr ma.Multiaddr) DeferredMap {
50 return m
51 }
52
53 -// DeferredMap is a Loggable which may contained deffered values.
53 +// DeferredMap is a Loggable which may contain deferred values.
54 type DeferredMap map[string]interface{}
55
56 // Loggable describes objects that can be marshalled into Metadata for logging