diff --git a/commands/request.go b/commands/request.go index 9c0e74196fb..c6b1f612462 100644 --- a/commands/request.go +++ b/commands/request.go @@ -68,12 +68,6 @@ func (c *Context) GetApi() (coreiface.CoreAPI, error) { return c.api, nil } -// NodeWithoutConstructing returns the underlying node variable -// so that clients may close it. -func (c *Context) NodeWithoutConstructing() *core.IpfsNode { - return c.node -} - // Context returns the node's context. func (c *Context) Context() context.Context { n, err := c.GetNode() diff --git a/core/commands/env.go b/core/commands/env.go index d0536e3da28..6f564bca671 100644 --- a/core/commands/env.go +++ b/core/commands/env.go @@ -7,6 +7,8 @@ import ( "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/repo/config" + + cmds "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds" ) // GetNode extracts the node from the environment. @@ -20,7 +22,7 @@ func GetNode(env interface{}) (*core.IpfsNode, error) { } // GetApi extracts CoreAPI instance from the environment. -func GetApi(env interface{}) (coreiface.CoreAPI, error) { +func GetApi(env cmds.Environment) (coreiface.CoreAPI, error) { ctx, ok := env.(*commands.Context) if !ok { return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env) @@ -30,7 +32,7 @@ func GetApi(env interface{}) (coreiface.CoreAPI, error) { } // GetConfig extracts the config from the environment. -func GetConfig(env interface{}) (*config.Config, error) { +func GetConfig(env cmds.Environment) (*config.Config, error) { ctx, ok := env.(*commands.Context) if !ok { return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env) diff --git a/core/commands/object/patch.go b/core/commands/object/patch.go index fcadc49bec3..bbb607ee7f2 100644 --- a/core/commands/object/patch.go +++ b/core/commands/object/patch.go @@ -254,7 +254,7 @@ to a file containing 'bar', and returns the hash of the new object. // TODO: fix import loop with core/commands so we don't need that // COPIED FROM ONE LEVEL UP // GetApi extracts CoreAPI instance from the environment. -func GetApi(env interface{}) (coreiface.CoreAPI, error) { +func GetApi(env cmds.Environment) (coreiface.CoreAPI, error) { ctx, ok := env.(*oldcmds.Context) if !ok { return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env) diff --git a/core/coreapi/interface/object.go b/core/coreapi/interface/object.go index 1c7caeb77bc..3eb0ea9ef37 100644 --- a/core/coreapi/interface/object.go +++ b/core/coreapi/interface/object.go @@ -31,25 +31,27 @@ type ObjectStat struct { CumulativeSize int } +// ChangeType denotes type of change in ObjectChange +type ChangeType int + const ( - // DiffAdd is a Type of ObjectChange where a link was added to the graph - DiffAdd = iota + // DiffAdd is set when a link was added to the graph + DiffAdd ChangeType = iota - // DiffRemove is a Type of ObjectChange where a link was removed from the graph + // DiffRemove is set when a link was removed from the graph DiffRemove - // DiffMod is a Type of ObjectChange where a link was changed in the graph + // DiffMod is set when a link was changed in the graph DiffMod ) // ObjectChange represents a change ia a graph -// TODO: do we want this to be an interface? type ObjectChange struct { // Type of the change, either: // * DiffAdd - Added a link // * DiffRemove - Removed a link // * DiffMod - Modified a link - Type int + Type ChangeType // Path to the changed link Path string diff --git a/dagutils/diff.go b/dagutils/diff.go index 7eef46d52a7..cd1ae4e4889 100644 --- a/dagutils/diff.go +++ b/dagutils/diff.go @@ -5,9 +5,10 @@ import ( "fmt" "path" - dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag" + coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - cid "gx/ipfs/QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP/go-cid" + dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag" + "gx/ipfs/QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP/go-cid" ipld "gx/ipfs/QmZtNq8dArGfnpCZfx2pUNY7UcjGhVp5qqwQ4hH6mpTMRQ/go-ipld-format" ) @@ -21,7 +22,7 @@ const ( // Change represents a change to a DAG and contains a reference to the old and // new CIDs. type Change struct { - Type int + Type coreiface.ChangeType Path string Before *cid.Cid After *cid.Cid