1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-29 01:12:24 +08:00

Merge pull request #2288 from tomgg/tmg/trivial

trivial: various superficial fixes
This commit is contained in:
Jeromy Johnson
2016-02-02 22:27:43 -08:00
13 changed files with 59 additions and 43 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)
}

View File

@ -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

View File

@ -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 (

View File

@ -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()
}

View File

@ -33,7 +33,7 @@ ipfs swarm peers - List peers with open connections
ipfs swarm addrs - List known addresses. Useful to debug.
ipfs swarm connect <address> - Open connection to a given address
ipfs swarm disconnect <address> - 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

View File

@ -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

View File

@ -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)

View File

@ -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]}"

View File

@ -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 (

View File

@ -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) {

View File

@ -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