Skip to content

Commit

Permalink
Add 'FetchBlocks' argument to Gateway constructor
Browse files Browse the repository at this point in the history
If FetchBlocks=false, don't fetch blocks which are not
already present in storage.

License: MIT
Signed-off-by: Iaroslav Gridin <voker57@gmail.com>
  • Loading branch information
Voker57 committed Nov 30, 2018
1 parent 156bf1c commit ceee457
Show file tree
Hide file tree
Showing 32 changed files with 67 additions and 34 deletions.
2 changes: 1 addition & 1 deletion cmd/ipfs/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
namesys "github.com/ipfs/go-ipfs/namesys"
fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"

"gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
"gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit"
"gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
"gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/ipfs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

loggables "gx/ipfs/QmNLzS18jsmwTxXewTm3YnZVLftWCeegNZEBFjMrnvnBrH/go-libp2p-loggables"
u "gx/ipfs/QmPdKqUcHGFdeSpvjVoaTRPPstGif9GBZb5Q56RVw9o69A/go-ipfs-util"
"gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
"gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
manet "gx/ipfs/QmV6FjemM1K8oXjrvuq3wuVWWoU2TLDPmNnKrxHzY3v6Ai/go-multiaddr-net"
"gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds"
"gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds/cli"
Expand Down
2 changes: 1 addition & 1 deletion cmd/ipfswatch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
coreunix "github.com/ipfs/go-ipfs/core/coreunix"
fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"

config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
process "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess"
config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
homedir "gx/ipfs/QmdcULN1WCzgoQmcCaUAmEhwcxHYsDrbZ2LvRJKCL8dMrK/go-homedir"
fsnotify "gx/ipfs/QmfNjggF4Pt6erqg3NDafD3MdvDHk1qqCVr8pL5hnPucS8/fsnotify"
)
Expand Down
2 changes: 1 addition & 1 deletion commands/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
coreapi "github.com/ipfs/go-ipfs/core/coreapi"
coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface"

config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
"gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit"
"gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit/files"
config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
"gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds"
)

Expand Down
2 changes: 1 addition & 1 deletion core/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
math2 "github.com/ipfs/go-ipfs/thirdparty/math2"
lgbl "gx/ipfs/QmNLzS18jsmwTxXewTm3YnZVLftWCeegNZEBFjMrnvnBrH/go-libp2p-loggables"

config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
goprocess "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess"
procctx "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess/context"
periodicproc "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess/periodic"
inet "gx/ipfs/QmSTaEYUgDe1r581hxyd2u9582Hgp3KX4wGwYbRqz2u9Qh/go-libp2p-net"
config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
pstore "gx/ipfs/QmWtCpWB39Rzc2xTB75MKorsxNpo3TyecTEN24CJ3KVohE/go-libp2p-peerstore"
peer "gx/ipfs/QmbNepETomvmXfz1X5pHNFD2QuPqnqi47dTd94QJWSorQ3/go-libp2p-peer"
host "gx/ipfs/Qmf5yHzmWAyHSJRPAmZzfk3Yd7icydBLi7eec5741aov7v/go-libp2p-host"
Expand Down
2 changes: 1 addition & 1 deletion core/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"

testutil "gx/ipfs/QmNfQbgBfARAtrYsBguChX6VJ5nbjeoYy1KdC36aaYWqG8/go-testutil"
config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
pstore "gx/ipfs/QmWtCpWB39Rzc2xTB75MKorsxNpo3TyecTEN24CJ3KVohE/go-libp2p-peerstore"
)

Expand Down
2 changes: 1 addition & 1 deletion core/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
bserv "gx/ipfs/QmVgTAMesq25DK9JuPVZAohx2aRkx1s7n8obmDsA2ipd1u/go-blockservice"

ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto"
cfg "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
goprocessctx "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess/context"
record "gx/ipfs/QmSb4B8ZAAj5ALe9LjfzPyF8Ma6ezC1NTnDF2JQPUJxEXb/go-libp2p-record"
cfg "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
offline "gx/ipfs/QmT6dHGp3UYd3vUMpy7rzX2CXQv7HLcj42Vtq8qwwjgASb/go-ipfs-exchange-offline"
pstore "gx/ipfs/QmWtCpWB39Rzc2xTB75MKorsxNpo3TyecTEN24CJ3KVohE/go-libp2p-peerstore"
pstoremem "gx/ipfs/QmWtCpWB39Rzc2xTB75MKorsxNpo3TyecTEN24CJ3KVohE/go-libp2p-peerstore/pstoremem"
Expand Down
2 changes: 1 addition & 1 deletion core/commands/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
repo "github.com/ipfs/go-ipfs/repo"
"github.com/ipfs/go-ipfs/repo/fsrepo"

config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
"gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit"
config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
)

type BootstrapOutput struct {
Expand Down
2 changes: 1 addition & 1 deletion core/commands/cmdenv/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/ipfs/go-ipfs/core"
coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface"

config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
cmds "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds"
)

Expand Down
2 changes: 1 addition & 1 deletion core/commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
repo "github.com/ipfs/go-ipfs/repo"
fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"

config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
"gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit"
config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
)

type ConfigField struct {
Expand Down
2 changes: 1 addition & 1 deletion core/commands/mount_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
e "github.com/ipfs/go-ipfs/core/commands/e"
nodeMount "github.com/ipfs/go-ipfs/fuse/node"

config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
"gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit"
config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
)

var MountCmd = &cmds.Command{
Expand Down
2 changes: 1 addition & 1 deletion core/commands/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"

cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid"
config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
cmdkit "gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit"
config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
cmds "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds"
bstore "gx/ipfs/QmcDDgAXDbpDUpadCJKLr49KYR4HuL7T8Z1dZTHt6ixsoR/go-ipfs-blockstore"
)
Expand Down
2 changes: 1 addition & 1 deletion core/commands/swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (
"github.com/ipfs/go-ipfs/repo"
"github.com/ipfs/go-ipfs/repo/fsrepo"

"gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
"gx/ipfs/QmR2Yj7Eod2U77DqUHRwNSbV2mtqeRHmVdCfsLkXZwJVLy/go-libp2p-swarm"
mafilter "gx/ipfs/QmSMZwvs3n4GBikZ7hKzT17c3bk65FmyZo2JqtJ16swqCv/multiaddr-filter"
"gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit"
inet "gx/ipfs/QmSTaEYUgDe1r581hxyd2u9582Hgp3KX4wGwYbRqz2u9Qh/go-libp2p-net"
"gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
pstore "gx/ipfs/QmWtCpWB39Rzc2xTB75MKorsxNpo3TyecTEN24CJ3KVohE/go-libp2p-peerstore"
"gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds"
ma "gx/ipfs/QmYmsdtJ3HsodkePE3eU3TsCaP2YvPZJ4LoXnNkDE5Tpt7/go-multiaddr"
Expand Down
2 changes: 1 addition & 1 deletion core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ import (
ic "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto"
nilrouting "gx/ipfs/QmQ9PR61a8rwEFuFNs7JMA1QtQC9yZnBwoDn51JWXDbaTd/go-ipfs-routing/none"
offroute "gx/ipfs/QmQ9PR61a8rwEFuFNs7JMA1QtQC9yZnBwoDn51JWXDbaTd/go-ipfs-routing/offline"
config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
exchange "gx/ipfs/QmR1nncPsZR14A4hWr39mq8Lm7BGgS68bHVT9nop8NpWEM/go-ipfs-exchange-interface"
goprocess "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess"
mamask "gx/ipfs/QmSMZwvs3n4GBikZ7hKzT17c3bk65FmyZo2JqtJ16swqCv/multiaddr-filter"
yamux "gx/ipfs/QmSNsTp6CjGoPj5yqjTMruAEoKcqicrzjsXfsaBLtKToVd/go-smux-yamux"
mafilter "gx/ipfs/QmSW4uNHbvQia8iZDXzbwjiyHQtnyo9aFqfQAMasj3TJ6Y/go-maddr-filter"
record "gx/ipfs/QmSb4B8ZAAj5ALe9LjfzPyF8Ma6ezC1NTnDF2JQPUJxEXb/go-libp2p-record"
config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
mfs "gx/ipfs/QmTBRw8S3NqcrCi3gAPuDa3o76DP6TzcxWz5iwHnHag493/go-mfs"
bitswap "gx/ipfs/QmTpkot96hyfLmj4mkWh62e7F2wY1RRWd7oe6MEY5FZyhV/go-bitswap"
bsnet "gx/ipfs/QmTpkot96hyfLmj4mkWh62e7F2wY1RRWd7oe6MEY5FZyhV/go-bitswap/network"
Expand Down
2 changes: 1 addition & 1 deletion core/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/ipfs/go-ipfs/repo"

config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
datastore "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore"
syncds "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore/sync"
)
Expand Down
2 changes: 1 addition & 1 deletion core/coreapi/unixfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
unixfs "gx/ipfs/QmNWmxWDZjv1dMUvz3sgThydJfeNUxxXaaZptF6E9b59vQ/go-unixfs"
mh "gx/ipfs/QmPnFwZ2JXKnXgMw8CdBPxn7FWh6LLdjUjxV1fKHuJnkr8/go-multihash"
ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto"
config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
files "gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit/files"
config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
cbor "gx/ipfs/QmSywXfm2v4Qkp4DcFqo8eehj49dJK3bdUnaLVxrdFLMQn/go-ipld-cbor"
mdag "gx/ipfs/QmTpyXP1bsqJvyW5VcNmALPCb47VPJFy2T8icGASNy4ML1/go-merkledag"
pstore "gx/ipfs/QmWtCpWB39Rzc2xTB75MKorsxNpo3TyecTEN24CJ3KVohE/go-libp2p-peerstore"
Expand Down
2 changes: 1 addition & 1 deletion core/corehttp/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/ipfs/go-ipfs/core"
corecommands "github.com/ipfs/go-ipfs/core/commands"

config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
path "gx/ipfs/QmTy6VoHV2E5baEFDXbp1xmHhxSVff5qTSrTsoXxD1eB2P/go-path"
cmds "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds"
cmdsHttp "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds/http"
Expand Down
4 changes: 3 additions & 1 deletion core/corehttp/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
type GatewayConfig struct {
Headers map[string][]string
Writable bool
FetchBlocks bool
PathPrefixes []string
}

Expand All @@ -26,13 +27,14 @@ func ConfigFromNode(n *core.IpfsNode) (*GatewayConfig, error) {
gc := &GatewayConfig{
Headers: cfg.Gateway.HTTPHeaders,
PathPrefixes: cfg.Gateway.PathPrefixes,
FetchBlocks: cfg.Gateway.FetchBlocks,
}
return gc, nil
}

func GatewayOption(gc GatewayConfig, paths ...string) ServeOption {
return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
gateway := newGatewayHandler(n, gc, coreapi.NewCoreAPI(n))
gateway := newGatewayHandler(n, gc, coreapi.NewCoreAPI(n, !gc.FetchBlocks))

for _, p := range paths {
mux.Handle(p+"/", gateway)
Expand Down
2 changes: 1 addition & 1 deletion core/corehttp/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
repo "github.com/ipfs/go-ipfs/repo"

ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto"
config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
dag "gx/ipfs/QmTpyXP1bsqJvyW5VcNmALPCb47VPJFy2T8icGASNy4ML1/go-merkledag"
path "gx/ipfs/QmTy6VoHV2E5baEFDXbp1xmHhxSVff5qTSrTsoXxD1eB2P/go-path"
datastore "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore"
Expand Down
2 changes: 1 addition & 1 deletion core/coreunix/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import (

pi "gx/ipfs/QmPG32VXR5jmpo9q8R9FNdR4Ae97Ky9CiZE6SctJLUB79H/go-ipfs-posinfo"
cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid"
config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
blocks "gx/ipfs/QmRcHuYzAyswytBuMF78rj3LTChYszomRFXNg4685ZN1WM/go-block-format"
files "gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit/files"
config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
dag "gx/ipfs/QmTpyXP1bsqJvyW5VcNmALPCb47VPJFy2T8icGASNy4ML1/go-merkledag"
"gx/ipfs/QmVgTAMesq25DK9JuPVZAohx2aRkx1s7n8obmDsA2ipd1u/go-blockservice"
datastore "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore"
Expand Down
2 changes: 1 addition & 1 deletion core/mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/ipfs/go-ipfs/repo"

testutil "gx/ipfs/QmNfQbgBfARAtrYsBguChX6VJ5nbjeoYy1KdC36aaYWqG8/go-testutil"
config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
pstore "gx/ipfs/QmWtCpWB39Rzc2xTB75MKorsxNpo3TyecTEN24CJ3KVohE/go-libp2p-peerstore"
datastore "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore"
syncds "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore/sync"
Expand Down
5 changes: 5 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ A boolean to configure whether the gateway is writeable or not.

Default: `false`

- `FetchBlocks`
A boolean to configure whether the gateway should fetch blocks from network to satisfy requests.

Default: `true`

- `PathPrefixes`
TODO

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
"version": "0.1.3"
},
{
"hash": "QmZ7Kqf9pbNvopSpC6L1UbV3ZbphShuv4554QdYGjKY2rM",
"hash": "QmeLP28CidKKZRQzFnZkqPPummH2e49Yb1kve89TovthiK",
"name": "iptb",
"version": "99.3.9"
"version": "99.4.0"
},
{
"hash": "QmPnFwZ2JXKnXgMw8CdBPxn7FWh6LLdjUjxV1fKHuJnkr8",
Expand Down Expand Up @@ -524,9 +524,9 @@
},
{
"author": "magik6k",
"hash": "QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u",
"hash": "QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3",
"name": "go-ipfs-config",
"version": "0.2.13"
"version": "0.3.0"
},
{
"author": "why",
Expand Down
2 changes: 1 addition & 1 deletion repo/fsrepo/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"reflect"
"testing"

config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
)

// note: to test sorting of the mountpoints in the disk spec they are
Expand Down
4 changes: 2 additions & 2 deletions repo/fsrepo/fsrepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (

util "gx/ipfs/QmPdKqUcHGFdeSpvjVoaTRPPstGif9GBZb5Q56RVw9o69A/go-ipfs-util"
measure "gx/ipfs/QmQS6UXi1R87y9nEgnCNmG6YfMzvBSLir7xUheMNFP3hoe/go-ds-measure"
config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
serialize "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config/serialize"
config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
serialize "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config/serialize"
ma "gx/ipfs/QmYmsdtJ3HsodkePE3eU3TsCaP2YvPZJ4LoXnNkDE5Tpt7/go-multiaddr"
logging "gx/ipfs/QmZChCsSt8DctjceaL56Eibc29CVQq4dGKRXC5JRZ6Ppae/go-log"
ds "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore"
Expand Down
2 changes: 1 addition & 1 deletion repo/fsrepo/fsrepo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/ipfs/go-ipfs/thirdparty/assert"

config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
datastore "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore"
)

Expand Down
2 changes: 1 addition & 1 deletion repo/fsrepo/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package fsrepo
import (
"os"

config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
homedir "gx/ipfs/QmdcULN1WCzgoQmcCaUAmEhwcxHYsDrbZ2LvRJKCL8dMrK/go-homedir"
)

Expand Down
2 changes: 1 addition & 1 deletion repo/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
filestore "github.com/ipfs/go-ipfs/filestore"
keystore "github.com/ipfs/go-ipfs/keystore"

config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
ma "gx/ipfs/QmYmsdtJ3HsodkePE3eU3TsCaP2YvPZJ4LoXnNkDE5Tpt7/go-multiaddr"
)

Expand Down
2 changes: 1 addition & 1 deletion repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
filestore "github.com/ipfs/go-ipfs/filestore"
keystore "github.com/ipfs/go-ipfs/keystore"

config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
ma "gx/ipfs/QmYmsdtJ3HsodkePE3eU3TsCaP2YvPZJ4LoXnNkDE5Tpt7/go-multiaddr"
ds "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore"
)
Expand Down
2 changes: 1 addition & 1 deletion test/bench/bench_cli_ipfs_add/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

"github.com/ipfs/go-ipfs/thirdparty/unit"

config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
random "gx/ipfs/QmSJ9n2s9NUoA9D849W5jj5SJ94nMcZpj1jCgQJieiNqSt/go-random"
config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion test/bench/offline_add/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

"github.com/ipfs/go-ipfs/thirdparty/unit"

config "gx/ipfs/QmQwsBSJXHs3nHBLPJKd1iBNpW9uJ9acSpqbbjafvNJQc3/go-ipfs-config"
random "gx/ipfs/QmSJ9n2s9NUoA9D849W5jj5SJ94nMcZpj1jCgQJieiNqSt/go-random"
config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
)

func main() {
Expand Down
26 changes: 26 additions & 0 deletions test/sharness/t0110-gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,30 @@ test_expect_success "GET compact blocks succeeds" '

test_kill_ipfs_daemon

test_expect_success "set FetchBlocks to false in config" '
ipfs config --bool=false Gateway.FetchBlocks
'

test_launch_ipfs_daemon

port=$GWAY_PORT
apiport=$API_PORT

test_expect_success "try fetching not present key from offline gateway" '
echo "hi" | ipfs add --hash-only -Q > hi.hash
test_expect_code 22 curl -f "http://127.0.0.1:$port/ipfs/$(cat hi.hash)"
'

test_expect_success "try fetching present key from offline gateway" '
echo "hi" | ipfs add -Q > hi.hash &&
echo "http://127.0.0.1:$port/ipfs/$(cat hi.hash)" &&
curl -f "http://127.0.0.1:$port/ipfs/$(cat hi.hash)"
'

test_kill_ipfs_daemon

test_expect_success "set FetchBlocks to true in config" '
ipfs config --bool=true Gateway.FetchBlocks
'

test_done

0 comments on commit ceee457

Please sign in to comment.