From aaa6569f2c6673ed3119382cc1f9cedd529311da Mon Sep 17 00:00:00 2001 From: Thomas Gardner Date: Sun, 24 Jan 2016 14:18:03 +1000 Subject: [PATCH] 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 --- cmd/ipfs/main.go | 2 +- commands/command.go | 19 ++++++++++++------- commands/files/file.go | 21 ++++++++++++--------- contribute.md | 2 +- core/commands/commands.go | 12 +++++------- core/commands/mount_unix.go | 9 ++++++++- core/commands/swarm.go | 2 +- exchange/bitswap/decision/engine.go | 8 +++++--- exchange/interface.go | 2 +- misc/completion/ipfs-completion.bash | 2 +- unixfs/format.go | 5 +++-- unixfs/io/dagreader.go | 8 ++++---- util/eventlog/loggables/loggables.go | 10 +++++----- 13 files changed, 59 insertions(+), 43 deletions(-) diff --git a/cmd/ipfs/main.go b/cmd/ipfs/main.go index 611dbd695..09e87e194 100644 --- a/cmd/ipfs/main.go +++ b/cmd/ipfs/main.go @@ -57,7 +57,7 @@ type cmdInvocation struct { // main roadmap: // - parse the commandline to get a cmdInvocation -// - if user requests, help, print it and exit. +// - if user requests help, print it and exit. // - run the command invocation // - output the response // - if anything fails, print error, maybe with help diff --git a/commands/command.go b/commands/command.go index f29fb0022..3a6ba681a 100644 --- a/commands/command.go +++ b/commands/command.go @@ -133,7 +133,8 @@ func (c *Command) Call(req Request) Response { } } - // If the command specified an output type, ensure the actual value returned is of that type + // If the command specified an output type, ensure the actual value + // returned is of that type if cmd.Type != nil && !isChan { expectedType := reflect.TypeOf(cmd.Type) @@ -146,7 +147,7 @@ func (c *Command) Call(req Request) Response { return res } -// Resolve gets the subcommands at the given path +// Resolve returns the subcommands at the given path func (c *Command) Resolve(pth []string) ([]*Command, error) { cmds := make([]*Command, len(pth)+1) cmds[0] = c @@ -175,7 +176,7 @@ func (c *Command) Get(path []string) (*Command, error) { return cmds[len(cmds)-1], nil } -// GetOptions gets the options in the given path of commands +// GetOptions returns the options in the given path of commands func (c *Command) GetOptions(path []string) (map[string]Option, error) { options := make([]Option, 0, len(c.Options)) @@ -217,12 +218,15 @@ func (c *Command) CheckArguments(req Request) error { // iterate over the arg definitions valueIndex := 0 // the index of the current value (in `args`) for _, argDef := range c.Arguments { - // skip optional argument definitions if there aren't sufficient remaining values - if len(args)-valueIndex <= numRequired && !argDef.Required || argDef.Type == ArgFile { + // skip optional argument definitions if there aren't + // sufficient remaining values + if len(args)-valueIndex <= numRequired && !argDef.Required || + argDef.Type == ArgFile { continue } - // the value for this argument definition. can be nil if it wasn't provided by the caller + // the value for this argument definition. can be nil if it + // wasn't provided by the caller v, found := "", false if valueIndex < len(args) { v = args[valueIndex] @@ -254,7 +258,8 @@ func (c *Command) Subcommand(id string) *Command { return c.Subcommands[id] } -// checkArgValue returns an error if a given arg value is not valid for the given Argument +// checkArgValue returns an error if a given arg value is not valid for the +// given Argument func checkArgValue(v string, found bool, def Argument) error { if !found && def.Required { return fmt.Errorf("Argument '%s' is required", def.Name) diff --git a/commands/files/file.go b/commands/files/file.go index 60ced7a71..37802fe3f 100644 --- a/commands/files/file.go +++ b/commands/files/file.go @@ -11,11 +11,12 @@ var ( ErrNotReader = errors.New("This file is a directory, can't use Reader functions") ) -// File is an interface that provides functionality for handling files/directories -// as values that can be supplied to commands. For directories, child files are -// accessed serially by calling `NextFile()`. +// File is an interface that provides functionality for handling +// files/directories as values that can be supplied to commands. For +// directories, child files are accessed serially by calling `NextFile()`. type File interface { - // Files implement ReadCloser, but can only be read from or closed if they are not directories + // Files implement ReadCloser, but can only be read from or closed if + // they are not directories io.ReadCloser // FileName returns a filename path associated with this file @@ -24,13 +25,15 @@ type File interface { // FullPath returns the full path in the os associated with this file FullPath() string - // IsDirectory returns true if the File is a directory (and therefore supports calling `NextFile`) - // and false if the File is a normal file (and therefor supports calling `Read` and `Close`) + // IsDirectory returns true if the File is a directory (and therefore + // supports calling `NextFile`) and false if the File is a normal file + // (and therefor supports calling `Read` and `Close`) IsDirectory() bool - // NextFile returns the next child file available (if the File is a directory). - // It will return (nil, io.EOF) if no more files are available. - // If the file is a regular file (not a directory), NextFile will return a non-nil error. + // NextFile returns the next child file available (if the File is a + // directory). It will return (nil, io.EOF) if no more files are + // available. If the file is a regular file (not a directory), NextFile + // will return a non-nil error. NextFile() (File, error) } diff --git a/contribute.md b/contribute.md index 9530729c9..6fbf0f320 100644 --- a/contribute.md +++ b/contribute.md @@ -75,7 +75,7 @@ recover quickly. This led to gateways not bootstrapping peers fast enough. The approach taken here is to do what crypto/tls does: -defer the handshake until Read/Write[1]. There are a number of +defer the handshake until Read/Write[0]. There are a number of reasons why this is _the right thing to do_: - it delays handshaking until it is known to be necessary (doing io) - it "accepts" before the handshake, getting the handshake out of the diff --git a/core/commands/commands.go b/core/commands/commands.go index 3e7630022..046ff785a 100644 --- a/core/commands/commands.go +++ b/core/commands/commands.go @@ -1,10 +1,8 @@ -/* -Package commands implements the IPFS command interface - -Using github.com/ipfs/go-ipfs/commands to define the command line and -HTTP APIs. This is the interface available to folks consuming IPFS -from outside of the Go language. -*/ +// Package commands implements the IPFS command interface +// +// Using github.com/ipfs/go-ipfs/commands to define the command line and HTTP +// APIs. This is the interface available to folks using IPFS from outside of +// the Go language. package commands import ( diff --git a/core/commands/mount_unix.go b/core/commands/mount_unix.go index 3be070560..5c3046af4 100644 --- a/core/commands/mount_unix.go +++ b/core/commands/mount_unix.go @@ -215,8 +215,15 @@ func doMount(node *core.IpfsNode, fsdir, nsdir string) error { <-done <-done + if err1 != nil { + log.Errorf("error mounting: %s", err1) + } + + if err2 != nil { + log.Errorf("error mounting: %s", err2) + } + if err1 != nil || err2 != nil { - log.Errorf("error mounting: %s %s", err1, err2) if fsmount != nil { fsmount.Unmount() } diff --git a/core/commands/swarm.go b/core/commands/swarm.go index 43d6a966c..5a7777e5f 100644 --- a/core/commands/swarm.go +++ b/core/commands/swarm.go @@ -33,7 +33,7 @@ ipfs swarm peers - List peers with open connections ipfs swarm addrs - List known addresses. Useful to debug. ipfs swarm connect
- Open connection to a given address ipfs swarm disconnect
- Close connection to a given address -ipfs swarm filters - Manipulate filters addresses +ipfs swarm filters - Manipulate filters addresses `, ShortDescription: ` 'ipfs swarm' is a tool to manipulate the network swarm. The swarm is the diff --git a/exchange/bitswap/decision/engine.go b/exchange/bitswap/decision/engine.go index 03c13d99e..78e02dbd7 100644 --- a/exchange/bitswap/decision/engine.go +++ b/exchange/bitswap/decision/engine.go @@ -21,7 +21,8 @@ import ( // batches/combines and takes all of these into consideration. // // Right now, messages go onto the network for four reasons: -// 1. an initial `sendwantlist` message to a provider of the first key in a request +// 1. an initial `sendwantlist` message to a provider of the first key in a +// request // 2. a periodic full sweep of `sendwantlist` messages to all providers // 3. upon receipt of blocks, a `cancel` message to all peers // 4. draining the priority queue of `blockrequests` from peers @@ -34,9 +35,10 @@ import ( // Some examples of what would be possible: // // * when sending out the wantlists, include `cancel` requests -// * when handling `blockrequests`, include `sendwantlist` and `cancel` as appropriate +// * when handling `blockrequests`, include `sendwantlist` and `cancel` as +// appropriate // * when handling `cancel`, if we recently received a wanted block from a -// peer, include a partial wantlist that contains a few other high priority +// peer, include a partial wantlist that contains a few other high priority // blocks // // In a sense, if we treat the decision engine as a black box, it could do diff --git a/exchange/interface.go b/exchange/interface.go index 1a149ed9d..05f52a64b 100644 --- a/exchange/interface.go +++ b/exchange/interface.go @@ -11,7 +11,7 @@ import ( // Any type that implements exchange.Interface may be used as an IPFS block // exchange protocol. -type Interface interface { +type Interface interface { // type Exchanger interface // GetBlock returns the block associated with a given key. GetBlock(context.Context, key.Key) (*blocks.Block, error) diff --git a/misc/completion/ipfs-completion.bash b/misc/completion/ipfs-completion.bash index fd07b09d2..afa320f02 100644 --- a/misc/completion/ipfs-completion.bash +++ b/misc/completion/ipfs-completion.bash @@ -406,7 +406,7 @@ _ipfs() 1) local opts="add bitswap block bootstrap cat commands config daemon dht \ diag dns file get id init log ls mount name object pin ping \ - refs repo swarm tour update version" + refs repo stats swarm tour update version" COMPREPLY=( $(compgen -W "${opts}" -- ${word}) );; 2) local command="${COMP_WORDS[1]}" diff --git a/unixfs/format.go b/unixfs/format.go index 472a575e7..0bf569438 100644 --- a/unixfs/format.go +++ b/unixfs/format.go @@ -1,5 +1,6 @@ -// Package format implements a data format for files in the ipfs filesystem -// It is not the only format in ipfs, but it is the one that the filesystem assumes +// Package format implements a data format for files in the ipfs filesystem It +// is not the only format in ipfs, but it is the one that the filesystem +// assumes package unixfs import ( diff --git a/unixfs/io/dagreader.go b/unixfs/io/dagreader.go index 646a69a40..4cc522025 100644 --- a/unixfs/io/dagreader.go +++ b/unixfs/io/dagreader.go @@ -56,8 +56,8 @@ type ReadSeekCloser interface { io.WriterTo } -// NewDagReader creates a new reader object that reads the data represented by the given -// node, using the passed in DAGService for data retreival +// NewDagReader creates a new reader object that reads the data represented by +// the given node, using the passed in DAGService for data retreival func NewDagReader(ctx context.Context, n *mdag.Node, serv mdag.DAGService) (*DagReader, error) { pb := new(ftpb.Data) 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 } } -// precalcNextBuf follows the next link in line and loads it from the DAGService, -// setting the next buffer to read from +// precalcNextBuf follows the next link in line and loads it from the +// DAGService, setting the next buffer to read from func (dr *DagReader) precalcNextBuf(ctx context.Context) error { dr.buf.Close() // Just to make sure if dr.linkPosition >= len(dr.promises) { diff --git a/util/eventlog/loggables/loggables.go b/util/eventlog/loggables/loggables.go index e7588541f..4d5ab474b 100644 --- a/util/eventlog/loggables/loggables.go +++ b/util/eventlog/loggables/loggables.go @@ -1,9 +1,9 @@ -// Package loggables includes a bunch of transaltor functions for commonplace/stdlib -// objects. This is boilerplate code that shouldn't change much, and not sprinkled -// all over the place (i.e. gather it here). +// Package loggables includes a bunch of translator functions for +// commonplace/stdlib objects. This is boilerplate code that shouldn't change +// much, and not sprinkled all over the place (i.e. gather it here). // // Note: it may make sense to put all stdlib Loggable functions in the eventlog -// package. Putting it here for now in case we don't want to polute it. +// package. Putting it here for now in case we don't want to pollute it. package loggables import ( @@ -50,7 +50,7 @@ func Dial(sys string, lid, rid peer.ID, laddr, raddr ma.Multiaddr) DeferredMap { return m } -// DeferredMap is a Loggable which may contained deffered values. +// DeferredMap is a Loggable which may contain deferred values. type DeferredMap map[string]interface{} // Loggable describes objects that can be marshalled into Metadata for logging