diff --git a/assets/assets.go b/assets/assets.go index 631a0fe57ae..f4f604f32c6 100644 --- a/assets/assets.go +++ b/assets/assets.go @@ -10,10 +10,10 @@ import ( "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/core/coreapi" - "github.com/ipfs/go-ipfs/core/coreapi/interface" - "github.com/ipfs/go-ipfs/core/coreapi/interface/options" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" + iface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + options "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" files "gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files" // this import keeps gx from thinking the dep isn't used diff --git a/commands/context.go b/commands/context.go index c1aca9a786a..93114bbe483 100644 --- a/commands/context.go +++ b/commands/context.go @@ -8,12 +8,12 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" loader "github.com/ipfs/go-ipfs/plugin/loader" "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" config "gx/ipfs/QmTbcMKv6GU3fxhnNcbzYChdox9Fdd7VpucM3PQ7UWjX3D/go-ipfs-config" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + options "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" ) diff --git a/core/commands/add.go b/core/commands/add.go index 26e67bdf37b..f5ca7826bab 100644 --- a/core/commands/add.go +++ b/core/commands/add.go @@ -8,10 +8,10 @@ import ( "strings" "github.com/ipfs/go-ipfs/core/commands/cmdenv" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - "github.com/ipfs/go-ipfs/core/coreapi/interface/options" cmds "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + options "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" pb "gx/ipfs/QmYWB8oH6o7qftxoyqTTZhzLrhKCVT7NYahECQTwTtqbgj/pb" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" diff --git a/core/commands/block.go b/core/commands/block.go index 8fe3ac3e612..caa176843d8 100644 --- a/core/commands/block.go +++ b/core/commands/block.go @@ -8,10 +8,10 @@ import ( util "github.com/ipfs/go-ipfs/blocks/blockstoreutil" cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - "github.com/ipfs/go-ipfs/core/coreapi/interface/options" cmds "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + options "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" ) diff --git a/core/commands/cat.go b/core/commands/cat.go index cfafcc09289..0e4904ccfba 100644 --- a/core/commands/cat.go +++ b/core/commands/cat.go @@ -7,9 +7,9 @@ import ( "os" "github.com/ipfs/go-ipfs/core/commands/cmdenv" - "github.com/ipfs/go-ipfs/core/coreapi/interface" cmds "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" + "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" "gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/cmdenv/env.go b/core/commands/cmdenv/env.go index 5095f72cdd1..9db1f0d04ef 100644 --- a/core/commands/cmdenv/env.go +++ b/core/commands/cmdenv/env.go @@ -6,11 +6,11 @@ import ( "github.com/ipfs/go-ipfs/commands" "github.com/ipfs/go-ipfs/core" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" cmds "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" config "gx/ipfs/QmTbcMKv6GU3fxhnNcbzYChdox9Fdd7VpucM3PQ7UWjX3D/go-ipfs-config" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + options "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" ) diff --git a/core/commands/dag/dag.go b/core/commands/dag/dag.go index 03f7fc39674..b7b65122bf8 100644 --- a/core/commands/dag/dag.go +++ b/core/commands/dag/dag.go @@ -7,13 +7,13 @@ import ( "strings" "github.com/ipfs/go-ipfs/core/commands/cmdenv" - "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/core/coredag" path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" cmds "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" + iface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" files "gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files" cidenc "gx/ipfs/QmdPQx9fvN5ExVwMhRmh7YpCQJzJrFhd1AjVBwJmRMFJeX/go-cidutil/cidenc" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" diff --git a/core/commands/dns.go b/core/commands/dns.go index 9c3cceda274..a67b045b3f4 100644 --- a/core/commands/dns.go +++ b/core/commands/dns.go @@ -5,8 +5,8 @@ import ( "io" ncmd "github.com/ipfs/go-ipfs/core/commands/name" - nsopts "github.com/ipfs/go-ipfs/core/coreapi/interface/options/namesys" namesys "github.com/ipfs/go-ipfs/namesys" + nsopts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" cmds "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" diff --git a/core/commands/files.go b/core/commands/files.go index 8a3cf48e08b..7586fef9e09 100644 --- a/core/commands/files.go +++ b/core/commands/files.go @@ -12,7 +12,6 @@ import ( "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/core/commands/cmdenv" - "github.com/ipfs/go-ipfs/core/coreapi/interface" "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" @@ -20,6 +19,7 @@ import ( ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" dag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" "gx/ipfs/QmVBXaQqupXCFtS62xtr9EsKGkbK9LviqCKSzwcqzwvX9U/go-mfs" + "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" "gx/ipfs/QmYZwey1thDTynSrvd6qQkX24UpTka6TFhQ2v569UpoqxD/go-ipfs-exchange-offline" ft "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs" bservice "gx/ipfs/QmbgbNxC1PMyS2gbx7nf2jKNG7bZAfYJJebdK4ptBBWCz1/go-blockservice" diff --git a/core/commands/get.go b/core/commands/get.go index 22b4b02152a..f59247c90c1 100644 --- a/core/commands/get.go +++ b/core/commands/get.go @@ -13,10 +13,10 @@ import ( "github.com/ipfs/go-ipfs/core/commands/cmdenv" "github.com/ipfs/go-ipfs/core/commands/e" - "github.com/ipfs/go-ipfs/core/coreapi/interface" "gx/ipfs/QmQine7gvHncNevKtG9QXxf3nXcwSj6aDDmMm52mHofEEp/tar-utils" "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" + "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" "gx/ipfs/QmYWB8oH6o7qftxoyqTTZhzLrhKCVT7NYahECQTwTtqbgj/pb" "gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" diff --git a/core/commands/keystore.go b/core/commands/keystore.go index 2053ac8972f..f605fad3328 100644 --- a/core/commands/keystore.go +++ b/core/commands/keystore.go @@ -6,9 +6,9 @@ import ( "text/tabwriter" cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" - options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" cmds "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" + options "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/ls.go b/core/commands/ls.go index 8cb520283f7..d899ef7f2a2 100644 --- a/core/commands/ls.go +++ b/core/commands/ls.go @@ -8,10 +8,10 @@ import ( "text/tabwriter" cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" - iface "github.com/ipfs/go-ipfs/core/coreapi/interface" - options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" cmds "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" + iface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + options "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/name/ipns.go b/core/commands/name/ipns.go index 6ec2fce6b60..bb1347fa5e5 100644 --- a/core/commands/name/ipns.go +++ b/core/commands/name/ipns.go @@ -8,11 +8,11 @@ import ( "time" cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" - options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - nsopts "github.com/ipfs/go-ipfs/core/coreapi/interface/options/namesys" path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" cmds "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" + options "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" + nsopts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/name/publish.go b/core/commands/name/publish.go index 25befe79a18..4500bb7c637 100644 --- a/core/commands/name/publish.go +++ b/core/commands/name/publish.go @@ -7,10 +7,10 @@ import ( "time" cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" - iface "github.com/ipfs/go-ipfs/core/coreapi/interface" - options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" cmds "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" + iface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + options "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/object/diff.go b/core/commands/object/diff.go index 5f0b163f606..6c7256d29cc 100644 --- a/core/commands/object/diff.go +++ b/core/commands/object/diff.go @@ -5,10 +5,10 @@ import ( "io" cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" cmds "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/object/object.go b/core/commands/object/object.go index 94fe86c454f..90e6b55a1e3 100644 --- a/core/commands/object/object.go +++ b/core/commands/object/object.go @@ -9,13 +9,13 @@ import ( "text/tabwriter" "github.com/ipfs/go-ipfs/core/commands/cmdenv" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - "github.com/ipfs/go-ipfs/core/coreapi/interface/options" "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" dag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/object/patch.go b/core/commands/object/patch.go index 43a9833af6b..3abf7f1d66c 100644 --- a/core/commands/object/patch.go +++ b/core/commands/object/patch.go @@ -5,10 +5,10 @@ import ( "io" "github.com/ipfs/go-ipfs/core/commands/cmdenv" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - "github.com/ipfs/go-ipfs/core/coreapi/interface/options" "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/pin.go b/core/commands/pin.go index 771449725bd..8cb3dafdbdb 100644 --- a/core/commands/pin.go +++ b/core/commands/pin.go @@ -10,13 +10,13 @@ import ( core "github.com/ipfs/go-ipfs/core" cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" e "github.com/ipfs/go-ipfs/core/commands/e" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" pin "github.com/ipfs/go-ipfs/pin" cmds "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" dag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + options "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" verifcid "gx/ipfs/QmYMQuypUbgsdNHmuCBSUJV6wdQVsBHRivNAp3efHJwZJD/go-verifcid" offline "gx/ipfs/QmYZwey1thDTynSrvd6qQkX24UpTka6TFhQ2v569UpoqxD/go-ipfs-exchange-offline" bserv "gx/ipfs/QmbgbNxC1PMyS2gbx7nf2jKNG7bZAfYJJebdK4ptBBWCz1/go-blockservice" diff --git a/core/commands/pubsub.go b/core/commands/pubsub.go index 0a628eeb888..d2fe2e19172 100644 --- a/core/commands/pubsub.go +++ b/core/commands/pubsub.go @@ -9,9 +9,9 @@ import ( "sort" cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" - options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" cmds "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" + options "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/resolve.go b/core/commands/resolve.go index 7e0a72a2fa4..291cf81b859 100644 --- a/core/commands/resolve.go +++ b/core/commands/resolve.go @@ -9,13 +9,13 @@ import ( cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" ncmd "github.com/ipfs/go-ipfs/core/commands/name" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - nsopts "github.com/ipfs/go-ipfs/core/coreapi/interface/options/namesys" ns "github.com/ipfs/go-ipfs/namesys" - path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" + path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" cmds "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + options "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" + nsopts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" cidenc "gx/ipfs/QmdPQx9fvN5ExVwMhRmh7YpCQJzJrFhd1AjVBwJmRMFJeX/go-cidutil/cidenc" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/unixfs/ls.go b/core/commands/unixfs/ls.go index 02824be784d..b9e9377be2a 100644 --- a/core/commands/unixfs/ls.go +++ b/core/commands/unixfs/ls.go @@ -7,10 +7,10 @@ import ( "text/tabwriter" cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" - iface "github.com/ipfs/go-ipfs/core/coreapi/interface" cmds "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" merkledag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" + iface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" unixfs "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/coreapi/block.go b/core/coreapi/block.go index 1a75630aaa1..f000b42603d 100644 --- a/core/coreapi/block.go +++ b/core/coreapi/block.go @@ -8,12 +8,12 @@ import ( "io/ioutil" util "github.com/ipfs/go-ipfs/blocks/blockstoreutil" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - caopts "github.com/ipfs/go-ipfs/core/coreapi/interface/options" pin "github.com/ipfs/go-ipfs/pin" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" blocks "gx/ipfs/QmWoXtvgC8inqFkAATB7cp2Dax7XBi9VDvSg9RCCZufmRk/go-block-format" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + caopts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" ) type BlockAPI CoreAPI diff --git a/core/coreapi/coreapi.go b/core/coreapi/coreapi.go index 45d4238638a..a2bc57b66a4 100644 --- a/core/coreapi/coreapi.go +++ b/core/coreapi/coreapi.go @@ -17,14 +17,12 @@ import ( "context" "errors" "fmt" + "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/namesys" "github.com/ipfs/go-ipfs/pin" "github.com/ipfs/go-ipfs/repo" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" "gx/ipfs/QmP2g3VxmC7g7fyRJDj1VJ72KHZbJ9UW24YjSWEj1XTb4H/go-ipfs-exchange-interface" "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" @@ -35,6 +33,8 @@ import ( "gx/ipfs/QmS2aqUZLJp8kF1ihE5rvDGE5LvmKDPnx32w9Z1BW9xLV5/go-ipfs-blockstore" dag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" pubsub "gx/ipfs/QmWL6MKfes1HuSiRUNzGmwy9YyQDwcZF9V1NaA2keYKhtE/go-libp2p-pubsub" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" offlinexch "gx/ipfs/QmYZwey1thDTynSrvd6qQkX24UpTka6TFhQ2v569UpoqxD/go-ipfs-exchange-offline" bserv "gx/ipfs/QmbgbNxC1PMyS2gbx7nf2jKNG7bZAfYJJebdK4ptBBWCz1/go-blockservice" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" diff --git a/core/coreapi/dht.go b/core/coreapi/dht.go index ff06d8bc854..5301f615a47 100644 --- a/core/coreapi/dht.go +++ b/core/coreapi/dht.go @@ -4,15 +4,14 @@ import ( "context" "fmt" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - caopts "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - peer "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" pstore "gx/ipfs/QmQFFp4ntkd4C14sP3FaH9WJyBuetuGUVo6dShNHvnoEvC/go-libp2p-peerstore" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" routing "gx/ipfs/QmRjT8Bkut84fHf9nxMQBxGsqLAkqzMdFaemDK7e61dBNZ/go-libp2p-routing" blockstore "gx/ipfs/QmS2aqUZLJp8kF1ihE5rvDGE5LvmKDPnx32w9Z1BW9xLV5/go-ipfs-blockstore" dag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + caopts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" offline "gx/ipfs/QmYZwey1thDTynSrvd6qQkX24UpTka6TFhQ2v569UpoqxD/go-ipfs-exchange-offline" blockservice "gx/ipfs/QmbgbNxC1PMyS2gbx7nf2jKNG7bZAfYJJebdK4ptBBWCz1/go-blockservice" cidutil "gx/ipfs/QmdPQx9fvN5ExVwMhRmh7YpCQJzJrFhd1AjVBwJmRMFJeX/go-cidutil" diff --git a/core/coreapi/interface/block.go b/core/coreapi/interface/block.go deleted file mode 100644 index b99b05fdb72..00000000000 --- a/core/coreapi/interface/block.go +++ /dev/null @@ -1,36 +0,0 @@ -package iface - -import ( - "context" - "io" - - options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" -) - -// BlockStat contains information about a block -type BlockStat interface { - // Size is the size of a block - Size() int - - // Path returns path to the block - Path() ResolvedPath -} - -// BlockAPI specifies the interface to the block layer -type BlockAPI interface { - // Put imports raw block data, hashing it using specified settings. - Put(context.Context, io.Reader, ...options.BlockPutOption) (BlockStat, error) - - // Get attempts to resolve the path and return a reader for data in the block - Get(context.Context, Path) (io.Reader, error) - - // Rm removes the block specified by the path from local blockstore. - // By default an error will be returned if the block can't be found locally. - // - // NOTE: If the specified block is pinned it won't be removed and no error - // will be returned - Rm(context.Context, Path, ...options.BlockRmOption) error - - // Stat returns information on - Stat(context.Context, Path) (BlockStat, error) -} diff --git a/core/coreapi/interface/coreapi.go b/core/coreapi/interface/coreapi.go deleted file mode 100644 index d26ec4f7d1a..00000000000 --- a/core/coreapi/interface/coreapi.go +++ /dev/null @@ -1,55 +0,0 @@ -// Package iface defines IPFS Core API which is a set of interfaces used to -// interact with IPFS nodes. -package iface - -import ( - "context" - - "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - - ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" -) - -// CoreAPI defines an unified interface to IPFS for Go programs -type CoreAPI interface { - // Unixfs returns an implementation of Unixfs API - Unixfs() UnixfsAPI - - // Block returns an implementation of Block API - Block() BlockAPI - - // Dag returns an implementation of Dag API - Dag() APIDagService - - // Name returns an implementation of Name API - Name() NameAPI - - // Key returns an implementation of Key API - Key() KeyAPI - - // Pin returns an implementation of Pin API - Pin() PinAPI - - // ObjectAPI returns an implementation of Object API - Object() ObjectAPI - - // Dht returns an implementation of Dht API - Dht() DhtAPI - - // Swarm returns an implementation of Swarm API - Swarm() SwarmAPI - - // PubSub returns an implementation of PubSub API - PubSub() PubSubAPI - - // ResolvePath resolves the path using Unixfs resolver - ResolvePath(context.Context, Path) (ResolvedPath, error) - - // ResolveNode resolves the path (if not resolved already) using Unixfs - // resolver, gets and returns the resolved Node - ResolveNode(context.Context, Path) (ipld.Node, error) - - // WithOptions creates new instance of CoreAPI based on this instance with - // a set of options applied - WithOptions(...options.ApiOption) (CoreAPI, error) -} diff --git a/core/coreapi/interface/dag.go b/core/coreapi/interface/dag.go deleted file mode 100644 index d15e24360e1..00000000000 --- a/core/coreapi/interface/dag.go +++ /dev/null @@ -1,13 +0,0 @@ -package iface - -import ( - ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" -) - -// APIDagService extends ipld.DAGService -type APIDagService interface { - ipld.DAGService - - // Pinning returns special NodeAdder which recursively pins added nodes - Pinning() ipld.NodeAdder -} diff --git a/core/coreapi/interface/dht.go b/core/coreapi/interface/dht.go deleted file mode 100644 index 94fb3779f7a..00000000000 --- a/core/coreapi/interface/dht.go +++ /dev/null @@ -1,26 +0,0 @@ -package iface - -import ( - "context" - - "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - - peer "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" - pstore "gx/ipfs/QmQFFp4ntkd4C14sP3FaH9WJyBuetuGUVo6dShNHvnoEvC/go-libp2p-peerstore" -) - -// DhtAPI specifies the interface to the DHT -// Note: This API will likely get deprecated in near future, see -// https://github.com/ipfs/interface-ipfs-core/issues/249 for more context. -type DhtAPI interface { - // FindPeer queries the DHT for all of the multiaddresses associated with a - // Peer ID - FindPeer(context.Context, peer.ID) (pstore.PeerInfo, error) - - // FindProviders finds peers in the DHT who can provide a specific value - // given a key. - FindProviders(context.Context, Path, ...options.DhtFindProvidersOption) (<-chan pstore.PeerInfo, error) - - // Provide announces to the network that you are providing given values - Provide(context.Context, Path, ...options.DhtProvideOption) error -} diff --git a/core/coreapi/interface/errors.go b/core/coreapi/interface/errors.go deleted file mode 100644 index 234abe5667e..00000000000 --- a/core/coreapi/interface/errors.go +++ /dev/null @@ -1,9 +0,0 @@ -package iface - -import "errors" - -var ( - ErrIsDir = errors.New("this dag node is a directory") - ErrNotFile = errors.New("this dag node is not a regular file") - ErrOffline = errors.New("this action must be run in online mode, try running 'ipfs daemon' first") -) diff --git a/core/coreapi/interface/key.go b/core/coreapi/interface/key.go deleted file mode 100644 index 69857e6137a..00000000000 --- a/core/coreapi/interface/key.go +++ /dev/null @@ -1,41 +0,0 @@ -package iface - -import ( - "context" - - options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - - "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" -) - -// Key specifies the interface to Keys in KeyAPI Keystore -type Key interface { - // Key returns key name - Name() string - - // Path returns key path - Path() Path - - // ID returns key PeerID - ID() peer.ID -} - -// KeyAPI specifies the interface to Keystore -type KeyAPI interface { - // Generate generates new key, stores it in the keystore under the specified - // name and returns a base58 encoded multihash of it's public key - Generate(ctx context.Context, name string, opts ...options.KeyGenerateOption) (Key, error) - - // Rename renames oldName key to newName. Returns the key and whether another - // key was overwritten, or an error - Rename(ctx context.Context, oldName string, newName string, opts ...options.KeyRenameOption) (Key, bool, error) - - // List lists keys stored in keystore - List(ctx context.Context) ([]Key, error) - - // Self returns the 'main' node key - Self(ctx context.Context) (Key, error) - - // Remove removes keys from keystore. Returns ipns path of the removed key - Remove(ctx context.Context, name string) (Key, error) -} diff --git a/core/coreapi/interface/name.go b/core/coreapi/interface/name.go deleted file mode 100644 index a02bc078748..00000000000 --- a/core/coreapi/interface/name.go +++ /dev/null @@ -1,46 +0,0 @@ -package iface - -import ( - "context" - "errors" - - options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" -) - -var ErrResolveFailed = errors.New("could not resolve name") - -// IpnsEntry specifies the interface to IpnsEntries -type IpnsEntry interface { - // Name returns IpnsEntry name - Name() string - // Value returns IpnsEntry value - Value() Path -} - -type IpnsResult struct { - Path - Err error -} - -// NameAPI specifies the interface to IPNS. -// -// IPNS is a PKI namespace, where names are the hashes of public keys, and the -// private key enables publishing new (signed) values. In both publish and -// resolve, the default name used is the node's own PeerID, which is the hash of -// its public key. -// -// You can use .Key API to list and generate more names and their respective keys. -type NameAPI interface { - // Publish announces new IPNS name - Publish(ctx context.Context, path Path, opts ...options.NamePublishOption) (IpnsEntry, error) - - // Resolve attempts to resolve the newest version of the specified name - Resolve(ctx context.Context, name string, opts ...options.NameResolveOption) (Path, error) - - // Search is a version of Resolve which outputs paths as they are discovered, - // reducing the time to first entry - // - // Note: by default, all paths read from the channel are considered unsafe, - // except the latest (last path in channel read buffer). - Search(ctx context.Context, name string, opts ...options.NameResolveOption) (<-chan IpnsResult, error) -} diff --git a/core/coreapi/interface/object.go b/core/coreapi/interface/object.go deleted file mode 100644 index 2ed357cb63a..00000000000 --- a/core/coreapi/interface/object.go +++ /dev/null @@ -1,106 +0,0 @@ -package iface - -import ( - "context" - "io" - - options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - - cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" - ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" -) - -// ObjectStat provides information about dag nodes -type ObjectStat struct { - // Cid is the CID of the node - Cid cid.Cid - - // NumLinks is number of links the node contains - NumLinks int - - // BlockSize is size of the raw serialized node - BlockSize int - - // LinksSize is size of the links block section - LinksSize int - - // DataSize is the size of data block section - DataSize int - - // CumulativeSize is size of the tree (BlockSize + link sizes) - CumulativeSize int -} - -// ChangeType denotes type of change in ObjectChange -type ChangeType int - -const ( - // DiffAdd is set when a link was added to the graph - DiffAdd ChangeType = iota - - // DiffRemove is set when a link was removed from the graph - DiffRemove - - // DiffMod is set when a link was changed in the graph - DiffMod -) - -// ObjectChange represents a change ia a graph -type ObjectChange struct { - // Type of the change, either: - // * DiffAdd - Added a link - // * DiffRemove - Removed a link - // * DiffMod - Modified a link - Type ChangeType - - // Path to the changed link - Path string - - // Before holds the link path before the change. Note that when a link is - // added, this will be nil. - Before ResolvedPath - - // After holds the link path after the change. Note that when a link is - // removed, this will be nil. - After ResolvedPath -} - -// ObjectAPI specifies the interface to MerkleDAG and contains useful utilities -// for manipulating MerkleDAG data structures. -type ObjectAPI interface { - // New creates new, empty (by default) dag-node. - New(context.Context, ...options.ObjectNewOption) (ipld.Node, error) - - // Put imports the data into merkledag - Put(context.Context, io.Reader, ...options.ObjectPutOption) (ResolvedPath, error) - - // Get returns the node for the path - Get(context.Context, Path) (ipld.Node, error) - - // Data returns reader for data of the node - Data(context.Context, Path) (io.Reader, error) - - // Links returns lint or links the node contains - Links(context.Context, Path) ([]*ipld.Link, error) - - // Stat returns information about the node - Stat(context.Context, Path) (*ObjectStat, error) - - // AddLink adds a link under the specified path. child path can point to a - // subdirectory within the patent which must be present (can be overridden - // with WithCreate option). - AddLink(ctx context.Context, base Path, name string, child Path, opts ...options.ObjectAddLinkOption) (ResolvedPath, error) - - // RmLink removes a link from the node - RmLink(ctx context.Context, base Path, link string) (ResolvedPath, error) - - // AppendData appends data to the node - AppendData(context.Context, Path, io.Reader) (ResolvedPath, error) - - // SetData sets the data contained in the node - SetData(context.Context, Path, io.Reader) (ResolvedPath, error) - - // Diff returns a set of changes needed to transform the first object into the - // second. - Diff(context.Context, Path, Path) ([]ObjectChange, error) -} diff --git a/core/coreapi/interface/options/block.go b/core/coreapi/interface/options/block.go deleted file mode 100644 index 40dfba79ab2..00000000000 --- a/core/coreapi/interface/options/block.go +++ /dev/null @@ -1,126 +0,0 @@ -package options - -import ( - "fmt" - cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" - mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" -) - -type BlockPutSettings struct { - Codec string - MhType uint64 - MhLength int - Pin bool -} - -type BlockRmSettings struct { - Force bool -} - -type BlockPutOption func(*BlockPutSettings) error -type BlockRmOption func(*BlockRmSettings) error - -func BlockPutOptions(opts ...BlockPutOption) (*BlockPutSettings, cid.Prefix, error) { - options := &BlockPutSettings{ - Codec: "", - MhType: mh.SHA2_256, - MhLength: -1, - Pin: false, - } - - for _, opt := range opts { - err := opt(options) - if err != nil { - return nil, cid.Prefix{}, err - } - } - - var pref cid.Prefix - pref.Version = 1 - - if options.Codec == "" { - if options.MhType != mh.SHA2_256 || (options.MhLength != -1 && options.MhLength != 32) { - options.Codec = "protobuf" - } else { - options.Codec = "v0" - } - } - - if options.Codec == "v0" && options.MhType == mh.SHA2_256 { - pref.Version = 0 - } - - formatval, ok := cid.Codecs[options.Codec] - if !ok { - return nil, cid.Prefix{}, fmt.Errorf("unrecognized format: %s", options.Codec) - } - - if options.Codec == "v0" { - if options.MhType != mh.SHA2_256 || (options.MhLength != -1 && options.MhLength != 32) { - return nil, cid.Prefix{}, fmt.Errorf("only sha2-255-32 is allowed with CIDv0") - } - } - - pref.Codec = formatval - - pref.MhType = options.MhType - pref.MhLength = options.MhLength - - return options, pref, nil -} - -func BlockRmOptions(opts ...BlockRmOption) (*BlockRmSettings, error) { - options := &BlockRmSettings{ - Force: false, - } - - for _, opt := range opts { - err := opt(options) - if err != nil { - return nil, err - } - } - return options, nil -} - -type blockOpts struct{} - -var Block blockOpts - -// Format is an option for Block.Put which specifies the multicodec to use to -// serialize the object. Default is "v0" -func (blockOpts) Format(codec string) BlockPutOption { - return func(settings *BlockPutSettings) error { - settings.Codec = codec - return nil - } -} - -// Hash is an option for Block.Put which specifies the multihash settings to use -// when hashing the object. Default is mh.SHA2_256 (0x12). -// If mhLen is set to -1, default length for the hash will be used -func (blockOpts) Hash(mhType uint64, mhLen int) BlockPutOption { - return func(settings *BlockPutSettings) error { - settings.MhType = mhType - settings.MhLength = mhLen - return nil - } -} - -// Pin is an option for Block.Put which specifies whether to (recursively) pin -// added blocks -func (blockOpts) Pin(pin bool) BlockPutOption { - return func(settings *BlockPutSettings) error { - settings.Pin = pin - return nil - } -} - -// Force is an option for Block.Rm which, when set to true, will ignore -// non-existing blocks -func (blockOpts) Force(force bool) BlockRmOption { - return func(settings *BlockRmSettings) error { - settings.Force = force - return nil - } -} diff --git a/core/coreapi/interface/options/dht.go b/core/coreapi/interface/options/dht.go deleted file mode 100644 index e13e1602006..00000000000 --- a/core/coreapi/interface/options/dht.go +++ /dev/null @@ -1,62 +0,0 @@ -package options - -type DhtProvideSettings struct { - Recursive bool -} - -type DhtFindProvidersSettings struct { - NumProviders int -} - -type DhtProvideOption func(*DhtProvideSettings) error -type DhtFindProvidersOption func(*DhtFindProvidersSettings) error - -func DhtProvideOptions(opts ...DhtProvideOption) (*DhtProvideSettings, error) { - options := &DhtProvideSettings{ - Recursive: false, - } - - for _, opt := range opts { - err := opt(options) - if err != nil { - return nil, err - } - } - return options, nil -} - -func DhtFindProvidersOptions(opts ...DhtFindProvidersOption) (*DhtFindProvidersSettings, error) { - options := &DhtFindProvidersSettings{ - NumProviders: 20, - } - - for _, opt := range opts { - err := opt(options) - if err != nil { - return nil, err - } - } - return options, nil -} - -type dhtOpts struct{} - -var Dht dhtOpts - -// Recursive is an option for Dht.Provide which specifies whether to provide -// the given path recursively -func (dhtOpts) Recursive(recursive bool) DhtProvideOption { - return func(settings *DhtProvideSettings) error { - settings.Recursive = recursive - return nil - } -} - -// NumProviders is an option for Dht.FindProviders which specifies the -// number of peers to look for. Default is 20 -func (dhtOpts) NumProviders(numProviders int) DhtFindProvidersOption { - return func(settings *DhtFindProvidersSettings) error { - settings.NumProviders = numProviders - return nil - } -} diff --git a/core/coreapi/interface/options/global.go b/core/coreapi/interface/options/global.go deleted file mode 100644 index 90e2586f10d..00000000000 --- a/core/coreapi/interface/options/global.go +++ /dev/null @@ -1,47 +0,0 @@ -package options - -type ApiSettings struct { - Offline bool - FetchBlocks bool -} - -type ApiOption func(*ApiSettings) error - -func ApiOptions(opts ...ApiOption) (*ApiSettings, error) { - options := &ApiSettings{ - Offline: false, - FetchBlocks: true, - } - - return ApiOptionsTo(options, opts...) -} - -func ApiOptionsTo(options *ApiSettings, opts ...ApiOption) (*ApiSettings, error) { - for _, opt := range opts { - err := opt(options) - if err != nil { - return nil, err - } - } - return options, nil -} - -type apiOpts struct{} - -var Api apiOpts - -func (apiOpts) Offline(offline bool) ApiOption { - return func(settings *ApiSettings) error { - settings.Offline = offline - return nil - } -} - -// FetchBlocks when set to false prevents api from fetching blocks from the -// network while allowing other services such as IPNS to still be online -func (apiOpts) FetchBlocks(fetch bool) ApiOption { - return func(settings *ApiSettings) error { - settings.FetchBlocks = fetch - return nil - } -} diff --git a/core/coreapi/interface/options/key.go b/core/coreapi/interface/options/key.go deleted file mode 100644 index 80beea35299..00000000000 --- a/core/coreapi/interface/options/key.go +++ /dev/null @@ -1,87 +0,0 @@ -package options - -const ( - RSAKey = "rsa" - Ed25519Key = "ed25519" - - DefaultRSALen = 2048 -) - -type KeyGenerateSettings struct { - Algorithm string - Size int -} - -type KeyRenameSettings struct { - Force bool -} - -type KeyGenerateOption func(*KeyGenerateSettings) error -type KeyRenameOption func(*KeyRenameSettings) error - -func KeyGenerateOptions(opts ...KeyGenerateOption) (*KeyGenerateSettings, error) { - options := &KeyGenerateSettings{ - Algorithm: RSAKey, - Size: -1, - } - - for _, opt := range opts { - err := opt(options) - if err != nil { - return nil, err - } - } - return options, nil -} - -func KeyRenameOptions(opts ...KeyRenameOption) (*KeyRenameSettings, error) { - options := &KeyRenameSettings{ - Force: false, - } - - for _, opt := range opts { - err := opt(options) - if err != nil { - return nil, err - } - } - return options, nil -} - -type keyOpts struct{} - -var Key keyOpts - -// Type is an option for Key.Generate which specifies which algorithm -// should be used for the key. Default is options.RSAKey -// -// Supported key types: -// * options.RSAKey -// * options.Ed25519Key -func (keyOpts) Type(algorithm string) KeyGenerateOption { - return func(settings *KeyGenerateSettings) error { - settings.Algorithm = algorithm - return nil - } -} - -// Size is an option for Key.Generate which specifies the size of the key to -// generated. Default is -1 -// -// value of -1 means 'use default size for key type': -// * 2048 for RSA -func (keyOpts) Size(size int) KeyGenerateOption { - return func(settings *KeyGenerateSettings) error { - settings.Size = size - return nil - } -} - -// Force is an option for Key.Rename which specifies whether to allow to -// replace existing keys. -func (keyOpts) Force(force bool) KeyRenameOption { - return func(settings *KeyRenameSettings) error { - settings.Force = force - return nil - } -} diff --git a/core/coreapi/interface/options/name.go b/core/coreapi/interface/options/name.go deleted file mode 100644 index e07ef8a595e..00000000000 --- a/core/coreapi/interface/options/name.go +++ /dev/null @@ -1,122 +0,0 @@ -package options - -import ( - "time" - - ropts "github.com/ipfs/go-ipfs/core/coreapi/interface/options/namesys" -) - -const ( - DefaultNameValidTime = 24 * time.Hour -) - -type NamePublishSettings struct { - ValidTime time.Duration - Key string - - TTL *time.Duration - - AllowOffline bool -} - -type NameResolveSettings struct { - Cache bool - - ResolveOpts []ropts.ResolveOpt -} - -type NamePublishOption func(*NamePublishSettings) error -type NameResolveOption func(*NameResolveSettings) error - -func NamePublishOptions(opts ...NamePublishOption) (*NamePublishSettings, error) { - options := &NamePublishSettings{ - ValidTime: DefaultNameValidTime, - Key: "self", - - AllowOffline: false, - } - - for _, opt := range opts { - err := opt(options) - if err != nil { - return nil, err - } - } - - return options, nil -} - -func NameResolveOptions(opts ...NameResolveOption) (*NameResolveSettings, error) { - options := &NameResolveSettings{ - Cache: true, - } - - for _, opt := range opts { - err := opt(options) - if err != nil { - return nil, err - } - } - - return options, nil -} - -type nameOpts struct{} - -var Name nameOpts - -// ValidTime is an option for Name.Publish which specifies for how long the -// entry will remain valid. Default value is 24h -func (nameOpts) ValidTime(validTime time.Duration) NamePublishOption { - return func(settings *NamePublishSettings) error { - settings.ValidTime = validTime - return nil - } -} - -// Key is an option for Name.Publish which specifies the key to use for -// publishing. Default value is "self" which is the node's own PeerID. -// The key parameter must be either PeerID or keystore key alias. -// -// You can use KeyAPI to list and generate more names and their respective keys. -func (nameOpts) Key(key string) NamePublishOption { - return func(settings *NamePublishSettings) error { - settings.Key = key - return nil - } -} - -// AllowOffline is an option for Name.Publish which specifies whether to allow -// publishing when the node is offline. Default value is false -func (nameOpts) AllowOffline(allow bool) NamePublishOption { - return func(settings *NamePublishSettings) error { - settings.AllowOffline = allow - return nil - } -} - -// TTL is an option for Name.Publish which specifies the time duration the -// published record should be cached for (caution: experimental). -func (nameOpts) TTL(ttl time.Duration) NamePublishOption { - return func(settings *NamePublishSettings) error { - settings.TTL = &ttl - return nil - } -} - -// Cache is an option for Name.Resolve which specifies if cache should be used. -// Default value is true -func (nameOpts) Cache(cache bool) NameResolveOption { - return func(settings *NameResolveSettings) error { - settings.Cache = cache - return nil - } -} - -// -func (nameOpts) ResolveOption(opt ropts.ResolveOpt) NameResolveOption { - return func(settings *NameResolveSettings) error { - settings.ResolveOpts = append(settings.ResolveOpts, opt) - return nil - } -} diff --git a/core/coreapi/interface/options/namesys/opts.go b/core/coreapi/interface/options/namesys/opts.go deleted file mode 100644 index ee2bd5ac2a4..00000000000 --- a/core/coreapi/interface/options/namesys/opts.go +++ /dev/null @@ -1,74 +0,0 @@ -package nsopts - -import ( - "time" -) - -const ( - // DefaultDepthLimit is the default depth limit used by Resolve. - DefaultDepthLimit = 32 - - // UnlimitedDepth allows infinite recursion in Resolve. You - // probably don't want to use this, but it's here if you absolutely - // trust resolution to eventually complete and can't put an upper - // limit on how many steps it will take. - UnlimitedDepth = 0 -) - -// ResolveOpts specifies options for resolving an IPNS path -type ResolveOpts struct { - // Recursion depth limit - Depth uint - // The number of IPNS records to retrieve from the DHT - // (the best record is selected from this set) - DhtRecordCount uint - // The amount of time to wait for DHT records to be fetched - // and verified. A zero value indicates that there is no explicit - // timeout (although there is an implicit timeout due to dial - // timeouts within the DHT) - DhtTimeout time.Duration -} - -// DefaultResolveOpts returns the default options for resolving -// an IPNS path -func DefaultResolveOpts() ResolveOpts { - return ResolveOpts{ - Depth: DefaultDepthLimit, - DhtRecordCount: 16, - DhtTimeout: time.Minute, - } -} - -// ResolveOpt is used to set an option -type ResolveOpt func(*ResolveOpts) - -// Depth is the recursion depth limit -func Depth(depth uint) ResolveOpt { - return func(o *ResolveOpts) { - o.Depth = depth - } -} - -// DhtRecordCount is the number of IPNS records to retrieve from the DHT -func DhtRecordCount(count uint) ResolveOpt { - return func(o *ResolveOpts) { - o.DhtRecordCount = count - } -} - -// DhtTimeout is the amount of time to wait for DHT records to be fetched -// and verified. A zero value indicates that there is no explicit timeout -func DhtTimeout(timeout time.Duration) ResolveOpt { - return func(o *ResolveOpts) { - o.DhtTimeout = timeout - } -} - -// ProcessOpts converts an array of ResolveOpt into a ResolveOpts object -func ProcessOpts(opts []ResolveOpt) ResolveOpts { - rsopts := DefaultResolveOpts() - for _, option := range opts { - option(&rsopts) - } - return rsopts -} diff --git a/core/coreapi/interface/options/object.go b/core/coreapi/interface/options/object.go deleted file mode 100644 index e484a9f3632..00000000000 --- a/core/coreapi/interface/options/object.go +++ /dev/null @@ -1,124 +0,0 @@ -package options - -type ObjectNewSettings struct { - Type string -} - -type ObjectPutSettings struct { - InputEnc string - DataType string - Pin bool -} - -type ObjectAddLinkSettings struct { - Create bool -} - -type ObjectNewOption func(*ObjectNewSettings) error -type ObjectPutOption func(*ObjectPutSettings) error -type ObjectAddLinkOption func(*ObjectAddLinkSettings) error - -func ObjectNewOptions(opts ...ObjectNewOption) (*ObjectNewSettings, error) { - options := &ObjectNewSettings{ - Type: "empty", - } - - for _, opt := range opts { - err := opt(options) - if err != nil { - return nil, err - } - } - return options, nil -} - -func ObjectPutOptions(opts ...ObjectPutOption) (*ObjectPutSettings, error) { - options := &ObjectPutSettings{ - InputEnc: "json", - DataType: "text", - Pin: false, - } - - for _, opt := range opts { - err := opt(options) - if err != nil { - return nil, err - } - } - return options, nil -} - -func ObjectAddLinkOptions(opts ...ObjectAddLinkOption) (*ObjectAddLinkSettings, error) { - options := &ObjectAddLinkSettings{ - Create: false, - } - - for _, opt := range opts { - err := opt(options) - if err != nil { - return nil, err - } - } - return options, nil -} - -type objectOpts struct{} - -var Object objectOpts - -// Type is an option for Object.New which allows to change the type of created -// dag node. -// -// Supported types: -// * 'empty' - Empty node -// * 'unixfs-dir' - Empty UnixFS directory -func (objectOpts) Type(t string) ObjectNewOption { - return func(settings *ObjectNewSettings) error { - settings.Type = t - return nil - } -} - -// InputEnc is an option for Object.Put which specifies the input encoding of the -// data. Default is "json". -// -// Supported encodings: -// * "protobuf" -// * "json" -func (objectOpts) InputEnc(e string) ObjectPutOption { - return func(settings *ObjectPutSettings) error { - settings.InputEnc = e - return nil - } -} - -// DataType is an option for Object.Put which specifies the encoding of data -// field when using Json or XML input encoding. -// -// Supported types: -// * "text" (default) -// * "base64" -func (objectOpts) DataType(t string) ObjectPutOption { - return func(settings *ObjectPutSettings) error { - settings.DataType = t - return nil - } -} - -// Pin is an option for Object.Put which specifies whether to pin the added -// objects, default is false -func (objectOpts) Pin(pin bool) ObjectPutOption { - return func(settings *ObjectPutSettings) error { - settings.Pin = pin - return nil - } -} - -// Create is an option for Object.AddLink which specifies whether create required -// directories for the child -func (objectOpts) Create(create bool) ObjectAddLinkOption { - return func(settings *ObjectAddLinkSettings) error { - settings.Create = create - return nil - } -} diff --git a/core/coreapi/interface/options/pin.go b/core/coreapi/interface/options/pin.go deleted file mode 100644 index cc4a8ef2966..00000000000 --- a/core/coreapi/interface/options/pin.go +++ /dev/null @@ -1,161 +0,0 @@ -package options - -type PinAddSettings struct { - Recursive bool -} - -type PinLsSettings struct { - Type string -} - -// PinRmSettings represents the settings of pin rm command -type PinRmSettings struct { - Recursive bool -} - -type PinUpdateSettings struct { - Unpin bool -} - -type PinAddOption func(*PinAddSettings) error - -// PinRmOption pin rm option func -type PinRmOption func(*PinRmSettings) error - -// PinLsOption pin ls option func -type PinLsOption func(*PinLsSettings) error -type PinUpdateOption func(*PinUpdateSettings) error - -func PinAddOptions(opts ...PinAddOption) (*PinAddSettings, error) { - options := &PinAddSettings{ - Recursive: true, - } - - for _, opt := range opts { - err := opt(options) - if err != nil { - return nil, err - } - } - - return options, nil -} - -// PinRmOptions pin rm options -func PinRmOptions(opts ...PinRmOption) (*PinRmSettings, error) { - options := &PinRmSettings{ - Recursive: true, - } - - for _, opt := range opts { - if err := opt(options); err != nil { - return nil, err - } - } - - return options, nil -} - -func PinLsOptions(opts ...PinLsOption) (*PinLsSettings, error) { - options := &PinLsSettings{ - Type: "all", - } - - for _, opt := range opts { - err := opt(options) - if err != nil { - return nil, err - } - } - - return options, nil -} - -func PinUpdateOptions(opts ...PinUpdateOption) (*PinUpdateSettings, error) { - options := &PinUpdateSettings{ - Unpin: true, - } - - for _, opt := range opts { - err := opt(options) - if err != nil { - return nil, err - } - } - - return options, nil -} - -type pinType struct{} - -type pinOpts struct { - Type pinType -} - -var Pin pinOpts - -// All is an option for Pin.Ls which will make it return all pins. It is -// the default -func (pinType) All() PinLsOption { - return Pin.pinType("all") -} - -// Recursive is an option for Pin.Ls which will make it only return recursive -// pins -func (pinType) Recursive() PinLsOption { - return Pin.pinType("recursive") -} - -// Direct is an option for Pin.Ls which will make it only return direct (non -// recursive) pins -func (pinType) Direct() PinLsOption { - return Pin.pinType("direct") -} - -// Indirect is an option for Pin.Ls which will make it only return indirect pins -// (objects referenced by other recursively pinned objects) -func (pinType) Indirect() PinLsOption { - return Pin.pinType("indirect") -} - -// Recursive is an option for Pin.Add which specifies whether to pin an entire -// object tree or just one object. Default: true -func (pinOpts) Recursive(recursive bool) PinAddOption { - return func(settings *PinAddSettings) error { - settings.Recursive = recursive - return nil - } -} - -// RmRecursive is an option for Pin.Rm -func (pinOpts) RmRecursive(recursive bool) PinRmOption { - return func(settings *PinRmSettings) error { - settings.Recursive = recursive - return nil - } -} - -// Type is an option for Pin.Ls which allows to specify which pin types should -// be returned -// -// Supported values: -// * "direct" - directly pinned objects -// * "recursive" - roots of recursive pins -// * "indirect" - indirectly pinned objects (referenced by recursively pinned -// objects) -// * "all" - all pinned objects (default) -func (pinOpts) pinType(t string) PinLsOption { - return func(settings *PinLsSettings) error { - settings.Type = t - return nil - } -} - -// Unpin is an option for Pin.Update which specifies whether to remove the old pin. -// Default is true. -func (pinOpts) Unpin(unpin bool) PinUpdateOption { - return func(settings *PinUpdateSettings) error { - settings.Unpin = unpin - return nil - } -} diff --git a/core/coreapi/interface/options/pubsub.go b/core/coreapi/interface/options/pubsub.go deleted file mode 100644 index c387d613db4..00000000000 --- a/core/coreapi/interface/options/pubsub.go +++ /dev/null @@ -1,58 +0,0 @@ -package options - -type PubSubPeersSettings struct { - Topic string -} - -type PubSubSubscribeSettings struct { - Discover bool -} - -type PubSubPeersOption func(*PubSubPeersSettings) error -type PubSubSubscribeOption func(*PubSubSubscribeSettings) error - -func PubSubPeersOptions(opts ...PubSubPeersOption) (*PubSubPeersSettings, error) { - options := &PubSubPeersSettings{ - Topic: "", - } - - for _, opt := range opts { - err := opt(options) - if err != nil { - return nil, err - } - } - return options, nil -} - -func PubSubSubscribeOptions(opts ...PubSubSubscribeOption) (*PubSubSubscribeSettings, error) { - options := &PubSubSubscribeSettings{ - Discover: false, - } - - for _, opt := range opts { - err := opt(options) - if err != nil { - return nil, err - } - } - return options, nil -} - -type pubsubOpts struct{} - -var PubSub pubsubOpts - -func (pubsubOpts) Topic(topic string) PubSubPeersOption { - return func(settings *PubSubPeersSettings) error { - settings.Topic = topic - return nil - } -} - -func (pubsubOpts) Discover(discover bool) PubSubSubscribeOption { - return func(settings *PubSubSubscribeSettings) error { - settings.Discover = discover - return nil - } -} diff --git a/core/coreapi/interface/options/unixfs.go b/core/coreapi/interface/options/unixfs.go deleted file mode 100644 index 0dd12960967..00000000000 --- a/core/coreapi/interface/options/unixfs.go +++ /dev/null @@ -1,319 +0,0 @@ -package options - -import ( - "errors" - "fmt" - - cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" - dag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" - mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" -) - -type Layout int - -const ( - BalancedLayout Layout = iota - TrickleLayout -) - -type UnixfsAddSettings struct { - CidVersion int - MhType uint64 - - Inline bool - InlineLimit int - RawLeaves bool - RawLeavesSet bool - - Chunker string - Layout Layout - - Pin bool - OnlyHash bool - FsCache bool - NoCopy bool - - Wrap bool - Hidden bool - StdinName string - - Events chan<- interface{} - Silent bool - Progress bool -} - -type UnixfsLsSettings struct { - ResolveChildren bool -} - -type UnixfsAddOption func(*UnixfsAddSettings) error -type UnixfsLsOption func(*UnixfsLsSettings) error - -func UnixfsAddOptions(opts ...UnixfsAddOption) (*UnixfsAddSettings, cid.Prefix, error) { - options := &UnixfsAddSettings{ - CidVersion: -1, - MhType: mh.SHA2_256, - - Inline: false, - InlineLimit: 32, - RawLeaves: false, - RawLeavesSet: false, - - Chunker: "size-262144", - Layout: BalancedLayout, - - Pin: false, - OnlyHash: false, - FsCache: false, - NoCopy: false, - - Wrap: false, - Hidden: false, - StdinName: "", - - Events: nil, - Silent: false, - Progress: false, - } - - for _, opt := range opts { - err := opt(options) - if err != nil { - return nil, cid.Prefix{}, err - } - } - - // nocopy -> rawblocks - if options.NoCopy && !options.RawLeaves { - // fixed? - if options.RawLeavesSet { - return nil, cid.Prefix{}, fmt.Errorf("nocopy option requires '--raw-leaves' to be enabled as well") - } - - // No, satisfy mandatory constraint. - options.RawLeaves = true - } - - // (hash != "sha2-256") -> CIDv1 - if options.MhType != mh.SHA2_256 { - switch options.CidVersion { - case 0: - return nil, cid.Prefix{}, errors.New("CIDv0 only supports sha2-256") - case 1, -1: - options.CidVersion = 1 - default: - return nil, cid.Prefix{}, fmt.Errorf("unknown CID version: %d", options.CidVersion) - } - } else { - if options.CidVersion < 0 { - // Default to CIDv0 - options.CidVersion = 0 - } - } - - // cidV1 -> raw blocks (by default) - if options.CidVersion > 0 && !options.RawLeavesSet { - options.RawLeaves = true - } - - prefix, err := dag.PrefixForCidVersion(options.CidVersion) - if err != nil { - return nil, cid.Prefix{}, err - } - - prefix.MhType = options.MhType - prefix.MhLength = -1 - - return options, prefix, nil -} - -func UnixfsLsOptions(opts ...UnixfsLsOption) (*UnixfsLsSettings, error) { - options := &UnixfsLsSettings{ - ResolveChildren: true, - } - - for _, opt := range opts { - err := opt(options) - if err != nil { - return nil, err - } - } - - return options, nil -} - -type unixfsOpts struct{} - -var Unixfs unixfsOpts - -// CidVersion specifies which CID version to use. Defaults to 0 unless an option -// that depends on CIDv1 is passed. -func (unixfsOpts) CidVersion(version int) UnixfsAddOption { - return func(settings *UnixfsAddSettings) error { - settings.CidVersion = version - return nil - } -} - -// Hash function to use. Implies CIDv1 if not set to sha2-256 (default). -// -// Table of functions is declared in https://github.com/multiformats/go-multihash/blob/master/multihash.go -func (unixfsOpts) Hash(mhtype uint64) UnixfsAddOption { - return func(settings *UnixfsAddSettings) error { - settings.MhType = mhtype - return nil - } -} - -// RawLeaves specifies whether to use raw blocks for leaves (data nodes with no -// links) instead of wrapping them with unixfs structures. -func (unixfsOpts) RawLeaves(enable bool) UnixfsAddOption { - return func(settings *UnixfsAddSettings) error { - settings.RawLeaves = enable - settings.RawLeavesSet = true - return nil - } -} - -// Inline tells the adder to inline small blocks into CIDs -func (unixfsOpts) Inline(enable bool) UnixfsAddOption { - return func(settings *UnixfsAddSettings) error { - settings.Inline = enable - return nil - } -} - -// InlineLimit sets the amount of bytes below which blocks will be encoded -// directly into CID instead of being stored and addressed by it's hash. -// Specifying this option won't enable block inlining. For that use `Inline` -// option. Default: 32 bytes -// -// Note that while there is no hard limit on the number of bytes, it should be -// kept at a reasonably low value, such as 64; implementations may choose to -// reject anything larger. -func (unixfsOpts) InlineLimit(limit int) UnixfsAddOption { - return func(settings *UnixfsAddSettings) error { - settings.InlineLimit = limit - return nil - } -} - -// Chunker specifies settings for the chunking algorithm to use. -// -// Default: size-262144, formats: -// size-[bytes] - Simple chunker splitting data into blocks of n bytes -// rabin-[min]-[avg]-[max] - Rabin chunker -func (unixfsOpts) Chunker(chunker string) UnixfsAddOption { - return func(settings *UnixfsAddSettings) error { - settings.Chunker = chunker - return nil - } -} - -// Layout tells the adder how to balance data between leaves. -// options.BalancedLayout is the default, it's optimized for static seekable -// files. -// options.TrickleLayout is optimized for streaming data, -func (unixfsOpts) Layout(layout Layout) UnixfsAddOption { - return func(settings *UnixfsAddSettings) error { - settings.Layout = layout - return nil - } -} - -// Pin tells the adder to pin the file root recursively after adding -func (unixfsOpts) Pin(pin bool) UnixfsAddOption { - return func(settings *UnixfsAddSettings) error { - settings.Pin = pin - return nil - } -} - -// HashOnly will make the adder calculate data hash without storing it in the -// blockstore or announcing it to the network -func (unixfsOpts) HashOnly(hashOnly bool) UnixfsAddOption { - return func(settings *UnixfsAddSettings) error { - settings.OnlyHash = hashOnly - return nil - } -} - -// Wrap tells the adder to wrap the added file structure with an additional -// directory. -func (unixfsOpts) Wrap(wrap bool) UnixfsAddOption { - return func(settings *UnixfsAddSettings) error { - settings.Wrap = wrap - return nil - } -} - -// Hidden enables adding of hidden files (files prefixed with '.') -func (unixfsOpts) Hidden(hidden bool) UnixfsAddOption { - return func(settings *UnixfsAddSettings) error { - settings.Hidden = hidden - return nil - } -} - -// StdinName is the name set for files which don specify FilePath as -// os.Stdin.Name() -func (unixfsOpts) StdinName(name string) UnixfsAddOption { - return func(settings *UnixfsAddSettings) error { - settings.StdinName = name - return nil - } -} - -// Events specifies channel which will be used to report events about ongoing -// Add operation. -// -// Note that if this channel blocks it may slowdown the adder -func (unixfsOpts) Events(sink chan<- interface{}) UnixfsAddOption { - return func(settings *UnixfsAddSettings) error { - settings.Events = sink - return nil - } -} - -// Silent reduces event output -func (unixfsOpts) Silent(silent bool) UnixfsAddOption { - return func(settings *UnixfsAddSettings) error { - settings.Silent = silent - return nil - } -} - -// Progress tells the adder whether to enable progress events -func (unixfsOpts) Progress(enable bool) UnixfsAddOption { - return func(settings *UnixfsAddSettings) error { - settings.Progress = enable - return nil - } -} - -// FsCache tells the adder to check the filestore for pre-existing blocks -// -// Experimental -func (unixfsOpts) FsCache(enable bool) UnixfsAddOption { - return func(settings *UnixfsAddSettings) error { - settings.FsCache = enable - return nil - } -} - -// NoCopy tells the adder to add the files using filestore. Implies RawLeaves. -// -// Experimental -func (unixfsOpts) Nocopy(enable bool) UnixfsAddOption { - return func(settings *UnixfsAddSettings) error { - settings.NoCopy = enable - return nil - } -} - -func (unixfsOpts) ResolveChildren(resolve bool) UnixfsLsOption { - return func(settings *UnixfsLsSettings) error { - settings.ResolveChildren = resolve - return nil - } -} diff --git a/core/coreapi/interface/path.go b/core/coreapi/interface/path.go deleted file mode 100644 index d59a851b458..00000000000 --- a/core/coreapi/interface/path.go +++ /dev/null @@ -1,182 +0,0 @@ -package iface - -import ( - ipfspath "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" - "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" -) - -//TODO: merge with ipfspath so we don't depend on it - -// Path is a generic wrapper for paths used in the API. A path can be resolved -// to a CID using one of Resolve functions in the API. -// -// Paths must be prefixed with a valid prefix: -// -// * /ipfs - Immutable unixfs path (files) -// * /ipld - Immutable ipld path (data) -// * /ipns - Mutable names. Usually resolves to one of the immutable paths -//TODO: /local (MFS) -type Path interface { - // String returns the path as a string. - String() string - - // Namespace returns the first component of the path. - // - // For example path "/ipfs/QmHash", calling Namespace() will return "ipfs" - Namespace() string - - // Mutable returns false if the data pointed to by this path in guaranteed - // to not change. - // - // Note that resolved mutable path can be immutable. - Mutable() bool -} - -// ResolvedPath is a path which was resolved to the last resolvable node -type ResolvedPath interface { - // Cid returns the CID of the node referenced by the path. Remainder of the - // path is guaranteed to be within the node. - // - // Examples: - // If you have 3 linked objects: QmRoot -> A -> B: - // - // cidB := {"foo": {"bar": 42 }} - // cidA := {"B": {"/": cidB }} - // cidRoot := {"A": {"/": cidA }} - // - // And resolve paths: - // - // * "/ipfs/${cidRoot}" - // * Calling Cid() will return `cidRoot` - // * Calling Root() will return `cidRoot` - // * Calling Remainder() will return `` - // - // * "/ipfs/${cidRoot}/A" - // * Calling Cid() will return `cidA` - // * Calling Root() will return `cidRoot` - // * Calling Remainder() will return `` - // - // * "/ipfs/${cidRoot}/A/B/foo" - // * Calling Cid() will return `cidB` - // * Calling Root() will return `cidRoot` - // * Calling Remainder() will return `foo` - // - // * "/ipfs/${cidRoot}/A/B/foo/bar" - // * Calling Cid() will return `cidB` - // * Calling Root() will return `cidRoot` - // * Calling Remainder() will return `foo/bar` - Cid() cid.Cid - - // Root returns the CID of the root object of the path - // - // Example: - // If you have 3 linked objects: QmRoot -> A -> B, and resolve path - // "/ipfs/QmRoot/A/B", the Root method will return the CID of object QmRoot - // - // For more examples see the documentation of Cid() method - Root() cid.Cid - - // Remainder returns unresolved part of the path - // - // Example: - // If you have 2 linked objects: QmRoot -> A, where A is a CBOR node - // containing the following data: - // - // {"foo": {"bar": 42 }} - // - // When resolving "/ipld/QmRoot/A/foo/bar", Remainder will return "foo/bar" - // - // For more examples see the documentation of Cid() method - Remainder() string - - Path -} - -// path implements coreiface.Path -type path struct { - path ipfspath.Path -} - -// resolvedPath implements coreiface.resolvedPath -type resolvedPath struct { - path - cid cid.Cid - root cid.Cid - remainder string -} - -// Join appends provided segments to the base path -func Join(base Path, a ...string) Path { - s := ipfspath.Join(append([]string{base.String()}, a...)) - return &path{path: ipfspath.FromString(s)} -} - -// IpfsPath creates new /ipfs path from the provided CID -func IpfsPath(c cid.Cid) ResolvedPath { - return &resolvedPath{ - path: path{ipfspath.Path("/ipfs/" + c.String())}, - cid: c, - root: c, - remainder: "", - } -} - -// IpldPath creates new /ipld path from the provided CID -func IpldPath(c cid.Cid) ResolvedPath { - return &resolvedPath{ - path: path{ipfspath.Path("/ipld/" + c.String())}, - cid: c, - root: c, - remainder: "", - } -} - -// ParsePath parses string path to a Path -func ParsePath(p string) (Path, error) { - pp, err := ipfspath.ParsePath(p) - if err != nil { - return nil, err - } - - return &path{path: pp}, nil -} - -// NewResolvedPath creates new ResolvedPath. This function performs no checks -// and is intended to be used by resolver implementations. Incorrect inputs may -// cause panics. Handle with care. -func NewResolvedPath(ipath ipfspath.Path, c cid.Cid, root cid.Cid, remainder string) ResolvedPath { - return &resolvedPath{ - path: path{ipath}, - cid: c, - root: root, - remainder: remainder, - } -} - -func (p *path) String() string { - return p.path.String() -} - -func (p *path) Namespace() string { - if len(p.path.Segments()) < 1 { - panic("path without namespace") //this shouldn't happen under any scenario - } - return p.path.Segments()[0] -} - -func (p *path) Mutable() bool { - //TODO: MFS: check for /local - return p.Namespace() == "ipns" -} - -func (p *resolvedPath) Cid() cid.Cid { - return p.cid -} - -func (p *resolvedPath) Root() cid.Cid { - return p.root -} - -func (p *resolvedPath) Remainder() string { - return p.remainder -} diff --git a/core/coreapi/interface/pin.go b/core/coreapi/interface/pin.go deleted file mode 100644 index 6e13def8f54..00000000000 --- a/core/coreapi/interface/pin.go +++ /dev/null @@ -1,54 +0,0 @@ -package iface - -import ( - "context" - - options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" -) - -// Pin holds information about pinned resource -type Pin interface { - // Path to the pinned object - Path() ResolvedPath - - // Type of the pin - Type() string -} - -// PinStatus holds information about pin health -type PinStatus interface { - // Ok indicates whether the pin has been verified to be correct - Ok() bool - - // BadNodes returns any bad (usually missing) nodes from the pin - BadNodes() []BadPinNode -} - -// BadPinNode is a node that has been marked as bad by Pin.Verify -type BadPinNode interface { - // Path is the path of the node - Path() ResolvedPath - - // Err is the reason why the node has been marked as bad - Err() error -} - -// PinAPI specifies the interface to pining -type PinAPI interface { - // Add creates new pin, be default recursive - pinning the whole referenced - // tree - Add(context.Context, Path, ...options.PinAddOption) error - - // Ls returns list of pinned objects on this node - Ls(context.Context, ...options.PinLsOption) ([]Pin, error) - - // Rm removes pin for object specified by the path - Rm(context.Context, Path, ...options.PinRmOption) error - - // Update changes one pin to another, skipping checks for matching paths in - // the old tree - Update(ctx context.Context, from Path, to Path, opts ...options.PinUpdateOption) error - - // Verify verifies the integrity of pinned objects - Verify(context.Context) (<-chan PinStatus, error) -} diff --git a/core/coreapi/interface/pubsub.go b/core/coreapi/interface/pubsub.go deleted file mode 100644 index 9336738260d..00000000000 --- a/core/coreapi/interface/pubsub.go +++ /dev/null @@ -1,48 +0,0 @@ -package iface - -import ( - "context" - "io" - - options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - - peer "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" -) - -// PubSubSubscription is an active PubSub subscription -type PubSubSubscription interface { - io.Closer - - // Next return the next incoming message - Next(context.Context) (PubSubMessage, error) -} - -// PubSubMessage is a single PubSub message -type PubSubMessage interface { - // From returns id of a peer from which the message has arrived - From() peer.ID - - // Data returns the message body - Data() []byte - - // Seq returns message identifier - Seq() []byte - - // Topics returns list of topics this message was set to - Topics() []string -} - -// PubSubAPI specifies the interface to PubSub -type PubSubAPI interface { - // Ls lists subscribed topics by name - Ls(context.Context) ([]string, error) - - // Peers list peers we are currently pubsubbing with - Peers(context.Context, ...options.PubSubPeersOption) ([]peer.ID, error) - - // Publish a message to a given pubsub topic - Publish(context.Context, string, []byte) error - - // Subscribe to messages on a given topic - Subscribe(context.Context, string, ...options.PubSubSubscribeOption) (PubSubSubscription, error) -} diff --git a/core/coreapi/interface/swarm.go b/core/coreapi/interface/swarm.go deleted file mode 100644 index 3af078f17ac..00000000000 --- a/core/coreapi/interface/swarm.go +++ /dev/null @@ -1,57 +0,0 @@ -package iface - -import ( - "context" - "errors" - "time" - - ma "gx/ipfs/QmNTCey11oxhb1AxDnQBRHtdhap6Ctud872NjAYPYYXPuc/go-multiaddr" - "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" - pstore "gx/ipfs/QmQFFp4ntkd4C14sP3FaH9WJyBuetuGUVo6dShNHvnoEvC/go-libp2p-peerstore" - net "gx/ipfs/QmZ7cBWUXkyWTMN4qH6NGoyMVs7JugyFChBNP4ZUp5rJHH/go-libp2p-net" - "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol" -) - -var ( - ErrNotConnected = errors.New("not connected") - ErrConnNotFound = errors.New("conn not found") -) - -// ConnectionInfo contains information about a peer -type ConnectionInfo interface { - // ID returns PeerID - ID() peer.ID - - // Address returns the multiaddress via which we are connected with the peer - Address() ma.Multiaddr - - // Direction returns which way the connection was established - Direction() net.Direction - - // Latency returns last known round trip time to the peer - Latency() (time.Duration, error) - - // Streams returns list of streams established with the peer - Streams() ([]protocol.ID, error) -} - -// SwarmAPI specifies the interface to libp2p swarm -type SwarmAPI interface { - // Connect to a given peer - Connect(context.Context, pstore.PeerInfo) error - - // Disconnect from a given address - Disconnect(context.Context, ma.Multiaddr) error - - // Peers returns the list of peers we are connected to - Peers(context.Context) ([]ConnectionInfo, error) - - // KnownAddrs returns the list of all addresses this node is aware of - KnownAddrs(context.Context) (map[peer.ID][]ma.Multiaddr, error) - - // LocalAddrs returns the list of announced listening addresses - LocalAddrs(context.Context) ([]ma.Multiaddr, error) - - // ListenAddrs returns the list of all listening addresses - ListenAddrs(context.Context) ([]ma.Multiaddr, error) -} diff --git a/core/coreapi/interface/tests/api.go b/core/coreapi/interface/tests/api.go deleted file mode 100644 index 7a4bd738624..00000000000 --- a/core/coreapi/interface/tests/api.go +++ /dev/null @@ -1,94 +0,0 @@ -package tests - -import ( - "context" - "errors" - "testing" - "time" - - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" -) - -var apiNotImplemented = errors.New("api not implemented") - -func (tp *provider) makeAPI(ctx context.Context) (coreiface.CoreAPI, error) { - api, err := tp.MakeAPISwarm(ctx, false, 1) - if err != nil { - return nil, err - } - - return api[0], nil -} - -type Provider interface { - // Make creates n nodes. fullIdentity set to false can be ignored - MakeAPISwarm(ctx context.Context, fullIdentity bool, n int) ([]coreiface.CoreAPI, error) -} - -func (tp *provider) MakeAPISwarm(ctx context.Context, fullIdentity bool, n int) ([]coreiface.CoreAPI, error) { - tp.apis <- 1 - go func() { - <-ctx.Done() - tp.apis <- -1 - }() - - return tp.Provider.MakeAPISwarm(ctx, fullIdentity, n) -} - -type provider struct { - Provider - - apis chan int -} - -func TestApi(p Provider) func(t *testing.T) { - running := 1 - apis := make(chan int) - zeroRunning := make(chan struct{}) - go func() { - for i := range apis { - running += i - if running < 1 { - close(zeroRunning) - return - } - } - }() - - tp := &provider{Provider: p, apis: apis} - - return func(t *testing.T) { - t.Run("Block", tp.TestBlock) - t.Run("Dag", tp.TestDag) - t.Run("Dht", tp.TestDht) - t.Run("Key", tp.TestKey) - t.Run("Name", tp.TestName) - t.Run("Object", tp.TestObject) - t.Run("Path", tp.TestPath) - t.Run("Pin", tp.TestPin) - t.Run("PubSub", tp.TestPubSub) - t.Run("Unixfs", tp.TestUnixfs) - - apis <- -1 - t.Run("TestsCancelCtx", func(t *testing.T) { - select { - case <-zeroRunning: - case <-time.After(time.Second): - t.Errorf("%d test swarms(s) not closed", running) - } - }) - } -} - -func (tp *provider) hasApi(t *testing.T, tf func(coreiface.CoreAPI) error) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - } - - if err := tf(api); err != nil { - t.Fatal(api) - } -} diff --git a/core/coreapi/interface/tests/block.go b/core/coreapi/interface/tests/block.go deleted file mode 100644 index c2ee70a3a6e..00000000000 --- a/core/coreapi/interface/tests/block.go +++ /dev/null @@ -1,243 +0,0 @@ -package tests - -import ( - "context" - "io/ioutil" - "strings" - "testing" - - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - opt "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - - mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" -) - -func (tp *provider) TestBlock(t *testing.T) { - tp.hasApi(t, func(api coreiface.CoreAPI) error { - if api.Block() == nil { - return apiNotImplemented - } - return nil - }) - - t.Run("TestBlockPut", tp.TestBlockPut) - t.Run("TestBlockPutFormat", tp.TestBlockPutFormat) - t.Run("TestBlockPutHash", tp.TestBlockPutHash) - t.Run("TestBlockGet", tp.TestBlockGet) - t.Run("TestBlockRm", tp.TestBlockRm) - t.Run("TestBlockStat", tp.TestBlockStat) - t.Run("TestBlockPin", tp.TestBlockPin) -} - -func (tp *provider) TestBlockPut(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - } - - res, err := api.Block().Put(ctx, strings.NewReader(`Hello`)) - if err != nil { - t.Fatal(err) - } - - if res.Path().Cid().String() != "QmPyo15ynbVrSTVdJL9th7JysHaAbXt9dM9tXk1bMHbRtk" { - t.Errorf("got wrong cid: %s", res.Path().Cid().String()) - } -} - -func (tp *provider) TestBlockPutFormat(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - res, err := api.Block().Put(ctx, strings.NewReader(`Hello`), opt.Block.Format("cbor")) - if err != nil { - t.Fatal(err) - } - - if res.Path().Cid().String() != "zdpuAn4amuLWo8Widi5v6VQpuo2dnpnwbVE3oB6qqs7mDSeoa" { - t.Errorf("got wrong cid: %s", res.Path().Cid().String()) - } -} - -func (tp *provider) TestBlockPutHash(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - res, err := api.Block().Put(ctx, strings.NewReader(`Hello`), opt.Block.Hash(mh.KECCAK_512, -1)) - if err != nil { - t.Fatal(err) - } - - if res.Path().Cid().String() != "zBurKB9YZkcDf6xa53WBE8CFX4ydVqAyf9KPXBFZt5stJzEstaS8Hukkhu4gwpMtc1xHNDbzP7sPtQKyWsP3C8fbhkmrZ" { - t.Errorf("got wrong cid: %s", res.Path().Cid().String()) - } -} - -func (tp *provider) TestBlockGet(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - res, err := api.Block().Put(ctx, strings.NewReader(`Hello`), opt.Block.Hash(mh.KECCAK_512, -1)) - if err != nil { - t.Fatal(err) - } - - r, err := api.Block().Get(ctx, res.Path()) - if err != nil { - t.Error(err) - } - - d, err := ioutil.ReadAll(r) - if err != nil { - t.Error(err) - } - - if string(d) != "Hello" { - t.Error("didn't get correct data back") - } - - p, err := coreiface.ParsePath("/ipfs/" + res.Path().Cid().String()) - if err != nil { - t.Error(err) - } - - rp, err := api.ResolvePath(ctx, p) - if err != nil { - t.Fatal(err) - } - if rp.Cid().String() != res.Path().Cid().String() { - t.Error("paths didn't match") - } -} - -func (tp *provider) TestBlockRm(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - res, err := api.Block().Put(ctx, strings.NewReader(`Hello`)) - if err != nil { - t.Fatal(err) - } - - r, err := api.Block().Get(ctx, res.Path()) - if err != nil { - t.Error(err) - } - - d, err := ioutil.ReadAll(r) - if err != nil { - t.Error(err) - } - - if string(d) != "Hello" { - t.Error("didn't get correct data back") - } - - err = api.Block().Rm(ctx, res.Path()) - if err != nil { - t.Error(err) - } - - _, err = api.Block().Get(ctx, res.Path()) - if err == nil { - t.Error("expected err to exist") - } - if !strings.Contains(err.Error(), "blockservice: key not found") { - t.Errorf("unexpected error; %s", err.Error()) - } - - err = api.Block().Rm(ctx, res.Path()) - if err == nil { - t.Error("expected err to exist") - } - if !strings.Contains(err.Error(), "blockstore: block not found") { - t.Errorf("unexpected error; %s", err.Error()) - } - - err = api.Block().Rm(ctx, res.Path(), opt.Block.Force(true)) - if err != nil { - t.Error(err) - } -} - -func (tp *provider) TestBlockStat(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - res, err := api.Block().Put(ctx, strings.NewReader(`Hello`)) - if err != nil { - t.Fatal(err) - } - - stat, err := api.Block().Stat(ctx, res.Path()) - if err != nil { - t.Error(err) - } - - if stat.Path().String() != res.Path().String() { - t.Error("paths don't match") - } - - if stat.Size() != len("Hello") { - t.Error("length doesn't match") - } -} - -func (tp *provider) TestBlockPin(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - _, err = api.Block().Put(ctx, strings.NewReader(`Hello`)) - if err != nil { - t.Fatal(err) - } - - if pins, err := api.Pin().Ls(ctx); err != nil || len(pins) != 0 { - t.Fatal("expected 0 pins") - } - - res, err := api.Block().Put(ctx, strings.NewReader(`Hello`), opt.Block.Pin(true)) - if err != nil { - t.Fatal(err) - } - - pins, err := api.Pin().Ls(ctx) - if err != nil { - return - } - if len(pins) != 1 { - t.Fatal("expected 1 pin") - } - if pins[0].Type() != "recursive" { - t.Error("expected a recursive pin") - } - if pins[0].Path().String() != res.Path().String() { - t.Error("pin path didn't match") - } -} diff --git a/core/coreapi/interface/tests/dag.go b/core/coreapi/interface/tests/dag.go deleted file mode 100644 index cf332027c88..00000000000 --- a/core/coreapi/interface/tests/dag.go +++ /dev/null @@ -1,201 +0,0 @@ -package tests - -import ( - "context" - "math" - "path" - "strings" - "testing" - - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - - ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" - ipldcbor "gx/ipfs/QmRZxJ7oybgnnwriuRub9JXp5YdFM9wiGSyRq38QC7swpS/go-ipld-cbor" - mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" -) - -func (tp *provider) TestDag(t *testing.T) { - tp.hasApi(t, func(api coreiface.CoreAPI) error { - if api.Dag() == nil { - return apiNotImplemented - } - return nil - }) - - t.Run("TestPut", tp.TestPut) - t.Run("TestPutWithHash", tp.TestPutWithHash) - t.Run("TestPath", tp.TestDagPath) - t.Run("TestTree", tp.TestTree) - t.Run("TestBatch", tp.TestBatch) -} - -var ( - treeExpected = map[string]struct{}{ - "a": {}, - "b": {}, - "c": {}, - "c/d": {}, - "c/e": {}, - } -) - -func (tp *provider) TestPut(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - nd, err := ipldcbor.FromJSON(strings.NewReader(`"Hello"`), math.MaxUint64, -1) - if err != nil { - t.Error(err) - } - - err = api.Dag().Add(ctx, nd) - if err != nil { - t.Fatal(err) - } - - if nd.Cid().String() != "zdpuAqckYF3ToF3gcJNxPZXmnmGuXd3gxHCXhq81HGxBejEvv" { - t.Errorf("got wrong cid: %s", nd.Cid().String()) - } -} - -func (tp *provider) TestPutWithHash(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - nd, err := ipldcbor.FromJSON(strings.NewReader(`"Hello"`), mh.ID, -1) - if err != nil { - t.Error(err) - } - - err = api.Dag().Add(ctx, nd) - if err != nil { - t.Fatal(err) - } - - if nd.Cid().String() != "z5hRLNd2sv4z1c" { - t.Errorf("got wrong cid: %s", nd.Cid().String()) - } -} - -func (tp *provider) TestDagPath(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - snd, err := ipldcbor.FromJSON(strings.NewReader(`"foo"`), math.MaxUint64, -1) - if err != nil { - t.Error(err) - } - - err = api.Dag().Add(ctx, snd) - if err != nil { - t.Fatal(err) - } - - nd, err := ipldcbor.FromJSON(strings.NewReader(`{"lnk": {"/": "`+snd.Cid().String()+`"}}`), math.MaxUint64, -1) - if err != nil { - t.Error(err) - } - - err = api.Dag().Add(ctx, nd) - if err != nil { - t.Fatal(err) - } - - p, err := coreiface.ParsePath(path.Join(nd.Cid().String(), "lnk")) - if err != nil { - t.Error(err) - } - - rp, err := api.ResolvePath(ctx, p) - if err != nil { - t.Error(err) - } - - ndd, err := api.Dag().Get(ctx, rp.Cid()) - if err != nil { - t.Error(err) - } - - if ndd.Cid().String() != snd.Cid().String() { - t.Errorf("got unexpected cid %s, expected %s", ndd.Cid().String(), snd.Cid().String()) - } -} - -func (tp *provider) TestTree(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - nd, err := ipldcbor.FromJSON(strings.NewReader(`{"a": 123, "b": "foo", "c": {"d": 321, "e": 111}}`), math.MaxUint64, -1) - if err != nil { - t.Error(err) - } - - err = api.Dag().Add(ctx, nd) - if err != nil { - t.Fatal(err) - } - - res, err := api.Dag().Get(ctx, nd.Cid()) - if err != nil { - t.Error(err) - } - - lst := res.Tree("", -1) - if len(lst) != len(treeExpected) { - t.Errorf("tree length of %d doesn't match expected %d", len(lst), len(treeExpected)) - } - - for _, ent := range lst { - if _, ok := treeExpected[ent]; !ok { - t.Errorf("unexpected tree entry %s", ent) - } - } -} - -func (tp *provider) TestBatch(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - nd, err := ipldcbor.FromJSON(strings.NewReader(`"Hello"`), math.MaxUint64, -1) - if err != nil { - t.Error(err) - } - - if nd.Cid().String() != "zdpuAqckYF3ToF3gcJNxPZXmnmGuXd3gxHCXhq81HGxBejEvv" { - t.Errorf("got wrong cid: %s", nd.Cid().String()) - } - - _, err = api.Dag().Get(ctx, nd.Cid()) - if err == nil || !strings.Contains(err.Error(), "not found") { - t.Error(err) - } - - if err := api.Dag().AddMany(ctx, []ipld.Node{nd}); err != nil { - t.Error(err) - } - - _, err = api.Dag().Get(ctx, nd.Cid()) - if err != nil { - t.Error(err) - } -} diff --git a/core/coreapi/interface/tests/dht.go b/core/coreapi/interface/tests/dht.go deleted file mode 100644 index d2eae1af479..00000000000 --- a/core/coreapi/interface/tests/dht.go +++ /dev/null @@ -1,159 +0,0 @@ -package tests - -import ( - "context" - "io" - "testing" - - "github.com/ipfs/go-ipfs/core/coreapi/interface" - "github.com/ipfs/go-ipfs/core/coreapi/interface/options" -) - -func (tp *provider) TestDht(t *testing.T) { - tp.hasApi(t, func(api iface.CoreAPI) error { - if api.Dht() == nil { - return apiNotImplemented - } - return nil - }) - - t.Run("TestDhtFindPeer", tp.TestDhtFindPeer) - t.Run("TestDhtFindProviders", tp.TestDhtFindProviders) - t.Run("TestDhtProvide", tp.TestDhtProvide) -} - -func (tp *provider) TestDhtFindPeer(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - apis, err := tp.MakeAPISwarm(ctx, true, 5) - if err != nil { - t.Fatal(err) - } - - self0, err := apis[0].Key().Self(ctx) - if err != nil { - t.Fatal(err) - } - - laddrs0, err := apis[0].Swarm().LocalAddrs(ctx) - if err != nil { - t.Fatal(err) - } - if len(laddrs0) != 1 { - t.Fatal("unexpected number of local addrs") - } - - pi, err := apis[2].Dht().FindPeer(ctx, self0.ID()) - if err != nil { - t.Fatal(err) - } - - if pi.Addrs[0].String() != laddrs0[0].String() { - t.Errorf("got unexpected address from FindPeer: %s", pi.Addrs[0].String()) - } - - self2, err := apis[2].Key().Self(ctx) - if err != nil { - t.Fatal(err) - } - - pi, err = apis[1].Dht().FindPeer(ctx, self2.ID()) - if err != nil { - t.Fatal(err) - } - - laddrs2, err := apis[2].Swarm().LocalAddrs(ctx) - if err != nil { - t.Fatal(err) - } - if len(laddrs2) != 1 { - t.Fatal("unexpected number of local addrs") - } - - if pi.Addrs[0].String() != laddrs2[0].String() { - t.Errorf("got unexpected address from FindPeer: %s", pi.Addrs[0].String()) - } -} - -func (tp *provider) TestDhtFindProviders(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - apis, err := tp.MakeAPISwarm(ctx, true, 5) - if err != nil { - t.Fatal(err) - } - - p, err := addTestObject(ctx, apis[0]) - if err != nil { - t.Fatal(err) - } - - out, err := apis[2].Dht().FindProviders(ctx, p, options.Dht.NumProviders(1)) - if err != nil { - t.Fatal(err) - } - - provider := <-out - - self0, err := apis[0].Key().Self(ctx) - if err != nil { - t.Fatal(err) - } - - if provider.ID.String() != self0.ID().String() { - t.Errorf("got wrong provider: %s != %s", provider.ID.String(), self0.ID().String()) - } -} - -func (tp *provider) TestDhtProvide(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - apis, err := tp.MakeAPISwarm(ctx, true, 5) - if err != nil { - t.Fatal(err) - } - - off0, err := apis[0].WithOptions(options.Api.Offline(true)) - if err != nil { - t.Fatal(err) - } - - s, err := off0.Block().Put(ctx, &io.LimitedReader{R: rnd, N: 4092}) - if err != nil { - t.Fatal(err) - } - - p := s.Path() - - out, err := apis[2].Dht().FindProviders(ctx, p, options.Dht.NumProviders(1)) - if err != nil { - t.Fatal(err) - } - - provider := <-out - - self0, err := apis[0].Key().Self(ctx) - if err != nil { - t.Fatal(err) - } - - if provider.ID.String() != "" { - t.Errorf("got wrong provider: %s != %s", provider.ID.String(), self0.ID().String()) - } - - err = apis[0].Dht().Provide(ctx, p) - if err != nil { - t.Fatal(err) - } - - out, err = apis[2].Dht().FindProviders(ctx, p, options.Dht.NumProviders(1)) - if err != nil { - t.Fatal(err) - } - - provider = <-out - - if provider.ID.String() != self0.ID().String() { - t.Errorf("got wrong provider: %s != %s", provider.ID.String(), self0.ID().String()) - } -} diff --git a/core/coreapi/interface/tests/key.go b/core/coreapi/interface/tests/key.go deleted file mode 100644 index 66011f99f9c..00000000000 --- a/core/coreapi/interface/tests/key.go +++ /dev/null @@ -1,523 +0,0 @@ -package tests - -import ( - "context" - "strings" - "testing" - - "github.com/ipfs/go-ipfs/core/coreapi/interface" - opt "github.com/ipfs/go-ipfs/core/coreapi/interface/options" -) - -func (tp *provider) TestKey(t *testing.T) { - tp.hasApi(t, func(api iface.CoreAPI) error { - if api.Key() == nil { - return apiNotImplemented - } - return nil - }) - - t.Run("TestListSelf", tp.TestListSelf) - t.Run("TestRenameSelf", tp.TestRenameSelf) - t.Run("TestRemoveSelf", tp.TestRemoveSelf) - t.Run("TestGenerate", tp.TestGenerate) - t.Run("TestGenerateSize", tp.TestGenerateSize) - t.Run("TestGenerateType", tp.TestGenerateType) - t.Run("TestGenerateExisting", tp.TestGenerateExisting) - t.Run("TestList", tp.TestList) - t.Run("TestRename", tp.TestRename) - t.Run("TestRenameToSelf", tp.TestRenameToSelf) - t.Run("TestRenameToSelfForce", tp.TestRenameToSelfForce) - t.Run("TestRenameOverwriteNoForce", tp.TestRenameOverwriteNoForce) - t.Run("TestRenameOverwrite", tp.TestRenameOverwrite) - t.Run("TestRenameSameNameNoForce", tp.TestRenameSameNameNoForce) - t.Run("TestRenameSameName", tp.TestRenameSameName) - t.Run("TestRemove", tp.TestRemove) -} - -func (tp *provider) TestListSelf(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - return - } - - self, err := api.Key().Self(ctx) - if err != nil { - t.Fatal(err) - } - - keys, err := api.Key().List(ctx) - if err != nil { - t.Fatalf("failed to list keys: %s", err) - return - } - - if len(keys) != 1 { - t.Fatalf("there should be 1 key (self), got %d", len(keys)) - return - } - - if keys[0].Name() != "self" { - t.Errorf("expected the key to be called 'self', got '%s'", keys[0].Name()) - } - - if keys[0].Path().String() != "/ipns/"+self.ID().Pretty() { - t.Errorf("expected the key to have path '/ipns/%s', got '%s'", self.ID().Pretty(), keys[0].Path().String()) - } -} - -func (tp *provider) TestRenameSelf(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - return - } - - _, _, err = api.Key().Rename(ctx, "self", "foo") - if err == nil { - t.Error("expected error to not be nil") - } else { - if !strings.Contains(err.Error(), "cannot rename key with name 'self'") { - t.Fatalf("expected error 'cannot rename key with name 'self'', got '%s'", err.Error()) - } - } - - _, _, err = api.Key().Rename(ctx, "self", "foo", opt.Key.Force(true)) - if err == nil { - t.Error("expected error to not be nil") - } else { - if !strings.Contains(err.Error(), "cannot rename key with name 'self'") { - t.Fatalf("expected error 'cannot rename key with name 'self'', got '%s'", err.Error()) - } - } -} - -func (tp *provider) TestRemoveSelf(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - return - } - - _, err = api.Key().Remove(ctx, "self") - if err == nil { - t.Error("expected error to not be nil") - } else { - if !strings.Contains(err.Error(), "cannot remove key with name 'self'") { - t.Fatalf("expected error 'cannot remove key with name 'self'', got '%s'", err.Error()) - } - } -} - -func (tp *provider) TestGenerate(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - k, err := api.Key().Generate(ctx, "foo") - if err != nil { - t.Fatal(err) - return - } - - if k.Name() != "foo" { - t.Errorf("expected the key to be called 'foo', got '%s'", k.Name()) - } - - if !strings.HasPrefix(k.Path().String(), "/ipns/Qm") { - t.Errorf("expected the key to be prefixed with '/ipns/Qm', got '%s'", k.Path().String()) - } -} - -func (tp *provider) TestGenerateSize(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - k, err := api.Key().Generate(ctx, "foo", opt.Key.Size(1024)) - if err != nil { - t.Fatal(err) - return - } - - if k.Name() != "foo" { - t.Errorf("expected the key to be called 'foo', got '%s'", k.Name()) - } - - if !strings.HasPrefix(k.Path().String(), "/ipns/Qm") { - t.Errorf("expected the key to be prefixed with '/ipns/Qm', got '%s'", k.Path().String()) - } -} - -func (tp *provider) TestGenerateType(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - t.Skip("disabled until libp2p/specs#111 is fixed") - - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - k, err := api.Key().Generate(ctx, "bar", opt.Key.Type(opt.Ed25519Key)) - if err != nil { - t.Fatal(err) - return - } - - if k.Name() != "bar" { - t.Errorf("expected the key to be called 'foo', got '%s'", k.Name()) - } - - // Expected to be an inlined identity hash. - if !strings.HasPrefix(k.Path().String(), "/ipns/12") { - t.Errorf("expected the key to be prefixed with '/ipns/12', got '%s'", k.Path().String()) - } -} - -func (tp *provider) TestGenerateExisting(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - _, err = api.Key().Generate(ctx, "foo") - if err != nil { - t.Fatal(err) - return - } - - _, err = api.Key().Generate(ctx, "foo") - if err == nil { - t.Error("expected error to not be nil") - } else { - if !strings.Contains(err.Error(), "key with name 'foo' already exists") { - t.Fatalf("expected error 'key with name 'foo' already exists', got '%s'", err.Error()) - } - } - - _, err = api.Key().Generate(ctx, "self") - if err == nil { - t.Error("expected error to not be nil") - } else { - if !strings.Contains(err.Error(), "cannot create key with name 'self'") { - t.Fatalf("expected error 'cannot create key with name 'self'', got '%s'", err.Error()) - } - } -} - -func (tp *provider) TestList(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - _, err = api.Key().Generate(ctx, "foo") - if err != nil { - t.Fatal(err) - return - } - - l, err := api.Key().List(ctx) - if err != nil { - t.Fatal(err) - return - } - - if len(l) != 2 { - t.Fatalf("expected to get 2 keys, got %d", len(l)) - return - } - - if l[0].Name() != "self" { - t.Fatalf("expected key 0 to be called 'self', got '%s'", l[0].Name()) - return - } - - if l[1].Name() != "foo" { - t.Fatalf("expected key 1 to be called 'foo', got '%s'", l[1].Name()) - return - } - - if !strings.HasPrefix(l[0].Path().String(), "/ipns/Qm") { - t.Fatalf("expected key 0 to be prefixed with '/ipns/Qm', got '%s'", l[0].Name()) - return - } - - if !strings.HasPrefix(l[1].Path().String(), "/ipns/Qm") { - t.Fatalf("expected key 1 to be prefixed with '/ipns/Qm', got '%s'", l[1].Name()) - return - } -} - -func (tp *provider) TestRename(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - _, err = api.Key().Generate(ctx, "foo") - if err != nil { - t.Fatal(err) - return - } - - k, overwrote, err := api.Key().Rename(ctx, "foo", "bar") - if err != nil { - t.Fatal(err) - return - } - - if overwrote { - t.Error("overwrote should be false") - } - - if k.Name() != "bar" { - t.Errorf("returned key should be called 'bar', got '%s'", k.Name()) - } -} - -func (tp *provider) TestRenameToSelf(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - _, err = api.Key().Generate(ctx, "foo") - if err != nil { - t.Fatal(err) - return - } - - _, _, err = api.Key().Rename(ctx, "foo", "self") - if err == nil { - t.Error("expected error to not be nil") - } else { - if !strings.Contains(err.Error(), "cannot overwrite key with name 'self'") { - t.Fatalf("expected error 'cannot overwrite key with name 'self'', got '%s'", err.Error()) - } - } -} - -func (tp *provider) TestRenameToSelfForce(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - _, err = api.Key().Generate(ctx, "foo") - if err != nil { - t.Fatal(err) - return - } - - _, _, err = api.Key().Rename(ctx, "foo", "self", opt.Key.Force(true)) - if err == nil { - t.Error("expected error to not be nil") - } else { - if !strings.Contains(err.Error(), "cannot overwrite key with name 'self'") { - t.Fatalf("expected error 'cannot overwrite key with name 'self'', got '%s'", err.Error()) - } - } -} - -func (tp *provider) TestRenameOverwriteNoForce(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - _, err = api.Key().Generate(ctx, "foo") - if err != nil { - t.Fatal(err) - return - } - - _, err = api.Key().Generate(ctx, "bar") - if err != nil { - t.Fatal(err) - return - } - - _, _, err = api.Key().Rename(ctx, "foo", "bar") - if err == nil { - t.Error("expected error to not be nil") - } else { - if !strings.Contains(err.Error(), "key by that name already exists, refusing to overwrite") { - t.Fatalf("expected error 'key by that name already exists, refusing to overwrite', got '%s'", err.Error()) - } - } -} - -func (tp *provider) TestRenameOverwrite(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - kfoo, err := api.Key().Generate(ctx, "foo") - if err != nil { - t.Fatal(err) - return - } - - _, err = api.Key().Generate(ctx, "bar") - if err != nil { - t.Fatal(err) - return - } - - k, overwrote, err := api.Key().Rename(ctx, "foo", "bar", opt.Key.Force(true)) - if err != nil { - t.Fatal(err) - return - } - - if !overwrote { - t.Error("overwrote should be true") - } - - if k.Name() != "bar" { - t.Errorf("returned key should be called 'bar', got '%s'", k.Name()) - } - - if k.Path().String() != kfoo.Path().String() { - t.Errorf("k and kfoo should have equal paths, '%s'!='%s'", k.Path().String(), kfoo.Path().String()) - } -} - -func (tp *provider) TestRenameSameNameNoForce(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - _, err = api.Key().Generate(ctx, "foo") - if err != nil { - t.Fatal(err) - return - } - - k, overwrote, err := api.Key().Rename(ctx, "foo", "foo") - if err != nil { - t.Fatal(err) - return - } - - if overwrote { - t.Error("overwrote should be false") - } - - if k.Name() != "foo" { - t.Errorf("returned key should be called 'foo', got '%s'", k.Name()) - } -} - -func (tp *provider) TestRenameSameName(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - _, err = api.Key().Generate(ctx, "foo") - if err != nil { - t.Fatal(err) - return - } - - k, overwrote, err := api.Key().Rename(ctx, "foo", "foo", opt.Key.Force(true)) - if err != nil { - t.Fatal(err) - return - } - - if overwrote { - t.Error("overwrote should be false") - } - - if k.Name() != "foo" { - t.Errorf("returned key should be called 'foo', got '%s'", k.Name()) - } -} - -func (tp *provider) TestRemove(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - k, err := api.Key().Generate(ctx, "foo") - if err != nil { - t.Fatal(err) - return - } - - l, err := api.Key().List(ctx) - if err != nil { - t.Fatal(err) - return - } - - if len(l) != 2 { - t.Fatalf("expected to get 2 keys, got %d", len(l)) - return - } - - p, err := api.Key().Remove(ctx, "foo") - if err != nil { - t.Fatal(err) - return - } - - if k.Path().String() != p.Path().String() { - t.Errorf("k and p should have equal paths, '%s'!='%s'", k.Path().String(), p.Path().String()) - } - - l, err = api.Key().List(ctx) - if err != nil { - t.Fatal(err) - return - } - - if len(l) != 1 { - t.Fatalf("expected to get 1 key, got %d", len(l)) - return - } - - if l[0].Name() != "self" { - t.Errorf("expected the key to be called 'self', got '%s'", l[0].Name()) - } -} diff --git a/core/coreapi/interface/tests/name.go b/core/coreapi/interface/tests/name.go deleted file mode 100644 index 8d87bd495d2..00000000000 --- a/core/coreapi/interface/tests/name.go +++ /dev/null @@ -1,278 +0,0 @@ -package tests - -import ( - "context" - "io" - "math/rand" - "path" - "testing" - "time" - - ipath "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" - "gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files" - - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - opt "github.com/ipfs/go-ipfs/core/coreapi/interface/options" -) - -func (tp *provider) TestName(t *testing.T) { - tp.hasApi(t, func(api coreiface.CoreAPI) error { - if api.Name() == nil { - return apiNotImplemented - } - return nil - }) - - t.Run("TestPublishResolve", tp.TestPublishResolve) - t.Run("TestBasicPublishResolveKey", tp.TestBasicPublishResolveKey) - t.Run("TestBasicPublishResolveTimeout", tp.TestBasicPublishResolveTimeout) -} - -var rnd = rand.New(rand.NewSource(0x62796532303137)) - -func addTestObject(ctx context.Context, api coreiface.CoreAPI) (coreiface.Path, error) { - return api.Unixfs().Add(ctx, files.NewReaderFile(&io.LimitedReader{R: rnd, N: 4092})) -} - -func appendPath(p coreiface.Path, sub string) coreiface.Path { - p, err := coreiface.ParsePath(path.Join(p.String(), sub)) - if err != nil { - panic(err) - } - return p -} - -func (tp *provider) TestPublishResolve(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - init := func() (coreiface.CoreAPI, coreiface.Path) { - apis, err := tp.MakeAPISwarm(ctx, true, 5) - if err != nil { - t.Fatal(err) - return nil, nil - } - api := apis[0] - - p, err := addTestObject(ctx, api) - if err != nil { - t.Fatal(err) - return nil, nil - } - return api, p - } - - run := func(t *testing.T, ropts []opt.NameResolveOption) { - t.Run("basic", func(t *testing.T) { - api, p := init() - e, err := api.Name().Publish(ctx, p) - if err != nil { - t.Fatal(err) - } - - self, err := api.Key().Self(ctx) - if err != nil { - t.Fatal(err) - } - - if e.Name() != self.ID().Pretty() { - t.Errorf("expected e.Name to equal '%s', got '%s'", self.ID().Pretty(), e.Name()) - } - - if e.Value().String() != p.String() { - t.Errorf("expected paths to match, '%s'!='%s'", e.Value().String(), p.String()) - } - - resPath, err := api.Name().Resolve(ctx, e.Name(), ropts...) - if err != nil { - t.Fatal(err) - } - - if resPath.String() != p.String() { - t.Errorf("expected paths to match, '%s'!='%s'", resPath.String(), p.String()) - } - }) - - t.Run("publishPath", func(t *testing.T) { - api, p := init() - e, err := api.Name().Publish(ctx, appendPath(p, "/test")) - if err != nil { - t.Fatal(err) - } - - self, err := api.Key().Self(ctx) - if err != nil { - t.Fatal(err) - } - - if e.Name() != self.ID().Pretty() { - t.Errorf("expected e.Name to equal '%s', got '%s'", self.ID().Pretty(), e.Name()) - } - - if e.Value().String() != p.String()+"/test" { - t.Errorf("expected paths to match, '%s'!='%s'", e.Value().String(), p.String()) - } - - resPath, err := api.Name().Resolve(ctx, e.Name(), ropts...) - if err != nil { - t.Fatal(err) - } - - if resPath.String() != p.String()+"/test" { - t.Errorf("expected paths to match, '%s'!='%s'", resPath.String(), p.String()+"/test") - } - }) - - t.Run("revolvePath", func(t *testing.T) { - api, p := init() - e, err := api.Name().Publish(ctx, p) - if err != nil { - t.Fatal(err) - } - - self, err := api.Key().Self(ctx) - if err != nil { - t.Fatal(err) - } - - if e.Name() != self.ID().Pretty() { - t.Errorf("expected e.Name to equal '%s', got '%s'", self.ID().Pretty(), e.Name()) - } - - if e.Value().String() != p.String() { - t.Errorf("expected paths to match, '%s'!='%s'", e.Value().String(), p.String()) - } - - resPath, err := api.Name().Resolve(ctx, e.Name()+"/test", ropts...) - if err != nil { - t.Fatal(err) - } - - if resPath.String() != p.String()+"/test" { - t.Errorf("expected paths to match, '%s'!='%s'", resPath.String(), p.String()+"/test") - } - }) - - t.Run("publishRevolvePath", func(t *testing.T) { - api, p := init() - e, err := api.Name().Publish(ctx, appendPath(p, "/a")) - if err != nil { - t.Fatal(err) - } - - self, err := api.Key().Self(ctx) - if err != nil { - t.Fatal(err) - } - - if e.Name() != self.ID().Pretty() { - t.Errorf("expected e.Name to equal '%s', got '%s'", self.ID().Pretty(), e.Name()) - } - - if e.Value().String() != p.String()+"/a" { - t.Errorf("expected paths to match, '%s'!='%s'", e.Value().String(), p.String()) - } - - resPath, err := api.Name().Resolve(ctx, e.Name()+"/b", ropts...) - if err != nil { - t.Fatal(err) - } - - if resPath.String() != p.String()+"/a/b" { - t.Errorf("expected paths to match, '%s'!='%s'", resPath.String(), p.String()+"/a/b") - } - }) - } - - t.Run("default", func(t *testing.T) { - run(t, []opt.NameResolveOption{}) - }) - - t.Run("nocache", func(t *testing.T) { - run(t, []opt.NameResolveOption{opt.Name.Cache(false)}) - }) -} - -func (tp *provider) TestBasicPublishResolveKey(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - apis, err := tp.MakeAPISwarm(ctx, true, 5) - if err != nil { - t.Fatal(err) - } - api := apis[0] - - k, err := api.Key().Generate(ctx, "foo") - if err != nil { - t.Fatal(err) - } - - p, err := addTestObject(ctx, api) - if err != nil { - t.Fatal(err) - } - - e, err := api.Name().Publish(ctx, p, opt.Name.Key(k.Name())) - if err != nil { - t.Fatal(err) - } - - if ipath.Join([]string{"/ipns", e.Name()}) != k.Path().String() { - t.Errorf("expected e.Name to equal '%s', got '%s'", e.Name(), k.Path().String()) - } - - if e.Value().String() != p.String() { - t.Errorf("expected paths to match, '%s'!='%s'", e.Value().String(), p.String()) - } - - resPath, err := api.Name().Resolve(ctx, e.Name()) - if err != nil { - t.Fatal(err) - } - - if resPath.String() != p.String() { - t.Errorf("expected paths to match, '%s'!='%s'", resPath.String(), p.String()) - } -} - -func (tp *provider) TestBasicPublishResolveTimeout(t *testing.T) { - t.Skip("ValidTime doesn't appear to work at this time resolution") - - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - apis, err := tp.MakeAPISwarm(ctx, true, 5) - if err != nil { - t.Fatal(err) - } - api := apis[0] - p, err := addTestObject(ctx, api) - if err != nil { - t.Fatal(err) - } - - e, err := api.Name().Publish(ctx, p, opt.Name.ValidTime(time.Millisecond*100)) - if err != nil { - t.Fatal(err) - } - - self, err := api.Key().Self(ctx) - if err != nil { - t.Fatal(err) - } - - if e.Name() != self.ID().Pretty() { - t.Errorf("expected e.Name to equal '%s', got '%s'", self.ID().Pretty(), e.Name()) - } - - if e.Value().String() != p.String() { - t.Errorf("expected paths to match, '%s'!='%s'", e.Value().String(), p.String()) - } - - time.Sleep(time.Second) - - _, err = api.Name().Resolve(ctx, e.Name()) - if err == nil { - t.Fatal("Expected an error") - } -} - -//TODO: When swarm api is created, add multinode tests diff --git a/core/coreapi/interface/tests/object.go b/core/coreapi/interface/tests/object.go deleted file mode 100644 index 2a3b1bd5ca6..00000000000 --- a/core/coreapi/interface/tests/object.go +++ /dev/null @@ -1,461 +0,0 @@ -package tests - -import ( - "bytes" - "context" - "encoding/hex" - "io/ioutil" - "strings" - "testing" - - "github.com/ipfs/go-ipfs/core/coreapi/interface" - opt "github.com/ipfs/go-ipfs/core/coreapi/interface/options" -) - -func (tp *provider) TestObject(t *testing.T) { - tp.hasApi(t, func(api iface.CoreAPI) error { - if api.Object() == nil { - return apiNotImplemented - } - return nil - }) - - t.Run("TestNew", tp.TestNew) - t.Run("TestObjectPut", tp.TestObjectPut) - t.Run("TestObjectGet", tp.TestObjectGet) - t.Run("TestObjectData", tp.TestObjectData) - t.Run("TestObjectLinks", tp.TestObjectLinks) - t.Run("TestObjectStat", tp.TestObjectStat) - t.Run("TestObjectAddLink", tp.TestObjectAddLink) - t.Run("TestObjectAddLinkCreate", tp.TestObjectAddLinkCreate) - t.Run("TestObjectRmLink", tp.TestObjectRmLink) - t.Run("TestObjectAddData", tp.TestObjectAddData) - t.Run("TestObjectSetData", tp.TestObjectSetData) - t.Run("TestDiffTest", tp.TestDiffTest) -} - -func (tp *provider) TestNew(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - } - - emptyNode, err := api.Object().New(ctx) - if err != nil { - t.Fatal(err) - } - - dirNode, err := api.Object().New(ctx, opt.Object.Type("unixfs-dir")) - if err != nil { - t.Fatal(err) - } - - if emptyNode.String() != "QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n" { - t.Errorf("Unexpected emptyNode path: %s", emptyNode.String()) - } - - if dirNode.String() != "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn" { - t.Errorf("Unexpected dirNode path: %s", dirNode.String()) - } -} - -func (tp *provider) TestObjectPut(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } - - p2, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"YmFy"}`), opt.Object.DataType("base64")) //bar - if err != nil { - t.Fatal(err) - } - - pbBytes, err := hex.DecodeString("0a0362617a") - if err != nil { - t.Fatal(err) - } - - p3, err := api.Object().Put(ctx, bytes.NewReader(pbBytes), opt.Object.InputEnc("protobuf")) - if err != nil { - t.Fatal(err) - } - - if p1.String() != "/ipfs/QmQeGyS87nyijii7kFt1zbe4n2PsXTFimzsdxyE9qh9TST" { - t.Errorf("unexpected path: %s", p1.String()) - } - - if p2.String() != "/ipfs/QmNeYRbCibmaMMK6Du6ChfServcLqFvLJF76PzzF76SPrZ" { - t.Errorf("unexpected path: %s", p2.String()) - } - - if p3.String() != "/ipfs/QmZreR7M2t7bFXAdb1V5FtQhjk4t36GnrvueLJowJbQM9m" { - t.Errorf("unexpected path: %s", p3.String()) - } -} - -func (tp *provider) TestObjectGet(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } - - nd, err := api.Object().Get(ctx, p1) - if err != nil { - t.Fatal(err) - } - - if string(nd.RawData()[len(nd.RawData())-3:]) != "foo" { - t.Fatal("got non-matching data") - } -} - -func (tp *provider) TestObjectData(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } - - r, err := api.Object().Data(ctx, p1) - if err != nil { - t.Fatal(err) - } - - data, err := ioutil.ReadAll(r) - if err != nil { - t.Fatal(err) - } - - if string(data) != "foo" { - t.Fatal("got non-matching data") - } -} - -func (tp *provider) TestObjectLinks(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } - - p2, err := api.Object().Put(ctx, strings.NewReader(`{"Links":[{"Name":"bar", "Hash":"`+p1.Cid().String()+`"}]}`)) - if err != nil { - t.Fatal(err) - } - - links, err := api.Object().Links(ctx, p2) - if err != nil { - t.Fatal(err) - } - - if len(links) != 1 { - t.Errorf("unexpected number of links: %d", len(links)) - } - - if links[0].Cid.String() != p1.Cid().String() { - t.Fatal("cids didn't batch") - } - - if links[0].Name != "bar" { - t.Fatal("unexpected link name") - } -} - -func (tp *provider) TestObjectStat(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } - - p2, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"bazz", "Links":[{"Name":"bar", "Hash":"`+p1.Cid().String()+`", "Size":3}]}`)) - if err != nil { - t.Fatal(err) - } - - stat, err := api.Object().Stat(ctx, p2) - if err != nil { - t.Fatal(err) - } - - if stat.Cid.String() != p2.Cid().String() { - t.Error("unexpected stat.Cid") - } - - if stat.NumLinks != 1 { - t.Errorf("unexpected stat.NumLinks") - } - - if stat.BlockSize != 51 { - t.Error("unexpected stat.BlockSize") - } - - if stat.LinksSize != 47 { - t.Errorf("unexpected stat.LinksSize: %d", stat.LinksSize) - } - - if stat.DataSize != 4 { - t.Error("unexpected stat.DataSize") - } - - if stat.CumulativeSize != 54 { - t.Error("unexpected stat.DataSize") - } -} - -func (tp *provider) TestObjectAddLink(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } - - p2, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"bazz", "Links":[{"Name":"bar", "Hash":"`+p1.Cid().String()+`", "Size":3}]}`)) - if err != nil { - t.Fatal(err) - } - - p3, err := api.Object().AddLink(ctx, p2, "abc", p2) - if err != nil { - t.Fatal(err) - } - - links, err := api.Object().Links(ctx, p3) - if err != nil { - t.Fatal(err) - } - - if len(links) != 2 { - t.Errorf("unexpected number of links: %d", len(links)) - } - - if links[0].Name != "abc" { - t.Errorf("unexpected link 0 name: %s", links[0].Name) - } - - if links[1].Name != "bar" { - t.Errorf("unexpected link 1 name: %s", links[1].Name) - } -} - -func (tp *provider) TestObjectAddLinkCreate(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } - - p2, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"bazz", "Links":[{"Name":"bar", "Hash":"`+p1.Cid().String()+`", "Size":3}]}`)) - if err != nil { - t.Fatal(err) - } - - p3, err := api.Object().AddLink(ctx, p2, "abc/d", p2) - if err == nil { - t.Fatal("expected an error") - } - if !strings.Contains(err.Error(), "no link by that name") { - t.Fatalf("unexpected error: %s", err.Error()) - } - - p3, err = api.Object().AddLink(ctx, p2, "abc/d", p2, opt.Object.Create(true)) - if err != nil { - t.Fatal(err) - } - - links, err := api.Object().Links(ctx, p3) - if err != nil { - t.Fatal(err) - } - - if len(links) != 2 { - t.Errorf("unexpected number of links: %d", len(links)) - } - - if links[0].Name != "abc" { - t.Errorf("unexpected link 0 name: %s", links[0].Name) - } - - if links[1].Name != "bar" { - t.Errorf("unexpected link 1 name: %s", links[1].Name) - } -} - -func (tp *provider) TestObjectRmLink(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } - - p2, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"bazz", "Links":[{"Name":"bar", "Hash":"`+p1.Cid().String()+`", "Size":3}]}`)) - if err != nil { - t.Fatal(err) - } - - p3, err := api.Object().RmLink(ctx, p2, "bar") - if err != nil { - t.Fatal(err) - } - - links, err := api.Object().Links(ctx, p3) - if err != nil { - t.Fatal(err) - } - - if len(links) != 0 { - t.Errorf("unexpected number of links: %d", len(links)) - } -} - -func (tp *provider) TestObjectAddData(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } - - p2, err := api.Object().AppendData(ctx, p1, strings.NewReader("bar")) - if err != nil { - t.Fatal(err) - } - - r, err := api.Object().Data(ctx, p2) - if err != nil { - t.Fatal(err) - } - - data, err := ioutil.ReadAll(r) - - if string(data) != "foobar" { - t.Error("unexpected data") - } -} - -func (tp *provider) TestObjectSetData(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } - - p2, err := api.Object().SetData(ctx, p1, strings.NewReader("bar")) - if err != nil { - t.Fatal(err) - } - - r, err := api.Object().Data(ctx, p2) - if err != nil { - t.Fatal(err) - } - - data, err := ioutil.ReadAll(r) - - if string(data) != "bar" { - t.Error("unexpected data") - } -} - -func (tp *provider) TestDiffTest(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } - - p2, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"bar"}`)) - if err != nil { - t.Fatal(err) - } - - changes, err := api.Object().Diff(ctx, p1, p2) - if err != nil { - t.Fatal(err) - } - - if len(changes) != 1 { - t.Fatal("unexpected changes len") - } - - if changes[0].Type != iface.DiffMod { - t.Fatal("unexpected change type") - } - - if changes[0].Before.String() != p1.String() { - t.Fatal("unexpected before path") - } - - if changes[0].After.String() != p2.String() { - t.Fatal("unexpected before path") - } -} diff --git a/core/coreapi/interface/tests/path.go b/core/coreapi/interface/tests/path.go deleted file mode 100644 index 5594cf0da51..00000000000 --- a/core/coreapi/interface/tests/path.go +++ /dev/null @@ -1,219 +0,0 @@ -package tests - -import ( - "context" - "math" - "strings" - "testing" - - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - - ipldcbor "gx/ipfs/QmRZxJ7oybgnnwriuRub9JXp5YdFM9wiGSyRq38QC7swpS/go-ipld-cbor" -) - -func (tp *provider) TestPath(t *testing.T) { - t.Run("TestMutablePath", tp.TestMutablePath) - t.Run("TestPathRemainder", tp.TestPathRemainder) - t.Run("TestEmptyPathRemainder", tp.TestEmptyPathRemainder) - t.Run("TestInvalidPathRemainder", tp.TestInvalidPathRemainder) - t.Run("TestPathRoot", tp.TestPathRoot) - t.Run("TestPathJoin", tp.TestPathJoin) -} - -func (tp *provider) TestMutablePath(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - } - - blk, err := api.Block().Put(ctx, strings.NewReader(`foo`)) - if err != nil { - t.Fatal(err) - } - - if blk.Path().Mutable() { - t.Error("expected /ipld path to be immutable") - } - - // get self /ipns path ipldcbor "gx/ipfs/QmRZxJ7oybgnnwriuRub9JXp5YdFM9wiGSyRq38QC7swpS/go-ipld-cbor" - - if api.Key() == nil { - t.Fatal(".Key not implemented") - } - - keys, err := api.Key().List(ctx) - if err != nil { - t.Fatal(err) - } - - if !keys[0].Path().Mutable() { - t.Error("expected self /ipns path to be mutable") - } -} - -func (tp *provider) TestPathRemainder(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - } - - if api.Dag() == nil { - t.Fatal(".Dag not implemented") - } - - nd, err := ipldcbor.FromJSON(strings.NewReader(`{"foo": {"bar": "baz"}}`), math.MaxUint64, -1) - if err != nil { - t.Error(err) - } - - if err := api.Dag().Add(ctx, nd); err != nil { - t.Fatal(err) - } - - p1, err := coreiface.ParsePath(nd.String() + "/foo/bar") - if err != nil { - t.Error(err) - } - - rp1, err := api.ResolvePath(ctx, p1) - if err != nil { - t.Fatal(err) - } - - if rp1.Remainder() != "foo/bar" { - t.Error("expected to get path remainder") - } -} - -func (tp *provider) TestEmptyPathRemainder(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - } - - if api.Dag() == nil { - t.Fatal(".Dag not implemented") - } - - nd, err := ipldcbor.FromJSON(strings.NewReader(`{"foo": {"bar": "baz"}}`), math.MaxUint64, -1) - if err != nil { - t.Error(err) - } - - if err := api.Dag().Add(ctx, nd); err != nil { - t.Fatal(err) - } - - p1, err := coreiface.ParsePath(nd.Cid().String()) - if err != nil { - t.Error(err) - } - - rp1, err := api.ResolvePath(ctx, p1) - if err != nil { - t.Fatal(err) - } - - if rp1.Remainder() != "" { - t.Error("expected the resolved path to not have a remainder") - } -} - -func (tp *provider) TestInvalidPathRemainder(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - } - - if api.Dag() == nil { - t.Fatal(".Dag not implemented") - } - - nd, err := ipldcbor.FromJSON(strings.NewReader(`{"foo": {"bar": "baz"}}`), math.MaxUint64, -1) - if err != nil { - t.Error(err) - } - - if err := api.Dag().Add(ctx, nd); err != nil { - t.Fatal(err) - } - - p1, err := coreiface.ParsePath("/ipld/" + nd.Cid().String() + "/bar/baz") - if err != nil { - t.Error(err) - } - - _, err = api.ResolvePath(ctx, p1) - if err == nil || !strings.Contains(err.Error(), "no such link found") { - t.Fatalf("unexpected error: %s", err) - } -} - -func (tp *provider) TestPathRoot(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - } - - if api.Block() == nil { - t.Fatal(".Block not implemented") - } - - blk, err := api.Block().Put(ctx, strings.NewReader(`foo`), options.Block.Format("raw")) - if err != nil { - t.Fatal(err) - } - - if api.Dag() == nil { - t.Fatal(".Dag not implemented") - } - - nd, err := ipldcbor.FromJSON(strings.NewReader(`{"foo": {"/": "`+blk.Path().Cid().String()+`"}}`), math.MaxUint64, -1) - if err != nil { - t.Error(err) - } - - if err := api.Dag().Add(ctx, nd); err != nil { - t.Fatal(err) - } - - p1, err := coreiface.ParsePath("/ipld/" + nd.Cid().String() + "/foo") - if err != nil { - t.Error(err) - } - - rp, err := api.ResolvePath(ctx, p1) - if err != nil { - t.Fatal(err) - } - - if rp.Root().String() != nd.Cid().String() { - t.Error("unexpected path root") - } - - if rp.Cid().String() != blk.Path().Cid().String() { - t.Error("unexpected path cid") - } -} - -func (tp *provider) TestPathJoin(t *testing.T) { - p1, err := coreiface.ParsePath("/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz") - if err != nil { - t.Error(err) - } - - if coreiface.Join(p1, "foo").String() != "/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz/foo" { - t.Error("unexpected path") - } -} diff --git a/core/coreapi/interface/tests/pin.go b/core/coreapi/interface/tests/pin.go deleted file mode 100644 index 35c9136187c..00000000000 --- a/core/coreapi/interface/tests/pin.go +++ /dev/null @@ -1,239 +0,0 @@ -package tests - -import ( - "context" - "math" - "strings" - "testing" - - "github.com/ipfs/go-ipfs/core/coreapi/interface" - opt "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - - ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" - ipldcbor "gx/ipfs/QmRZxJ7oybgnnwriuRub9JXp5YdFM9wiGSyRq38QC7swpS/go-ipld-cbor" -) - -func (tp *provider) TestPin(t *testing.T) { - tp.hasApi(t, func(api iface.CoreAPI) error { - if api.Pin() == nil { - return apiNotImplemented - } - return nil - }) - - t.Run("TestPinAdd", tp.TestPinAdd) - t.Run("TestPinSimple", tp.TestPinSimple) - t.Run("TestPinRecursive", tp.TestPinRecursive) -} - -func (tp *provider) TestPinAdd(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - p, err := api.Unixfs().Add(ctx, strFile("foo")()) - if err != nil { - t.Error(err) - } - - err = api.Pin().Add(ctx, p) - if err != nil { - t.Error(err) - } -} - -func (tp *provider) TestPinSimple(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - p, err := api.Unixfs().Add(ctx, strFile("foo")()) - if err != nil { - t.Error(err) - } - - err = api.Pin().Add(ctx, p) - if err != nil { - t.Error(err) - } - - list, err := api.Pin().Ls(ctx) - if err != nil { - t.Fatal(err) - } - - if len(list) != 1 { - t.Errorf("unexpected pin list len: %d", len(list)) - } - - if list[0].Path().Cid().String() != p.Cid().String() { - t.Error("paths don't match") - } - - if list[0].Type() != "recursive" { - t.Error("unexpected pin type") - } - - err = api.Pin().Rm(ctx, p) - if err != nil { - t.Fatal(err) - } - - list, err = api.Pin().Ls(ctx) - if err != nil { - t.Fatal(err) - } - - if len(list) != 0 { - t.Errorf("unexpected pin list len: %d", len(list)) - } -} - -func (tp *provider) TestPinRecursive(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - p0, err := api.Unixfs().Add(ctx, strFile("foo")()) - if err != nil { - t.Error(err) - } - - p1, err := api.Unixfs().Add(ctx, strFile("bar")()) - if err != nil { - t.Error(err) - } - - nd2, err := ipldcbor.FromJSON(strings.NewReader(`{"lnk": {"/": "`+p0.Cid().String()+`"}}`), math.MaxUint64, -1) - if err != nil { - t.Error(err) - } - - nd3, err := ipldcbor.FromJSON(strings.NewReader(`{"lnk": {"/": "`+p1.Cid().String()+`"}}`), math.MaxUint64, -1) - if err != nil { - t.Error(err) - } - - if err := api.Dag().AddMany(ctx, []ipld.Node{nd2, nd3}); err != nil { - t.Fatal(err) - } - - err = api.Pin().Add(ctx, iface.IpldPath(nd2.Cid())) - if err != nil { - t.Error(err) - } - - err = api.Pin().Add(ctx, iface.IpldPath(nd3.Cid()), opt.Pin.Recursive(false)) - if err != nil { - t.Error(err) - } - - list, err := api.Pin().Ls(ctx) - if err != nil { - t.Fatal(err) - } - - if len(list) != 3 { - t.Errorf("unexpected pin list len: %d", len(list)) - } - - list, err = api.Pin().Ls(ctx, opt.Pin.Type.Direct()) - if err != nil { - t.Fatal(err) - } - - if len(list) != 1 { - t.Errorf("unexpected pin list len: %d", len(list)) - } - - if list[0].Path().String() != iface.IpldPath(nd3.Cid()).String() { - t.Errorf("unexpected path, %s != %s", list[0].Path().String(), iface.IpfsPath(nd2.Cid()).String()) - } - - list, err = api.Pin().Ls(ctx, opt.Pin.Type.Recursive()) - if err != nil { - t.Fatal(err) - } - - if len(list) != 1 { - t.Errorf("unexpected pin list len: %d", len(list)) - } - - if list[0].Path().String() != iface.IpldPath(nd2.Cid()).String() { - t.Errorf("unexpected path, %s != %s", list[0].Path().String(), iface.IpldPath(nd3.Cid()).String()) - } - - list, err = api.Pin().Ls(ctx, opt.Pin.Type.Indirect()) - if err != nil { - t.Fatal(err) - } - - if len(list) != 1 { - t.Errorf("unexpected pin list len: %d", len(list)) - } - - if list[0].Path().Cid().String() != p0.Cid().String() { - t.Error("unexpected path") - } - - res, err := api.Pin().Verify(ctx) - if err != nil { - t.Fatal(err) - } - n := 0 - for r := range res { - if !r.Ok() { - t.Error("expected pin to be ok") - } - n++ - } - - if n != 1 { - t.Errorf("unexpected verify result count: %d", n) - } - - //TODO: figure out a way to test verify without touching IpfsNode - /* - err = api.Block().Rm(ctx, p0, opt.Block.Force(true)) - if err != nil { - t.Fatal(err) - } - - res, err = api.Pin().Verify(ctx) - if err != nil { - t.Fatal(err) - } - n = 0 - for r := range res { - if r.Ok() { - t.Error("expected pin to not be ok") - } - - if len(r.BadNodes()) != 1 { - t.Fatalf("unexpected badNodes len") - } - - if r.BadNodes()[0].Path().Cid().String() != p0.Cid().String() { - t.Error("unexpected badNode path") - } - - if r.BadNodes()[0].Err().Error() != "merkledag: not found" { - t.Errorf("unexpected badNode error: %s", r.BadNodes()[0].Err().Error()) - } - n++ - } - - if n != 1 { - t.Errorf("unexpected verify result count: %d", n) - } - */ -} diff --git a/core/coreapi/interface/tests/pubsub.go b/core/coreapi/interface/tests/pubsub.go deleted file mode 100644 index b993f51dc55..00000000000 --- a/core/coreapi/interface/tests/pubsub.go +++ /dev/null @@ -1,118 +0,0 @@ -package tests - -import ( - "context" - "github.com/ipfs/go-ipfs/core/coreapi/interface" - "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - "testing" - "time" -) - -func (tp *provider) TestPubSub(t *testing.T) { - tp.hasApi(t, func(api iface.CoreAPI) error { - if api.PubSub() == nil { - return apiNotImplemented - } - return nil - }) - - t.Run("TestBasicPubSub", tp.TestBasicPubSub) -} - -func (tp *provider) TestBasicPubSub(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - apis, err := tp.MakeAPISwarm(ctx, true, 2) - if err != nil { - t.Fatal(err) - } - - sub, err := apis[0].PubSub().Subscribe(ctx, "testch") - if err != nil { - t.Fatal(err) - } - - go func() { - tick := time.Tick(100 * time.Millisecond) - - for { - err = apis[1].PubSub().Publish(ctx, "testch", []byte("hello world")) - if err != nil { - t.Fatal(err) - } - select { - case <-tick: - case <-ctx.Done(): - return - } - } - }() - - m, err := sub.Next(ctx) - if err != nil { - t.Fatal(err) - } - - if string(m.Data()) != "hello world" { - t.Errorf("got invalid data: %s", string(m.Data())) - } - - self1, err := apis[1].Key().Self(ctx) - if err != nil { - t.Fatal(err) - } - - if m.From() != self1.ID() { - t.Errorf("m.From didn't match") - } - - peers, err := apis[1].PubSub().Peers(ctx, options.PubSub.Topic("testch")) - if err != nil { - t.Fatal(err) - } - - if len(peers) != 1 { - t.Fatalf("got incorrect number of peers: %d", len(peers)) - } - - self0, err := apis[0].Key().Self(ctx) - if err != nil { - t.Fatal(err) - } - - if peers[0] != self0.ID() { - t.Errorf("peer didn't match") - } - - peers, err = apis[1].PubSub().Peers(ctx, options.PubSub.Topic("nottestch")) - if err != nil { - t.Fatal(err) - } - - if len(peers) != 0 { - t.Fatalf("got incorrect number of peers: %d", len(peers)) - } - - topics, err := apis[0].PubSub().Ls(ctx) - if err != nil { - t.Fatal(err) - } - - if len(topics) != 1 { - t.Fatalf("got incorrect number of topics: %d", len(peers)) - } - - if topics[0] != "testch" { - t.Errorf("topic didn't match") - } - - topics, err = apis[1].PubSub().Ls(ctx) - if err != nil { - t.Fatal(err) - } - - if len(topics) != 0 { - t.Fatalf("got incorrect number of topics: %d", len(peers)) - } -} diff --git a/core/coreapi/interface/tests/unixfs.go b/core/coreapi/interface/tests/unixfs.go deleted file mode 100644 index f5ce85b78be..00000000000 --- a/core/coreapi/interface/tests/unixfs.go +++ /dev/null @@ -1,1055 +0,0 @@ -package tests - -import ( - "bytes" - "context" - "encoding/hex" - "fmt" - "io" - "io/ioutil" - "math" - "math/rand" - "os" - "strconv" - "strings" - "sync" - "testing" - - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - - "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" - cbor "gx/ipfs/QmRZxJ7oybgnnwriuRub9JXp5YdFM9wiGSyRq38QC7swpS/go-ipld-cbor" - mdag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" - "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs" - "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs/importer/helpers" - "gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files" - mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" -) - -func (tp *provider) TestUnixfs(t *testing.T) { - tp.hasApi(t, func(api coreiface.CoreAPI) error { - if api.Unixfs() == nil { - return apiNotImplemented - } - return nil - }) - - t.Run("TestAdd", tp.TestAdd) - t.Run("TestAddPinned", tp.TestAddPinned) - t.Run("TestAddHashOnly", tp.TestAddHashOnly) - t.Run("TestGetEmptyFile", tp.TestGetEmptyFile) - t.Run("TestGetDir", tp.TestGetDir) - t.Run("TestGetNonUnixfs", tp.TestGetNonUnixfs) - t.Run("TestLs", tp.TestLs) - t.Run("TestEntriesExpired", tp.TestEntriesExpired) - t.Run("TestLsEmptyDir", tp.TestLsEmptyDir) - t.Run("TestLsNonUnixfs", tp.TestLsNonUnixfs) - t.Run("TestAddCloses", tp.TestAddCloses) - t.Run("TestGetSeek", tp.TestGetSeek) -} - -// `echo -n 'hello, world!' | ipfs add` -var hello = "/ipfs/QmQy2Dw4Wk7rdJKjThjYXzfFJNaRKRHhHP5gHHXroJMYxk" -var helloStr = "hello, world!" - -// `echo -n | ipfs add` -var emptyFile = "/ipfs/QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH" - -func strFile(data string) func() files.Node { - return func() files.Node { - return files.NewBytesFile([]byte(data)) - } -} - -func twoLevelDir() func() files.Node { - return func() files.Node { - return files.NewMapDirectory(map[string]files.Node{ - "abc": files.NewMapDirectory(map[string]files.Node{ - "def": files.NewBytesFile([]byte("world")), - }), - - "bar": files.NewBytesFile([]byte("hello2")), - "foo": files.NewBytesFile([]byte("hello1")), - }) - } -} - -func flatDir() files.Node { - return files.NewMapDirectory(map[string]files.Node{ - "bar": files.NewBytesFile([]byte("hello2")), - "foo": files.NewBytesFile([]byte("hello1")), - }) -} - -func wrapped(name string) func(f files.Node) files.Node { - return func(f files.Node) files.Node { - return files.NewMapDirectory(map[string]files.Node{ - name: f, - }) - } -} - -func (tp *provider) TestAdd(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - p := func(h string) coreiface.ResolvedPath { - c, err := cid.Parse(h) - if err != nil { - t.Fatal(err) - } - return coreiface.IpfsPath(c) - } - - rf, err := ioutil.TempFile(os.TempDir(), "unixfs-add-real") - if err != nil { - t.Fatal(err) - } - rfp := rf.Name() - - if _, err := rf.Write([]byte(helloStr)); err != nil { - t.Fatal(err) - } - - stat, err := rf.Stat() - if err != nil { - t.Fatal(err) - } - - if err := rf.Close(); err != nil { - t.Fatal(err) - } - defer os.Remove(rfp) - - realFile := func() files.Node { - n, err := files.NewReaderPathFile(rfp, ioutil.NopCloser(strings.NewReader(helloStr)), stat) - if err != nil { - t.Fatal(err) - } - return n - } - - cases := []struct { - name string - data func() files.Node - expect func(files.Node) files.Node - - apiOpts []options.ApiOption - - path string - err string - - wrap string - - events []coreiface.AddEvent - - opts []options.UnixfsAddOption - }{ - // Simple cases - { - name: "simpleAdd", - data: strFile(helloStr), - path: hello, - opts: []options.UnixfsAddOption{}, - }, - { - name: "addEmpty", - data: strFile(""), - path: emptyFile, - }, - // CIDv1 version / rawLeaves - { - name: "addCidV1", - data: strFile(helloStr), - path: "/ipfs/zb2rhdhmJjJZs9qkhQCpCQ7VREFkqWw3h1r8utjVvQugwHPFd", - opts: []options.UnixfsAddOption{options.Unixfs.CidVersion(1)}, - }, - { - name: "addCidV1NoLeaves", - data: strFile(helloStr), - path: "/ipfs/zdj7WY4GbN8NDbTW1dfCShAQNVovams2xhq9hVCx5vXcjvT8g", - opts: []options.UnixfsAddOption{options.Unixfs.CidVersion(1), options.Unixfs.RawLeaves(false)}, - }, - // Non sha256 hash vs CID - { - name: "addCidSha3", - data: strFile(helloStr), - path: "/ipfs/zb2wwnYtXBxpndNABjtYxWAPt3cwWNRnc11iT63fvkYV78iRb", - opts: []options.UnixfsAddOption{options.Unixfs.Hash(mh.SHA3_256)}, - }, - { - name: "addCidSha3Cid0", - data: strFile(helloStr), - err: "CIDv0 only supports sha2-256", - opts: []options.UnixfsAddOption{options.Unixfs.CidVersion(0), options.Unixfs.Hash(mh.SHA3_256)}, - }, - // Inline - { - name: "addInline", - data: strFile(helloStr), - path: "/ipfs/zaYomJdLndMku8P9LHngHB5w2CQ7NenLbv", - opts: []options.UnixfsAddOption{options.Unixfs.Inline(true)}, - }, - { - name: "addInlineLimit", - data: strFile(helloStr), - path: "/ipfs/zaYomJdLndMku8P9LHngHB5w2CQ7NenLbv", - opts: []options.UnixfsAddOption{options.Unixfs.InlineLimit(32), options.Unixfs.Inline(true)}, - }, - { - name: "addInlineZero", - data: strFile(""), - path: "/ipfs/z2yYDV", - opts: []options.UnixfsAddOption{options.Unixfs.InlineLimit(0), options.Unixfs.Inline(true), options.Unixfs.RawLeaves(true)}, - }, - { //TODO: after coreapi add is used in `ipfs add`, consider making this default for inline - name: "addInlineRaw", - data: strFile(helloStr), - path: "/ipfs/zj7Gr8AcBreqGEfrnR5kPFe", - opts: []options.UnixfsAddOption{options.Unixfs.InlineLimit(32), options.Unixfs.Inline(true), options.Unixfs.RawLeaves(true)}, - }, - // Chunker / Layout - { - name: "addChunks", - data: strFile(strings.Repeat("aoeuidhtns", 200)), - path: "/ipfs/QmRo11d4QJrST47aaiGVJYwPhoNA4ihRpJ5WaxBWjWDwbX", - opts: []options.UnixfsAddOption{options.Unixfs.Chunker("size-4")}, - }, - { - name: "addChunksTrickle", - data: strFile(strings.Repeat("aoeuidhtns", 200)), - path: "/ipfs/QmNNhDGttafX3M1wKWixGre6PrLFGjnoPEDXjBYpTv93HP", - opts: []options.UnixfsAddOption{options.Unixfs.Chunker("size-4"), options.Unixfs.Layout(options.TrickleLayout)}, - }, - // Local - { - name: "addLocal", // better cases in sharness - data: strFile(helloStr), - path: hello, - apiOpts: []options.ApiOption{options.Api.Offline(true)}, - }, - { - name: "hashOnly", // test (non)fetchability - data: strFile(helloStr), - path: hello, - opts: []options.UnixfsAddOption{options.Unixfs.HashOnly(true)}, - }, - // multi file - { - name: "simpleDir", - data: flatDir, - wrap: "t", - path: "/ipfs/QmRKGpFfR32FVXdvJiHfo4WJ5TDYBsM1P9raAp1p6APWSp", - }, - { - name: "twoLevelDir", - data: twoLevelDir(), - wrap: "t", - path: "/ipfs/QmVG2ZYCkV1S4TK8URA3a4RupBF17A8yAr4FqsRDXVJASr", - }, - // wrapped - { - name: "addWrapped", - path: "/ipfs/QmVE9rNpj5doj7XHzp5zMUxD7BJgXEqx4pe3xZ3JBReWHE", - data: func() files.Node { - return files.NewBytesFile([]byte(helloStr)) - }, - wrap: "foo", - expect: wrapped("foo"), - opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true)}, - }, - { - name: "addNotWrappedDirFile", - path: hello, - data: func() files.Node { - return files.NewBytesFile([]byte(helloStr)) - }, - wrap: "foo", - }, - { - name: "stdinWrapped", - path: "/ipfs/QmU3r81oZycjHS9oaSHw37ootMFuFUw1DvMLKXPsezdtqU", - data: func() files.Node { - return files.NewBytesFile([]byte(helloStr)) - }, - expect: func(files.Node) files.Node { - return files.NewMapDirectory(map[string]files.Node{ - "QmQy2Dw4Wk7rdJKjThjYXzfFJNaRKRHhHP5gHHXroJMYxk": files.NewBytesFile([]byte(helloStr)), - }) - }, - opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true)}, - }, - { - name: "stdinNamed", - path: "/ipfs/QmQ6cGBmb3ZbdrQW1MRm1RJnYnaxCqfssz7CrTa9NEhQyS", - data: func() files.Node { - rf, err := files.NewReaderPathFile(os.Stdin.Name(), ioutil.NopCloser(strings.NewReader(helloStr)), nil) - if err != nil { - panic(err) - } - - return rf - }, - expect: func(files.Node) files.Node { - return files.NewMapDirectory(map[string]files.Node{ - "test": files.NewBytesFile([]byte(helloStr)), - }) - }, - opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true), options.Unixfs.StdinName("test")}, - }, - { - name: "twoLevelDirWrapped", - data: twoLevelDir(), - wrap: "t", - expect: wrapped("t"), - path: "/ipfs/QmPwsL3T5sWhDmmAWZHAzyjKtMVDS9a11aHNRqb3xoVnmg", - opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true)}, - }, - { - name: "twoLevelInlineHash", - data: twoLevelDir(), - wrap: "t", - expect: wrapped("t"), - path: "/ipfs/zBunoruKoyCHKkALNSWxDvj4L7yuQnMgQ4hUa9j1Z64tVcDEcu6Zdetyu7eeFCxMPfxb7YJvHeFHoFoHMkBUQf6vfdhmi", - opts: []options.UnixfsAddOption{options.Unixfs.Wrap(true), options.Unixfs.Inline(true), options.Unixfs.RawLeaves(true), options.Unixfs.Hash(mh.SHA3)}, - }, - // hidden - { - name: "hiddenFiles", - data: func() files.Node { - return files.NewMapDirectory(map[string]files.Node{ - ".bar": files.NewBytesFile([]byte("hello2")), - "bar": files.NewBytesFile([]byte("hello2")), - "foo": files.NewBytesFile([]byte("hello1")), - }) - }, - wrap: "t", - path: "/ipfs/QmehGvpf2hY196MzDFmjL8Wy27S4jbgGDUAhBJyvXAwr3g", - opts: []options.UnixfsAddOption{options.Unixfs.Hidden(true)}, - }, - { - name: "hiddenFileAlwaysAdded", - data: func() files.Node { - return files.NewBytesFile([]byte(helloStr)) - }, - wrap: ".foo", - path: hello, - }, - { - name: "hiddenFilesNotAdded", - data: func() files.Node { - return files.NewMapDirectory(map[string]files.Node{ - ".bar": files.NewBytesFile([]byte("hello2")), - "bar": files.NewBytesFile([]byte("hello2")), - "foo": files.NewBytesFile([]byte("hello1")), - }) - }, - expect: func(files.Node) files.Node { - return flatDir() - }, - wrap: "t", - path: "/ipfs/QmRKGpFfR32FVXdvJiHfo4WJ5TDYBsM1P9raAp1p6APWSp", - opts: []options.UnixfsAddOption{options.Unixfs.Hidden(false)}, - }, - // NoCopy - { - name: "simpleNoCopy", - data: realFile, - path: "/ipfs/zb2rhdhmJjJZs9qkhQCpCQ7VREFkqWw3h1r8utjVvQugwHPFd", - opts: []options.UnixfsAddOption{options.Unixfs.Nocopy(true)}, - }, - { - name: "noCopyNoRaw", - data: realFile, - path: "/ipfs/zb2rhdhmJjJZs9qkhQCpCQ7VREFkqWw3h1r8utjVvQugwHPFd", - opts: []options.UnixfsAddOption{options.Unixfs.Nocopy(true), options.Unixfs.RawLeaves(false)}, - err: "nocopy option requires '--raw-leaves' to be enabled as well", - }, - { - name: "noCopyNoPath", - data: strFile(helloStr), - path: "/ipfs/zb2rhdhmJjJZs9qkhQCpCQ7VREFkqWw3h1r8utjVvQugwHPFd", - opts: []options.UnixfsAddOption{options.Unixfs.Nocopy(true)}, - err: helpers.ErrMissingFsRef.Error(), - }, - // Events / Progress - { - name: "simpleAddEvent", - data: strFile(helloStr), - path: "/ipfs/zb2rhdhmJjJZs9qkhQCpCQ7VREFkqWw3h1r8utjVvQugwHPFd", - events: []coreiface.AddEvent{ - {Name: "zb2rhdhmJjJZs9qkhQCpCQ7VREFkqWw3h1r8utjVvQugwHPFd", Path: p("zb2rhdhmJjJZs9qkhQCpCQ7VREFkqWw3h1r8utjVvQugwHPFd"), Size: strconv.Itoa(len(helloStr))}, - }, - opts: []options.UnixfsAddOption{options.Unixfs.RawLeaves(true)}, - }, - { - name: "silentAddEvent", - data: twoLevelDir(), - path: "/ipfs/QmVG2ZYCkV1S4TK8URA3a4RupBF17A8yAr4FqsRDXVJASr", - events: []coreiface.AddEvent{ - {Name: "t/abc", Path: p("QmU7nuGs2djqK99UNsNgEPGh6GV4662p6WtsgccBNGTDxt"), Size: "62"}, - {Name: "t", Path: p("QmVG2ZYCkV1S4TK8URA3a4RupBF17A8yAr4FqsRDXVJASr"), Size: "229"}, - }, - wrap: "t", - opts: []options.UnixfsAddOption{options.Unixfs.Silent(true)}, - }, - { - name: "dirAddEvents", - data: twoLevelDir(), - path: "/ipfs/QmVG2ZYCkV1S4TK8URA3a4RupBF17A8yAr4FqsRDXVJASr", - events: []coreiface.AddEvent{ - {Name: "t/abc/def", Path: p("QmNyJpQkU1cEkBwMDhDNFstr42q55mqG5GE5Mgwug4xyGk"), Size: "13"}, - {Name: "t/bar", Path: p("QmS21GuXiRMvJKHos4ZkEmQDmRBqRaF5tQS2CQCu2ne9sY"), Size: "14"}, - {Name: "t/foo", Path: p("QmfAjGiVpTN56TXi6SBQtstit5BEw3sijKj1Qkxn6EXKzJ"), Size: "14"}, - {Name: "t/abc", Path: p("QmU7nuGs2djqK99UNsNgEPGh6GV4662p6WtsgccBNGTDxt"), Size: "62"}, - {Name: "t", Path: p("QmVG2ZYCkV1S4TK8URA3a4RupBF17A8yAr4FqsRDXVJASr"), Size: "229"}, - }, - wrap: "t", - }, - { - name: "progress1M", - data: func() files.Node { - return files.NewReaderFile(bytes.NewReader(bytes.Repeat([]byte{0}, 1000000))) - }, - path: "/ipfs/QmXXNNbwe4zzpdMg62ZXvnX1oU7MwSrQ3vAEtuwFKCm1oD", - events: []coreiface.AddEvent{ - {Name: "", Bytes: 262144}, - {Name: "", Bytes: 524288}, - {Name: "", Bytes: 786432}, - {Name: "", Bytes: 1000000}, - {Name: "QmXXNNbwe4zzpdMg62ZXvnX1oU7MwSrQ3vAEtuwFKCm1oD", Path: p("QmXXNNbwe4zzpdMg62ZXvnX1oU7MwSrQ3vAEtuwFKCm1oD"), Size: "1000256"}, - }, - wrap: "", - opts: []options.UnixfsAddOption{options.Unixfs.Progress(true)}, - }, - } - - for _, testCase := range cases { - t.Run(testCase.name, func(t *testing.T) { - ctx, cancel := context.WithCancel(ctx) - defer cancel() - - // recursive logic - - data := testCase.data() - if testCase.wrap != "" { - data = files.NewMapDirectory(map[string]files.Node{ - testCase.wrap: data, - }) - } - - // handle events if relevant to test case - - opts := testCase.opts - eventOut := make(chan interface{}) - var evtWg sync.WaitGroup - if len(testCase.events) > 0 { - opts = append(opts, options.Unixfs.Events(eventOut)) - evtWg.Add(1) - - go func() { - defer evtWg.Done() - expected := testCase.events - - for evt := range eventOut { - event, ok := evt.(*coreiface.AddEvent) - if !ok { - t.Fatal("unexpected event type") - } - - if len(expected) < 1 { - t.Fatal("got more events than expected") - } - - if expected[0].Size != event.Size { - t.Errorf("Event.Size didn't match, %s != %s", expected[0].Size, event.Size) - } - - if expected[0].Name != event.Name { - t.Errorf("Event.Name didn't match, %s != %s", expected[0].Name, event.Name) - } - - if expected[0].Path != nil && event.Path != nil { - if expected[0].Path.Cid().String() != event.Path.Cid().String() { - t.Errorf("Event.Hash didn't match, %s != %s", expected[0].Path, event.Path) - } - } else if event.Path != expected[0].Path { - t.Errorf("Event.Hash didn't match, %s != %s", expected[0].Path, event.Path) - } - if expected[0].Bytes != event.Bytes { - t.Errorf("Event.Bytes didn't match, %d != %d", expected[0].Bytes, event.Bytes) - } - - expected = expected[1:] - } - - if len(expected) > 0 { - t.Fatalf("%d event(s) didn't arrive", len(expected)) - } - }() - } - - tapi, err := api.WithOptions(testCase.apiOpts...) - if err != nil { - t.Fatal(err) - } - - // Add! - - p, err := tapi.Unixfs().Add(ctx, data, opts...) - close(eventOut) - evtWg.Wait() - if testCase.err != "" { - if err == nil { - t.Fatalf("expected an error: %s", testCase.err) - } - if err.Error() != testCase.err { - t.Fatalf("expected an error: '%s' != '%s'", err.Error(), testCase.err) - } - return - } - if err != nil { - t.Fatal(err) - } - - if p.String() != testCase.path { - t.Errorf("expected path %s, got: %s", testCase.path, p) - } - - // compare file structure with Unixfs().Get - - var cmpFile func(origName string, orig files.Node, gotName string, got files.Node) - cmpFile = func(origName string, orig files.Node, gotName string, got files.Node) { - _, origDir := orig.(files.Directory) - _, gotDir := got.(files.Directory) - - if origDir != gotDir { - t.Fatal("file type mismatch") - } - - if origName != gotName { - t.Errorf("file name mismatch, orig='%s', got='%s'", origName, gotName) - } - - if !gotDir { - defer orig.Close() - defer got.Close() - - do, err := ioutil.ReadAll(orig.(files.File)) - if err != nil { - t.Fatal(err) - } - - dg, err := ioutil.ReadAll(got.(files.File)) - if err != nil { - t.Fatal(err) - } - - if !bytes.Equal(do, dg) { - t.Fatal("data not equal") - } - - return - } - - origIt := orig.(files.Directory).Entries() - gotIt := got.(files.Directory).Entries() - - for { - if origIt.Next() { - if !gotIt.Next() { - t.Fatal("gotIt out of entries before origIt") - } - } else { - if gotIt.Next() { - t.Fatal("origIt out of entries before gotIt") - } - break - } - - cmpFile(origIt.Name(), origIt.Node(), gotIt.Name(), gotIt.Node()) - } - if origIt.Err() != nil { - t.Fatal(origIt.Err()) - } - if gotIt.Err() != nil { - t.Fatal(gotIt.Err()) - } - } - - f, err := tapi.Unixfs().Get(ctx, p) - if err != nil { - t.Fatal(err) - } - - orig := testCase.data() - if testCase.expect != nil { - orig = testCase.expect(orig) - } - - cmpFile("", orig, "", f) - }) - } -} - -func (tp *provider) TestAddPinned(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - _, err = api.Unixfs().Add(ctx, strFile(helloStr)(), options.Unixfs.Pin(true)) - if err != nil { - t.Error(err) - } - - pins, err := api.Pin().Ls(ctx) - if len(pins) != 1 { - t.Fatalf("expected 1 pin, got %d", len(pins)) - } - - if pins[0].Path().String() != "/ipld/QmQy2Dw4Wk7rdJKjThjYXzfFJNaRKRHhHP5gHHXroJMYxk" { - t.Fatalf("got unexpected pin: %s", pins[0].Path().String()) - } -} - -func (tp *provider) TestAddHashOnly(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - p, err := api.Unixfs().Add(ctx, strFile(helloStr)(), options.Unixfs.HashOnly(true)) - if err != nil { - t.Error(err) - } - - if p.String() != hello { - t.Errorf("unxepected path: %s", p.String()) - } - - _, err = api.Block().Get(ctx, p) - if err == nil { - t.Fatal("expected an error") - } - if !strings.Contains(err.Error(), "blockservice: key not found") { - t.Errorf("unxepected error: %s", err.Error()) - } -} - -func (tp *provider) TestGetEmptyFile(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Fatal(err) - } - - _, err = api.Unixfs().Add(ctx, files.NewBytesFile([]byte{})) - if err != nil { - t.Fatal(err) - } - - emptyFilePath, err := coreiface.ParsePath(emptyFile) - if err != nil { - t.Fatal(err) - } - - r, err := api.Unixfs().Get(ctx, emptyFilePath) - if err != nil { - t.Fatal(err) - } - - buf := make([]byte, 1) // non-zero so that Read() actually tries to read - n, err := io.ReadFull(r.(files.File), buf) - if err != nil && err != io.EOF { - t.Error(err) - } - if !bytes.HasPrefix(buf, []byte{0x00}) { - t.Fatalf("expected empty data, got [%s] [read=%d]", buf, n) - } -} - -func (tp *provider) TestGetDir(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - edir := unixfs.EmptyDirNode() - err = api.Dag().Add(ctx, edir) - if err != nil { - t.Error(err) - } - p := coreiface.IpfsPath(edir.Cid()) - - emptyDir, err := api.Object().New(ctx, options.Object.Type("unixfs-dir")) - if err != nil { - t.Error(err) - } - - if p.String() != coreiface.IpfsPath(emptyDir.Cid()).String() { - t.Fatalf("expected path %s, got: %s", emptyDir.Cid(), p.String()) - } - - r, err := api.Unixfs().Get(ctx, coreiface.IpfsPath(emptyDir.Cid())) - if err != nil { - t.Error(err) - } - - if _, ok := r.(files.Directory); !ok { - t.Fatalf("expected a directory") - } -} - -func (tp *provider) TestGetNonUnixfs(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - nd := new(mdag.ProtoNode) - err = api.Dag().Add(ctx, nd) - if err != nil { - t.Error(err) - } - - _, err = api.Unixfs().Get(ctx, coreiface.IpfsPath(nd.Cid())) - if !strings.Contains(err.Error(), "proto: required field") { - t.Fatalf("expected protobuf error, got: %s", err) - } -} - -func (tp *provider) TestLs(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - r := strings.NewReader("content-of-file") - p, err := api.Unixfs().Add(ctx, files.NewMapDirectory(map[string]files.Node{ - "0": files.NewMapDirectory(map[string]files.Node{ - "name-of-file": files.NewReaderFile(r), - }), - })) - if err != nil { - t.Error(err) - } - - links, err := api.Unixfs().Ls(ctx, p) - if err != nil { - t.Error(err) - } - - linkRes := <-links - if linkRes.Err != nil { - t.Fatal(linkRes.Err) - } - link := linkRes.Link - if linkRes.Size != 15 { - t.Fatalf("expected size = 15, got %d", link.Size) - } - if link.Name != "name-of-file" { - t.Fatalf("expected name = name-of-file, got %s", link.Name) - } - if link.Cid.String() != "QmX3qQVKxDGz3URVC3861Z3CKtQKGBn6ffXRBBWGMFz9Lr" { - t.Fatalf("expected cid = QmX3qQVKxDGz3URVC3861Z3CKtQKGBn6ffXRBBWGMFz9Lr, got %s", link.Cid) - } - if l, ok := <-links; ok { - t.Errorf("didn't expect a second link") - if l.Err != nil { - t.Error(l.Err) - } - } -} - -func (tp *provider) TestEntriesExpired(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - r := strings.NewReader("content-of-file") - p, err := api.Unixfs().Add(ctx, files.NewMapDirectory(map[string]files.Node{ - "0": files.NewMapDirectory(map[string]files.Node{ - "name-of-file": files.NewReaderFile(r), - }), - })) - if err != nil { - t.Error(err) - } - - ctx, cancel = context.WithCancel(ctx) - - nd, err := api.Unixfs().Get(ctx, p) - if err != nil { - t.Error(err) - } - cancel() - - it := files.ToDir(nd).Entries() - if it == nil { - t.Fatal("it was nil") - } - - if it.Next() { - t.Fatal("Next succeeded") - } - - if it.Err() != context.Canceled { - t.Fatalf("unexpected error %s", it.Err()) - } - - if it.Next() { - t.Fatal("Next succeeded") - } -} - -func (tp *provider) TestLsEmptyDir(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - _, err = api.Unixfs().Add(ctx, files.NewMapDirectory(map[string]files.Node{"0": files.NewSliceDirectory([]files.DirEntry{})})) - if err != nil { - t.Error(err) - } - - emptyDir, err := api.Object().New(ctx, options.Object.Type("unixfs-dir")) - if err != nil { - t.Error(err) - } - - links, err := api.Unixfs().Ls(ctx, coreiface.IpfsPath(emptyDir.Cid())) - if err != nil { - t.Error(err) - } - - if len(links) != 0 { - t.Fatalf("expected 0 links, got %d", len(links)) - } -} - -// TODO(lgierth) this should test properly, with len(links) > 0 -func (tp *provider) TestLsNonUnixfs(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - nd, err := cbor.WrapObject(map[string]interface{}{"foo": "bar"}, math.MaxUint64, -1) - if err != nil { - t.Fatal(err) - } - - err = api.Dag().Add(ctx, nd) - if err != nil { - t.Error(err) - } - - links, err := api.Unixfs().Ls(ctx, coreiface.IpfsPath(nd.Cid())) - if err != nil { - t.Error(err) - } - - if len(links) != 0 { - t.Fatalf("expected 0 links, got %d", len(links)) - } -} - -type closeTestF struct { - files.File - closed bool - - t *testing.T -} - -type closeTestD struct { - files.Directory - closed bool - - t *testing.T -} - -func (f *closeTestD) Close() error { - if f.closed { - f.t.Fatal("already closed") - } - f.closed = true - return nil -} - -func (f *closeTestF) Close() error { - if f.closed { - f.t.Fatal("already closed") - } - f.closed = true - return nil -} - -func (tp *provider) TestAddCloses(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - n4 := &closeTestF{files.NewBytesFile([]byte("foo")), false, t} - d3 := &closeTestD{files.NewMapDirectory(map[string]files.Node{ - "sub": n4, - }), false, t} - n2 := &closeTestF{files.NewBytesFile([]byte("bar")), false, t} - n1 := &closeTestF{files.NewBytesFile([]byte("baz")), false, t} - d0 := &closeTestD{files.NewMapDirectory(map[string]files.Node{ - "a": d3, - "b": n1, - "c": n2, - }), false, t} - - _, err = api.Unixfs().Add(ctx, d0) - if err != nil { - t.Error(err) - } - - d0.Close() // Adder doesn't close top-level file - - for i, n := range []*closeTestF{n1, n2, n4} { - if !n.closed { - t.Errorf("file %d not closed!", i) - } - } - - for i, n := range []*closeTestD{d0, d3} { - if !n.closed { - t.Errorf("dir %d not closed!", i) - } - } -} - -func (tp *provider) TestGetSeek(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(ctx) - if err != nil { - t.Error(err) - } - - dataSize := int64(100000) - tf := files.NewReaderFile(io.LimitReader(rand.New(rand.NewSource(1403768328)), dataSize)) - - p, err := api.Unixfs().Add(ctx, tf, options.Unixfs.Chunker("size-100")) - if err != nil { - t.Fatal(err) - } - - r, err := api.Unixfs().Get(ctx, p) - if err != nil { - t.Fatal(err) - } - - f := files.ToFile(r) - if f == nil { - t.Fatal("not a file") - } - - orig := make([]byte, dataSize) - if _, err := io.ReadFull(f, orig); err != nil { - t.Fatal(err) - } - f.Close() - - origR := bytes.NewReader(orig) - - r, err = api.Unixfs().Get(ctx, p) - if err != nil { - t.Fatal(err) - } - - f = files.ToFile(r) - if f == nil { - t.Fatal("not a file") - } - - test := func(offset int64, whence int, read int, expect int64, shouldEof bool) { - t.Run(fmt.Sprintf("seek%d+%d-r%d-%d", whence, offset, read, expect), func(t *testing.T) { - n, err := f.Seek(offset, whence) - if err != nil { - t.Fatal(err) - } - origN, err := origR.Seek(offset, whence) - if err != nil { - t.Fatal(err) - } - - if n != origN { - t.Fatalf("offsets didn't match, expected %d, got %d", origN, n) - } - - buf := make([]byte, read) - origBuf := make([]byte, read) - origRead, err := origR.Read(origBuf) - if err != nil { - t.Fatalf("orig: %s", err) - } - r, err := io.ReadFull(f, buf) - switch { - case shouldEof && err != nil && err != io.ErrUnexpectedEOF: - fallthrough - case !shouldEof && err != nil: - t.Fatalf("f: %s", err) - case shouldEof: - _, err := f.Read([]byte{0}) - if err != io.EOF { - t.Fatal("expected EOF") - } - _, err = origR.Read([]byte{0}) - if err != io.EOF { - t.Fatal("expected EOF (orig)") - } - } - - if int64(r) != expect { - t.Fatal("read wrong amount of data") - } - if r != origRead { - t.Fatal("read different amount of data than bytes.Reader") - } - if !bytes.Equal(buf, origBuf) { - fmt.Fprintf(os.Stderr, "original:\n%s\n", hex.Dump(origBuf)) - fmt.Fprintf(os.Stderr, "got:\n%s\n", hex.Dump(buf)) - t.Fatal("data didn't match") - } - }) - } - - test(3, io.SeekCurrent, 10, 10, false) - test(3, io.SeekCurrent, 10, 10, false) - test(500, io.SeekCurrent, 10, 10, false) - test(350, io.SeekStart, 100, 100, false) - test(-123, io.SeekCurrent, 100, 100, false) - test(0, io.SeekStart, int(dataSize), dataSize, false) - test(dataSize-50, io.SeekStart, 100, 50, true) - test(-5, io.SeekEnd, 100, 5, true) -} diff --git a/core/coreapi/interface/unixfs.go b/core/coreapi/interface/unixfs.go deleted file mode 100644 index 8e559022ccd..00000000000 --- a/core/coreapi/interface/unixfs.go +++ /dev/null @@ -1,55 +0,0 @@ -package iface - -import ( - "context" - "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - - ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" - "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs" - "gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files" -) - -type AddEvent struct { - Name string - Path ResolvedPath `json:",omitempty"` - Bytes int64 `json:",omitempty"` - Size string `json:",omitempty"` -} - -type FileType int32 - -const ( - TRaw = FileType(unixfs.TRaw) - TFile = FileType(unixfs.TFile) - TDirectory = FileType(unixfs.TDirectory) - TMetadata = FileType(unixfs.TMetadata) - TSymlink = FileType(unixfs.TSymlink) - THAMTShard = FileType(unixfs.THAMTShard) -) - -type LsLink struct { - Link *ipld.Link - Size uint64 - Type FileType - - Err error -} - -// UnixfsAPI is the basic interface to immutable files in IPFS -// NOTE: This API is heavily WIP, things are guaranteed to break frequently -type UnixfsAPI interface { - // Add imports the data from the reader into merkledag file - // - // TODO: a long useful comment on how to use this for many different scenarios - Add(context.Context, files.Node, ...options.UnixfsAddOption) (ResolvedPath, error) - - // Get returns a read-only handle to a file tree referenced by a path - // - // Note that some implementations of this API may apply the specified context - // to operations performed on the returned file - Get(context.Context, Path) (files.Node, error) - - // Ls returns the list of links in a directory. Links aren't guaranteed to be - // returned in order - Ls(context.Context, Path, ...options.UnixfsLsOption) (<-chan LsLink, error) -} diff --git a/core/coreapi/interface/util.go b/core/coreapi/interface/util.go deleted file mode 100644 index 6d58bf40d2b..00000000000 --- a/core/coreapi/interface/util.go +++ /dev/null @@ -1,20 +0,0 @@ -package iface - -import ( - "context" - "io" -) - -type Reader interface { - ReadSeekCloser - Size() uint64 - CtxReadFull(context.Context, []byte) (int, error) -} - -// A ReadSeekCloser implements interfaces to read, copy, seek and close. -type ReadSeekCloser interface { - io.Reader - io.Seeker - io.Closer - io.WriterTo -} diff --git a/core/coreapi/key.go b/core/coreapi/key.go index 5a68a61bb87..bf32e03fa88 100644 --- a/core/coreapi/key.go +++ b/core/coreapi/key.go @@ -7,12 +7,11 @@ import ( "fmt" "sort" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - caopts "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - crypto "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" peer "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" ipfspath "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + caopts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" ) type KeyAPI CoreAPI diff --git a/core/coreapi/name.go b/core/coreapi/name.go index 5b10448c392..0cb3a4820a5 100644 --- a/core/coreapi/name.go +++ b/core/coreapi/name.go @@ -6,8 +6,6 @@ import ( "strings" "time" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - caopts "github.com/ipfs/go-ipfs/core/coreapi/interface/options" "github.com/ipfs/go-ipfs/keystore" "github.com/ipfs/go-ipfs/namesys" @@ -15,6 +13,8 @@ import ( ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" ipath "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + caopts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" ) type NameAPI CoreAPI diff --git a/core/coreapi/object.go b/core/coreapi/object.go index 20a253d9b69..d50c7ed9870 100644 --- a/core/coreapi/object.go +++ b/core/coreapi/object.go @@ -11,14 +11,14 @@ import ( "io" "io/ioutil" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - caopts "github.com/ipfs/go-ipfs/core/coreapi/interface/options" "github.com/ipfs/go-ipfs/dagutils" "github.com/ipfs/go-ipfs/pin" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" dag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + caopts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" ft "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs" ) diff --git a/core/coreapi/path.go b/core/coreapi/path.go index 217be0db106..8ad4ab6a506 100644 --- a/core/coreapi/path.go +++ b/core/coreapi/path.go @@ -6,12 +6,12 @@ import ( gopath "path" "github.com/ipfs/go-ipfs/core" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" ipfspath "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path/resolver" "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" uio "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs/io" ) diff --git a/core/coreapi/pin.go b/core/coreapi/pin.go index b4d33ae0bdc..a9e202d32e2 100644 --- a/core/coreapi/pin.go +++ b/core/coreapi/pin.go @@ -4,13 +4,12 @@ import ( "context" "fmt" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - caopts "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - merkledag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" - bserv "gx/ipfs/QmbgbNxC1PMyS2gbx7nf2jKNG7bZAfYJJebdK4ptBBWCz1/go-blockservice" - cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" + merkledag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + caopts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" offline "gx/ipfs/QmYZwey1thDTynSrvd6qQkX24UpTka6TFhQ2v569UpoqxD/go-ipfs-exchange-offline" + bserv "gx/ipfs/QmbgbNxC1PMyS2gbx7nf2jKNG7bZAfYJJebdK4ptBBWCz1/go-blockservice" ) type PinAPI CoreAPI diff --git a/core/coreapi/pubsub.go b/core/coreapi/pubsub.go index 0c4e52e2875..ef2905118b3 100644 --- a/core/coreapi/pubsub.go +++ b/core/coreapi/pubsub.go @@ -7,14 +7,13 @@ import ( "sync" "time" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - caopts "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - peer "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" pstore "gx/ipfs/QmQFFp4ntkd4C14sP3FaH9WJyBuetuGUVo6dShNHvnoEvC/go-libp2p-peerstore" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" routing "gx/ipfs/QmRjT8Bkut84fHf9nxMQBxGsqLAkqzMdFaemDK7e61dBNZ/go-libp2p-routing" pubsub "gx/ipfs/QmWL6MKfes1HuSiRUNzGmwy9YyQDwcZF9V1NaA2keYKhtE/go-libp2p-pubsub" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + caopts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" p2phost "gx/ipfs/QmfRHxh8bt4jWLKRhNvR5fn7mFACrQBFLqV4wyoymEExKV/go-libp2p-host" ) diff --git a/core/coreapi/swarm.go b/core/coreapi/swarm.go index 53f92526ae5..0ac555a6517 100644 --- a/core/coreapi/swarm.go +++ b/core/coreapi/swarm.go @@ -5,12 +5,11 @@ import ( "sort" "time" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - ma "gx/ipfs/QmNTCey11oxhb1AxDnQBRHtdhap6Ctud872NjAYPYYXPuc/go-multiaddr" peer "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" pstore "gx/ipfs/QmQFFp4ntkd4C14sP3FaH9WJyBuetuGUVo6dShNHvnoEvC/go-libp2p-peerstore" swarm "gx/ipfs/QmTJCJaS8Cpjc2MkoS32iwr4zMZtbLkaF9GJsUgH1uwtN9/go-libp2p-swarm" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" inet "gx/ipfs/QmZ7cBWUXkyWTMN4qH6NGoyMVs7JugyFChBNP4ZUp5rJHH/go-libp2p-net" net "gx/ipfs/QmZ7cBWUXkyWTMN4qH6NGoyMVs7JugyFChBNP4ZUp5rJHH/go-libp2p-net" protocol "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol" diff --git a/core/coreapi/test/api_test.go b/core/coreapi/test/api_test.go index 2c99f8e3d22..f8be208625f 100644 --- a/core/coreapi/test/api_test.go +++ b/core/coreapi/test/api_test.go @@ -8,12 +8,10 @@ import ( "path/filepath" "testing" - "github.com/ipfs/go-ipfs/core/coreapi/interface/tests" "github.com/ipfs/go-ipfs/filestore" "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/core/coreapi" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" mock "github.com/ipfs/go-ipfs/core/mock" "github.com/ipfs/go-ipfs/keystore" "github.com/ipfs/go-ipfs/repo" @@ -23,6 +21,8 @@ import ( pstore "gx/ipfs/QmQFFp4ntkd4C14sP3FaH9WJyBuetuGUVo6dShNHvnoEvC/go-libp2p-peerstore" "gx/ipfs/QmSgtf5vHyugoxcwMbyNy6bZ9qPDDTJSYEED2GkWjLwitZ/go-libp2p/p2p/net/mock" "gx/ipfs/QmTbcMKv6GU3fxhnNcbzYChdox9Fdd7VpucM3PQ7UWjX3D/go-ipfs-config" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/tests" "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" ) diff --git a/core/coreapi/unixfs.go b/core/coreapi/unixfs.go index 7b3fb146f86..2471451e929 100644 --- a/core/coreapi/unixfs.go +++ b/core/coreapi/unixfs.go @@ -7,8 +7,6 @@ import ( "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/filestore" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - "github.com/ipfs/go-ipfs/core/coreapi/interface/options" "github.com/ipfs/go-ipfs/core/coreunix" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" @@ -18,6 +16,8 @@ import ( merkledag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" dagtest "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag/test" mfs "gx/ipfs/QmVBXaQqupXCFtS62xtr9EsKGkbK9LviqCKSzwcqzwvX9U/go-mfs" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" ft "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs" unixfile "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs/file" uio "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs/io" diff --git a/core/corehttp/gateway.go b/core/corehttp/gateway.go index 7db412a7263..326a087cd82 100644 --- a/core/corehttp/gateway.go +++ b/core/corehttp/gateway.go @@ -9,9 +9,9 @@ import ( version "github.com/ipfs/go-ipfs" core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" id "gx/ipfs/QmSgtf5vHyugoxcwMbyNy6bZ9qPDDTJSYEED2GkWjLwitZ/go-libp2p/p2p/protocol/identify" + options "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" ) type GatewayConfig struct { diff --git a/core/corehttp/gateway_handler.go b/core/corehttp/gateway_handler.go index d4e0ec51e92..836d57dc0ba 100644 --- a/core/corehttp/gateway_handler.go +++ b/core/corehttp/gateway_handler.go @@ -13,7 +13,6 @@ import ( "time" "github.com/ipfs/go-ipfs/core" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" @@ -24,6 +23,7 @@ import ( ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" "gx/ipfs/QmRjT8Bkut84fHf9nxMQBxGsqLAkqzMdFaemDK7e61dBNZ/go-libp2p-routing" dag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" ft "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs" "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs/importer" "gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files" diff --git a/core/corehttp/gateway_test.go b/core/corehttp/gateway_test.go index 2000945c01f..829b309a863 100644 --- a/core/corehttp/gateway_test.go +++ b/core/corehttp/gateway_test.go @@ -14,9 +14,6 @@ import ( version "github.com/ipfs/go-ipfs" core "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/core/coreapi" - "github.com/ipfs/go-ipfs/core/coreapi/interface" - "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - nsopts "github.com/ipfs/go-ipfs/core/coreapi/interface/options/namesys" namesys "github.com/ipfs/go-ipfs/namesys" repo "github.com/ipfs/go-ipfs/repo" @@ -24,6 +21,9 @@ import ( path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" id "gx/ipfs/QmSgtf5vHyugoxcwMbyNy6bZ9qPDDTJSYEED2GkWjLwitZ/go-libp2p/p2p/protocol/identify" config "gx/ipfs/QmTbcMKv6GU3fxhnNcbzYChdox9Fdd7VpucM3PQ7UWjX3D/go-ipfs-config" + "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" + nsopts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" files "gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" diff --git a/core/corehttp/ipns_hostname.go b/core/corehttp/ipns_hostname.go index dedf886277d..cd2f187eef6 100644 --- a/core/corehttp/ipns_hostname.go +++ b/core/corehttp/ipns_hostname.go @@ -7,9 +7,9 @@ import ( "strings" core "github.com/ipfs/go-ipfs/core" - nsopts "github.com/ipfs/go-ipfs/core/coreapi/interface/options/namesys" namesys "github.com/ipfs/go-ipfs/namesys" + nsopts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" ) diff --git a/core/coreunix/add.go b/core/coreunix/add.go index a3e5fe6eedc..c8076a5a23a 100644 --- a/core/coreunix/add.go +++ b/core/coreunix/add.go @@ -9,7 +9,6 @@ import ( gopath "path" "strconv" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/pin" chunker "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" @@ -19,6 +18,7 @@ import ( "gx/ipfs/QmUhHBdzfNb9FQPDtKwhghVoR3zwkbXzFJ1uJyEMYUpFSd/go-ipfs-posinfo" dag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" "gx/ipfs/QmVBXaQqupXCFtS62xtr9EsKGkbK9LviqCKSzwcqzwvX9U/go-mfs" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs" "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs/importer/balanced" ihelper "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs/importer/helpers" diff --git a/core/coreunix/add_test.go b/core/coreunix/add_test.go index 10b03a25448..595d679492c 100644 --- a/core/coreunix/add_test.go +++ b/core/coreunix/add_test.go @@ -12,7 +12,6 @@ import ( "time" "github.com/ipfs/go-ipfs/core" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/pin/gc" "github.com/ipfs/go-ipfs/repo" @@ -22,6 +21,7 @@ import ( pi "gx/ipfs/QmUhHBdzfNb9FQPDtKwhghVoR3zwkbXzFJ1uJyEMYUpFSd/go-ipfs-posinfo" dag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" blocks "gx/ipfs/QmWoXtvgC8inqFkAATB7cp2Dax7XBi9VDvSg9RCCZufmRk/go-block-format" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" files "gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files" "gx/ipfs/QmbgbNxC1PMyS2gbx7nf2jKNG7bZAfYJJebdK4ptBBWCz1/go-blockservice" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" diff --git a/dagutils/diff.go b/dagutils/diff.go index a1f49685e31..3bd7779f238 100644 --- a/dagutils/diff.go +++ b/dagutils/diff.go @@ -5,11 +5,10 @@ import ( "fmt" "path" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" dag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" ) // These constants define the changes that can be applied to a DAG. diff --git a/fuse/readonly/ipfs_test.go b/fuse/readonly/ipfs_test.go index 665bbef406f..698d19d727e 100644 --- a/fuse/readonly/ipfs_test.go +++ b/fuse/readonly/ipfs_test.go @@ -17,7 +17,6 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - iface "github.com/ipfs/go-ipfs/core/coreapi/interface" coremock "github.com/ipfs/go-ipfs/core/mock" u "gx/ipfs/QmNohiVssaPw3KVLZik59DBVGTSm2dGvYT9eoXt5DQ36Yz/go-ipfs-util" @@ -26,6 +25,7 @@ import ( fstest "gx/ipfs/QmSJBsmLP1XMjv8hxYg2rUMdPDB7YUpyBo9idjrJ6Cmq6F/fuse/fs/fstestutil" dag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" ci "gx/ipfs/QmVnJMgafh5MBYiyqbvDtoCL8pcQvbEGD2k9o9GFpBWPzY/go-testutil/ci" + iface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" importer "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs/importer" uio "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs/io" files "gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files" diff --git a/namesys/base.go b/namesys/base.go index 79cb65be9b8..4818cfbaf74 100644 --- a/namesys/base.go +++ b/namesys/base.go @@ -5,9 +5,8 @@ import ( "strings" "time" - opts "github.com/ipfs/go-ipfs/core/coreapi/interface/options/namesys" - path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" + opts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" ) type onceResult struct { diff --git a/namesys/dns.go b/namesys/dns.go index 5a34d5e2501..868d0a9b3a4 100644 --- a/namesys/dns.go +++ b/namesys/dns.go @@ -6,9 +6,8 @@ import ( "net" "strings" - opts "github.com/ipfs/go-ipfs/core/coreapi/interface/options/namesys" - path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" + opts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" ) diff --git a/namesys/dns_test.go b/namesys/dns_test.go index e434e19f802..4fdc46c3542 100644 --- a/namesys/dns_test.go +++ b/namesys/dns_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - opts "github.com/ipfs/go-ipfs/core/coreapi/interface/options/namesys" + opts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" ) type mockDNS struct { diff --git a/namesys/interface.go b/namesys/interface.go index 96fbb35b386..55677512206 100644 --- a/namesys/interface.go +++ b/namesys/interface.go @@ -35,10 +35,9 @@ import ( context "context" - opts "github.com/ipfs/go-ipfs/core/coreapi/interface/options/namesys" - path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" - ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" + path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" + opts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" ) // ErrResolveFailed signals an error when attempting to resolve. diff --git a/namesys/ipns_resolver_validation_test.go b/namesys/ipns_resolver_validation_test.go index 1e5c0d04cee..af198014579 100644 --- a/namesys/ipns_resolver_validation_test.go +++ b/namesys/ipns_resolver_validation_test.go @@ -5,13 +5,10 @@ import ( "testing" "time" - path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" - - opts "github.com/ipfs/go-ipfs/core/coreapi/interface/options/namesys" - ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" u "gx/ipfs/QmNohiVssaPw3KVLZik59DBVGTSm2dGvYT9eoXt5DQ36Yz/go-ipfs-util" peer "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" + path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" pstore "gx/ipfs/QmQFFp4ntkd4C14sP3FaH9WJyBuetuGUVo6dShNHvnoEvC/go-libp2p-peerstore" pstoremem "gx/ipfs/QmQFFp4ntkd4C14sP3FaH9WJyBuetuGUVo6dShNHvnoEvC/go-libp2p-peerstore/pstoremem" mockrouting "gx/ipfs/QmRJvdmKJoDcQEhhTt5NYXJPQFnJYPo1kfapxtjZLfDDqH/go-ipfs-routing/mock" @@ -20,6 +17,7 @@ import ( ropts "gx/ipfs/QmRjT8Bkut84fHf9nxMQBxGsqLAkqzMdFaemDK7e61dBNZ/go-libp2p-routing/options" testutil "gx/ipfs/QmVnJMgafh5MBYiyqbvDtoCL8pcQvbEGD2k9o9GFpBWPzY/go-testutil" ipns "gx/ipfs/QmVpC4PPSaoqZzWYEnQURnsQagimcWEzNKZouZyd7sNJdZ/go-ipns" + opts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" record "gx/ipfs/QmexPd3srWxHC76gW2p5j5tQvwpPuCoW7b9vFhJ8BRPyh9/go-libp2p-record" ds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" dssync "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" diff --git a/namesys/namesys.go b/namesys/namesys.go index 6a1a495aeaf..8e39b0bfa57 100644 --- a/namesys/namesys.go +++ b/namesys/namesys.go @@ -5,14 +5,12 @@ import ( "strings" "time" - path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" - - opts "github.com/ipfs/go-ipfs/core/coreapi/interface/options/namesys" - ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" peer "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" + path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" lru "gx/ipfs/QmQjMHF8ptRgx4E57UFMiT4YM6kqaJeYxZ1MCDX23aw4rK/golang-lru" routing "gx/ipfs/QmRjT8Bkut84fHf9nxMQBxGsqLAkqzMdFaemDK7e61dBNZ/go-libp2p-routing" + opts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash" ds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" diff --git a/namesys/namesys_test.go b/namesys/namesys_test.go index 1e0c173b661..9cb17fa7ef9 100644 --- a/namesys/namesys_test.go +++ b/namesys/namesys_test.go @@ -5,14 +5,13 @@ import ( "fmt" "testing" - opts "github.com/ipfs/go-ipfs/core/coreapi/interface/options/namesys" - ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" peer "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" pstoremem "gx/ipfs/QmQFFp4ntkd4C14sP3FaH9WJyBuetuGUVo6dShNHvnoEvC/go-libp2p-peerstore/pstoremem" offroute "gx/ipfs/QmRJvdmKJoDcQEhhTt5NYXJPQFnJYPo1kfapxtjZLfDDqH/go-ipfs-routing/offline" ipns "gx/ipfs/QmVpC4PPSaoqZzWYEnQURnsQagimcWEzNKZouZyd7sNJdZ/go-ipns" + opts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs" ds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" dssync "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" diff --git a/namesys/proquint.go b/namesys/proquint.go index 850eb398e24..c63d7e03d24 100644 --- a/namesys/proquint.go +++ b/namesys/proquint.go @@ -5,9 +5,8 @@ import ( "errors" path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" + opts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" proquint "gx/ipfs/QmYnf27kzqR2cxt6LFZdrAFJuQd6785fTkBvMuEj9EeRxM/proquint" - - opts "github.com/ipfs/go-ipfs/core/coreapi/interface/options/namesys" ) type ProquintResolver struct{} diff --git a/namesys/publisher.go b/namesys/publisher.go index d20cda5a0b0..19b49e6d1dd 100644 --- a/namesys/publisher.go +++ b/namesys/publisher.go @@ -7,14 +7,14 @@ import ( "time" pin "github.com/ipfs/go-ipfs/pin" - path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" - ft "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs" ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" peer "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" + path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" routing "gx/ipfs/QmRjT8Bkut84fHf9nxMQBxGsqLAkqzMdFaemDK7e61dBNZ/go-libp2p-routing" ipns "gx/ipfs/QmVpC4PPSaoqZzWYEnQURnsQagimcWEzNKZouZyd7sNJdZ/go-ipns" pb "gx/ipfs/QmVpC4PPSaoqZzWYEnQURnsQagimcWEzNKZouZyd7sNJdZ/go-ipns/pb" + ft "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs" proto "gx/ipfs/QmdxUuburamoF6zF9qjeQC4WYcWGbWuRmdLacMEsW8ioD8/gogo-protobuf/proto" ds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" dsquery "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/query" diff --git a/namesys/resolve_test.go b/namesys/resolve_test.go index 54cc4c8d69f..368e52698d0 100644 --- a/namesys/resolve_test.go +++ b/namesys/resolve_test.go @@ -6,9 +6,8 @@ import ( "testing" "time" - path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" - peer "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" + path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" mockrouting "gx/ipfs/QmRJvdmKJoDcQEhhTt5NYXJPQFnJYPo1kfapxtjZLfDDqH/go-ipfs-routing/mock" testutil "gx/ipfs/QmVnJMgafh5MBYiyqbvDtoCL8pcQvbEGD2k9o9GFpBWPzY/go-testutil" ipns "gx/ipfs/QmVpC4PPSaoqZzWYEnQURnsQagimcWEzNKZouZyd7sNJdZ/go-ipns" diff --git a/namesys/routing.go b/namesys/routing.go index 66220aba931..6ab72f2f742 100644 --- a/namesys/routing.go +++ b/namesys/routing.go @@ -5,15 +5,13 @@ import ( "strings" "time" - path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" - - opts "github.com/ipfs/go-ipfs/core/coreapi/interface/options/namesys" - peer "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer" + path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" routing "gx/ipfs/QmRjT8Bkut84fHf9nxMQBxGsqLAkqzMdFaemDK7e61dBNZ/go-libp2p-routing" ipns "gx/ipfs/QmVpC4PPSaoqZzWYEnQURnsQagimcWEzNKZouZyd7sNJdZ/go-ipns" pb "gx/ipfs/QmVpC4PPSaoqZzWYEnQURnsQagimcWEzNKZouZyd7sNJdZ/go-ipns/pb" + opts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" proto "gx/ipfs/QmdxUuburamoF6zF9qjeQC4WYcWGbWuRmdLacMEsW8ioD8/gogo-protobuf/proto" dht "gx/ipfs/Qmeh1RJ3kvEXgmuEmbNLwZ9wVUDuaqE7BhhEngd8aXV8tf/go-libp2p-kad-dht" diff --git a/package.json b/package.json index 885e2586ca0..60e45121e82 100644 --- a/package.json +++ b/package.json @@ -605,6 +605,12 @@ "hash": "QmTFYSU3zLMVpJdrz5FfAfNRnaPH7TZSyG5sxoJhCQdjAg", "name": "go-libp2p-autonat-svc", "version": "1.0.6" + }, + { + "author": "magik6k", + "hash": "QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH", + "name": "interface-go-ipfs-core", + "version": "0.1.0" } ], "gxVersion": "0.10.0", diff --git a/plugin/daemon.go b/plugin/daemon.go index 50aa2ac6c5e..ac50f45ce7d 100644 --- a/plugin/daemon.go +++ b/plugin/daemon.go @@ -1,7 +1,7 @@ package plugin import ( - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" ) // PluginDaemon is an interface for daemon plugins. These plugins will be run on diff --git a/plugin/loader/loader.go b/plugin/loader/loader.go index 67599e385fb..6f57a37a1d7 100644 --- a/plugin/loader/loader.go +++ b/plugin/loader/loader.go @@ -5,13 +5,13 @@ import ( "os" "strings" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" coredag "github.com/ipfs/go-ipfs/core/coredag" plugin "github.com/ipfs/go-ipfs/plugin" fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" opentracing "gx/ipfs/QmWLWmRVSiagqP15jczsGME1qpob6HDbtbHAY2he9W5iUo/opentracing-go" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" )