提交 60039f27 作者: Łukasz Magiera

object coreapi: Address review

License: MIT
Signed-off-by: 's avatarŁukasz Magiera <magik6k@gmail.com>
上级 36c6fb35
...@@ -68,12 +68,6 @@ func (c *Context) GetApi() (coreiface.CoreAPI, error) { ...@@ -68,12 +68,6 @@ func (c *Context) GetApi() (coreiface.CoreAPI, error) {
return c.api, nil 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. // Context returns the node's context.
func (c *Context) Context() context.Context { func (c *Context) Context() context.Context {
n, err := c.GetNode() n, err := c.GetNode()
......
...@@ -7,6 +7,8 @@ import ( ...@@ -7,6 +7,8 @@ import (
"github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/core"
coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface"
"github.com/ipfs/go-ipfs/repo/config" "github.com/ipfs/go-ipfs/repo/config"
cmds "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds"
) )
// GetNode extracts the node from the environment. // GetNode extracts the node from the environment.
...@@ -20,7 +22,7 @@ func GetNode(env interface{}) (*core.IpfsNode, error) { ...@@ -20,7 +22,7 @@ func GetNode(env interface{}) (*core.IpfsNode, error) {
} }
// GetApi extracts CoreAPI instance from the environment. // 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) ctx, ok := env.(*commands.Context)
if !ok { if !ok {
return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env) 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) { ...@@ -30,7 +32,7 @@ func GetApi(env interface{}) (coreiface.CoreAPI, error) {
} }
// GetConfig extracts the config from the environment. // 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) ctx, ok := env.(*commands.Context)
if !ok { if !ok {
return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env) return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env)
......
...@@ -254,7 +254,7 @@ to a file containing 'bar', and returns the hash of the new object. ...@@ -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 // TODO: fix import loop with core/commands so we don't need that
// COPIED FROM ONE LEVEL UP // COPIED FROM ONE LEVEL UP
// GetApi extracts CoreAPI instance from the environment. // 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) ctx, ok := env.(*oldcmds.Context)
if !ok { if !ok {
return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env) return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env)
......
...@@ -31,25 +31,27 @@ type ObjectStat struct { ...@@ -31,25 +31,27 @@ type ObjectStat struct {
CumulativeSize int CumulativeSize int
} }
// ChangeType denotes type of change in ObjectChange
type ChangeType int
const ( const (
// DiffAdd is a Type of ObjectChange where a link was added to the graph // DiffAdd is set when a link was added to the graph
DiffAdd = iota 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 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 DiffMod
) )
// ObjectChange represents a change ia a graph // ObjectChange represents a change ia a graph
// TODO: do we want this to be an interface?
type ObjectChange struct { type ObjectChange struct {
// Type of the change, either: // Type of the change, either:
// * DiffAdd - Added a link // * DiffAdd - Added a link
// * DiffRemove - Removed a link // * DiffRemove - Removed a link
// * DiffMod - Modified a link // * DiffMod - Modified a link
Type int Type ChangeType
// Path to the changed link // Path to the changed link
Path string Path string
......
...@@ -5,9 +5,10 @@ import ( ...@@ -5,9 +5,10 @@ import (
"fmt" "fmt"
"path" "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" ipld "gx/ipfs/QmZtNq8dArGfnpCZfx2pUNY7UcjGhVp5qqwQ4hH6mpTMRQ/go-ipld-format"
) )
...@@ -21,7 +22,7 @@ const ( ...@@ -21,7 +22,7 @@ const (
// Change represents a change to a DAG and contains a reference to the old and // Change represents a change to a DAG and contains a reference to the old and
// new CIDs. // new CIDs.
type Change struct { type Change struct {
Type int Type coreiface.ChangeType
Path string Path string
Before *cid.Cid Before *cid.Cid
After *cid.Cid After *cid.Cid
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论