Skip to content

Commit

Permalink
Merge branch 'master' into fix/4864
Browse files Browse the repository at this point in the history
  • Loading branch information
steverecio committed Mar 25, 2018
2 parents 4f92a69 + d4a4355 commit b9a418c
Show file tree
Hide file tree
Showing 81 changed files with 1,204 additions and 956 deletions.
2 changes: 1 addition & 1 deletion .gx/lastpubver
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.14-rc1: QmXporsyf5xMvffd2eiTDoq85dNpYUynGJhfabzDjwP8uR
0.4.14: QmatUACvrFK3xYg1nd2iLAKfz7Yy5YB56tnzBYHpqiUuhn
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# go-ipfs changelog

## 0.4.14 2018-03-02
## 0.4.14 2018-03-22

Ipfs 0.4.14 is a big release with a large number of improvements and bugfixes.
It is also the first release of 2018, and our first release in over three
Expand Down
22 changes: 18 additions & 4 deletions bin/archive-branches.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -x

auth=""
#auth="-u kubuxu:$GH_TOKEN"
Expand All @@ -14,6 +13,7 @@ exclusions=(
'master'
'release'
'feat/zcash'
'feat/ai-mirror'
)

gh_api_next() {
Expand Down Expand Up @@ -48,9 +48,23 @@ active_branches() {

git remote add archived "[email protected]:$org/$arch_repo.git" || true

cat <(active_branches) <(pr_branches) <((IFS=$'\n'; echo "${exclusions[*]}")) \
| sort -u | comm - <(origin_refs | sort) -13 |\
while read -r ref; do
branches_to_move="$(cat <(active_branches) <(pr_branches) <((IFS=$'\n'; echo "${exclusions[*]}")) | sort -u | comm - <(origin_refs | sort) -13)"

echo "================"
printf "%s\n" "$branches_to_move"
echo "================"

echo "Please confirm move of above branches [y/N]:"

read line
case $line in
[Yy]|[Yy][Ee][Ss]) ;;
*) exit 1 ;;
esac


printf "%s\n" "$branches_to_move" | \
while read -r ref; do
git push archived "origin/$ref:refs/heads/$ref/$(date --rfc-3339=date)"
git push origin --delete "$ref"
done
Expand Down
7 changes: 1 addition & 6 deletions bin/check_go_path
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ if [ -z "$PWD" ]; then
exit 1
fi

if [ -z "$GOPATH" ]; then
echo "GOPATH not set, you must have go configured properly to install ipfs"
exit 1
fi

while [ ${#} -gt 1 ]; do
if [ "$PWD" = "$2" ]; then
exit 0
Expand All @@ -20,5 +15,5 @@ while [ ${#} -gt 1 ]; do
done

echo "go-ipfs must be built from within your \$GOPATH directory."
echo "expected within '$GOPATH' but got '$PWD'"
echo "expected within '$(go env GOPATH)' but got '$PWD'"
exit 1
12 changes: 10 additions & 2 deletions blockservice/blockservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ func (s *blockService) AddBlock(o blocks.Block) error {
return err
}

log.Event(context.TODO(), "BlockService.BlockAdded", c)

if err := s.exchange.HasBlock(o); err != nil {
// TODO(#4623): really an error?
return errors.New("blockservice is closed")
Expand Down Expand Up @@ -184,6 +186,7 @@ func (s *blockService) AddBlocks(bs []blocks.Block) error {
}

for _, o := range toput {
log.Event(context.TODO(), "BlockService.BlockAdded", o.Cid())
if err := s.exchange.HasBlock(o); err != nil {
// TODO(#4623): Should this really *return*?
return fmt.Errorf("blockservice is closed (%s)", err)
Expand Down Expand Up @@ -227,6 +230,7 @@ func getBlock(ctx context.Context, c *cid.Cid, bs blockstore.Blockstore, f excha
}
return nil, err
}
log.Event(ctx, "BlockService.BlockFetched", c)
return blk, nil
}

Expand Down Expand Up @@ -263,7 +267,6 @@ func getBlocks(ctx context.Context, ks []*cid.Cid, bs blockstore.Blockstore, f e
misses = append(misses, c)
continue
}
log.Debug("Blockservice: Got data in datastore")
select {
case out <- hit:
case <-ctx.Done():
Expand All @@ -282,6 +285,7 @@ func getBlocks(ctx context.Context, ks []*cid.Cid, bs blockstore.Blockstore, f e
}

for b := range rblocks {
log.Event(ctx, "BlockService.BlockFetched", b.Cid())
select {
case out <- b:
case <-ctx.Done():
Expand All @@ -294,7 +298,11 @@ func getBlocks(ctx context.Context, ks []*cid.Cid, bs blockstore.Blockstore, f e

// DeleteBlock deletes a block in the blockservice from the datastore
func (s *blockService) DeleteBlock(c *cid.Cid) error {
return s.blockstore.DeleteBlock(c)
err := s.blockstore.DeleteBlock(c)
if err == nil {
log.Event(context.TODO(), "BlockService.BlockDeleted", c)
}
return err
}

func (s *blockService) Close() error {
Expand Down
25 changes: 23 additions & 2 deletions cmd/ipfs/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
adjustFDLimitKwd = "manage-fdlimit"
enableGCKwd = "enable-gc"
initOptionKwd = "init"
initProfileOptionKwd = "init-profile"
ipfsMountKwd = "mount-ipfs"
ipnsMountKwd = "mount-ipns"
migrateKwd = "migrate"
Expand All @@ -44,6 +45,7 @@ const (
routingOptionDHTClientKwd = "dhtclient"
routingOptionDHTKwd = "dht"
routingOptionNoneKwd = "none"
routingOptionDefaultKwd = "default"
unencryptTransportKwd = "disable-transport-encryption"
unrestrictedApiAccessKwd = "unrestricted-api"
writableKwd = "writable"
Expand Down Expand Up @@ -148,7 +150,8 @@ Headers.

Options: []cmdkit.Option{
cmdkit.BoolOption(initOptionKwd, "Initialize ipfs with default settings if not already initialized"),
cmdkit.StringOption(routingOptionKwd, "Overrides the routing option").WithDefault("dht"),
cmdkit.StringOption(initProfileOptionKwd, "Configuration profiles to apply for --init. See ipfs init --help for more"),
cmdkit.StringOption(routingOptionKwd, "Overrides the routing option").WithDefault("default"),
cmdkit.BoolOption(mountKwd, "Mounts IPFS to the filesystem"),
cmdkit.BoolOption(writableKwd, "Enable writing objects (with POST, PUT and DELETE)"),
cmdkit.StringOption(ipfsMountKwd, "Path to the mountpoint for IPFS (if using --mount). Defaults to config setting."),
Expand Down Expand Up @@ -222,7 +225,9 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment

cfg := cctx.ConfigRoot
if !fsrepo.IsInitialized(cfg) {
err := initWithDefaults(os.Stdout, cfg)
profiles, _ := req.Options[initProfileOptionKwd].(string)

err := initWithDefaults(os.Stdout, cfg, profiles)
if err != nil {
re.SetError(err, cmdkit.ErrNormal)
return
Expand Down Expand Up @@ -296,6 +301,22 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
}

routingOption, _ := req.Options[routingOptionKwd].(string)
if err != nil {
re.SetError(err, cmdkit.ErrNormal)
return
}
if routingOption == routingOptionDefaultKwd {
cfg, err := repo.Config()
if err != nil {
re.SetError(err, cmdkit.ErrNormal)
return
}

routingOption = cfg.Routing.Type
if routingOption == "" {
routingOption = routingOptionDHTKwd
}
}
switch routingOption {
case routingOptionSupernodeKwd:
re.SetError(errors.New("supernode routing was never fully implemented and has been removed"), cmdkit.ErrNormal)
Expand Down
51 changes: 23 additions & 28 deletions cmd/ipfs/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import (
"strings"

assets "github.com/ipfs/go-ipfs/assets"
cmds "github.com/ipfs/go-ipfs/commands"
oldcmds "github.com/ipfs/go-ipfs/commands"
core "github.com/ipfs/go-ipfs/core"
namesys "github.com/ipfs/go-ipfs/namesys"
config "github.com/ipfs/go-ipfs/repo/config"
fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"

"gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit"
"gx/ipfs/QmfAkMSt9Fwzk48QDJecPcwCUjnf2uG7MLnmCGTp4C6ouL/go-ipfs-cmds"
)

const (
Expand All @@ -38,6 +39,9 @@ Available profiles:
running IPFS on machines with public IPv4 addresses.
'test' - Reduces external interference of IPFS daemon, this
is useful when using the daemon in test environments.
'lowpower' - Reduces daemon overhead on the system. May affect node
functionality - performance of content discovery and data fetching
may be degraded.
ipfs uses a repository in the local file system. By default, the repo is
located at ~/.ipfs. To change the repo location, set the $IPFS_PATH
Expand All @@ -59,8 +63,9 @@ environment variable:
// name of the file?
// TODO cmdkit.StringOption("event-logs", "l", "Location for machine-readable event logs."),
},
PreRun: func(req cmds.Request) error {
daemonLocked, err := fsrepo.LockedByOtherProcess(req.InvocContext().ConfigRoot)
PreRun: func(req *cmds.Request, env cmds.Environment) error {
cctx := env.(*oldcmds.Context)
daemonLocked, err := fsrepo.LockedByOtherProcess(cctx.ConfigRoot)
if err != nil {
return err
}
Expand All @@ -74,30 +79,19 @@ environment variable:

return nil
},
Run: func(req cmds.Request, res cmds.Response) {
// needs to be called at least once
res.SetOutput(nil)

if req.InvocContext().Online {
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) {
cctx := env.(*oldcmds.Context)
if cctx.Online {
res.SetError(errors.New("init must be run offline only!"), cmdkit.ErrNormal)
return
}

empty, _, err := req.Option("e").Bool()
if err != nil {
res.SetError(err, cmdkit.ErrNormal)
return
}

nBitsForKeypair, _, err := req.Option("b").Int()
if err != nil {
res.SetError(err, cmdkit.ErrNormal)
return
}
empty, _ := req.Options["empty-repo"].(bool)
nBitsForKeypair, _ := req.Options["bits"].(int)

var conf *config.Config

f := req.Files()
f := req.Files
if f != nil {
confFile, err := f.NextFile()
if err != nil {
Expand All @@ -112,18 +106,14 @@ environment variable:
}
}

profile, _, err := req.Option("profile").String()
if err != nil {
res.SetError(err, cmdkit.ErrNormal)
return
}
profile, _ := req.Options["profile"].(string)

var profiles []string
if profile != "" {
profiles = strings.Split(profile, ",")
}

if err := doInit(os.Stdout, req.InvocContext().ConfigRoot, empty, nBitsForKeypair, profiles, conf); err != nil {
if err := doInit(os.Stdout, cctx.ConfigRoot, empty, nBitsForKeypair, profiles, conf); err != nil {
res.SetError(err, cmdkit.ErrNormal)
return
}
Expand All @@ -134,8 +124,13 @@ var errRepoExists = errors.New(`ipfs configuration file already exists!
Reinitializing would overwrite your keys.
`)

func initWithDefaults(out io.Writer, repoRoot string) error {
return doInit(out, repoRoot, false, nBitsForKeypairDefault, nil, nil)
func initWithDefaults(out io.Writer, repoRoot string, profile string) error {
var profiles []string
if profile != "" {
profiles = strings.Split(profile, ",")
}

return doInit(out, repoRoot, false, nBitsForKeypairDefault, profiles, nil)
}

func doInit(out io.Writer, repoRoot string, empty bool, nBitsForKeypair int, confProfiles []string, conf *config.Config) error {
Expand Down
3 changes: 1 addition & 2 deletions cmd/ipfs/ipfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

commands "github.com/ipfs/go-ipfs/core/commands"

lgc "github.com/ipfs/go-ipfs/commands/legacy"
cmds "gx/ipfs/QmfAkMSt9Fwzk48QDJecPcwCUjnf2uG7MLnmCGTp4C6ouL/go-ipfs-cmds"
)

Expand All @@ -24,7 +23,7 @@ var commandsClientCmd = commands.CommandsCmd(Root)
// They can override subcommands in commands.Root by defining a subcommand with the same name.
var localCommands = map[string]*cmds.Command{
"daemon": daemonCmd,
"init": lgc.NewCommand(initCmd),
"init": initCmd,
"commands": commandsClientCmd,
}
var localMap = make(map[*cmds.Command]bool)
Expand Down
2 changes: 1 addition & 1 deletion cmd/seccat/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type logRW struct {

func (r *logRW) Read(buf []byte) (int, error) {
n, err := r.rw.Read(buf)
if err == nil {
if n > 0 {
log.Debugf("%s read: %v", r.n, buf)
}
return n, err
Expand Down
11 changes: 11 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ codecov:
notify:
require_ci_to_pass: no
after_n_builds: 2

coverage:
range: "50...100"

status:
project:
default:
threshold: 0.2%

patch:
default:
threshold: 2%

comment: off
4 changes: 2 additions & 2 deletions contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ try picking up an issue from there.

## Go Guidelines:

Please look and conform to our [Go Contribution Guidelines](https://github.com/ipfs/community/blob/master/go-contribution-guidelines.md).
Please look and conform to our [Go Contribution Guidelines](https://github.com/ipfs/community/blob/master/go-code-guidelines.md).

## General Guidelines:

- See the [dev pseudo-roadmap](dev.md).
- Please adhere to the protocol described in [the main ipfs repo](https://github.com/ipfs/ipfs), [paper](http://static.benet.ai/t/ipfs.pdf), and [specs](https://github.com/ipfs/specs) (WIP).
- Please adhere to the protocol described in [the main ipfs repo](https://github.com/ipfs/ipfs) and [specs](https://github.com/ipfs/specs) (WIP).
- Please make branches and pull-request, even if working on the main repository.
- Ask questions or talk about things in [Issues](https://github.com/ipfs/go-ipfs/issues) or #ipfs on freenode.
- Ensure you are able to contribute (no legal issues please-- we'll probably setup a CLA).
Expand Down
4 changes: 2 additions & 2 deletions core/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func setupNode(ctx context.Context, n *IpfsNode, cfg *BuildCfg) error {

// hash security
bs := bstore.NewBlockstore(rds)
bs = &verifbs.VerifBS{bs}
bs = &verifbs.VerifBS{Blockstore: bs}

opts := bstore.DefaultCacheOpts()
conf, err := n.Repo.Config()
Expand Down Expand Up @@ -202,7 +202,7 @@ func setupNode(ctx context.Context, n *IpfsNode, cfg *BuildCfg) error {
// hash security
n.Filestore = filestore.NewFilestore(bs, n.Repo.FileManager())
n.Blockstore = bstore.NewGCBlockstore(n.Filestore, n.GCLocker)
n.Blockstore = &verifbs.VerifBSGC{n.Blockstore}
n.Blockstore = &verifbs.VerifBSGC{GCBlockstore: n.Blockstore}
}

rcfg, err := n.Repo.Config()
Expand Down
5 changes: 4 additions & 1 deletion core/commands/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,10 @@ You can now check what blocks have been created by:

if hash {
md := dagtest.Mock()
mr, err := mfs.NewRoot(req.Context, md, ft.EmptyDirNode(), nil)
emptyDirNode := ft.EmptyDirNode()
// Use the same prefix for the "empty" MFS root as for the file adder.
emptyDirNode.Prefix = *fileAdder.Prefix
mr, err := mfs.NewRoot(req.Context, md, emptyDirNode, nil)
if err != nil {
res.SetError(err, cmdkit.ErrNormal)
return
Expand Down
Loading

0 comments on commit b9a418c

Please sign in to comment.