@cryptotaxi247 / kubo / commits / c9168ecf0

gateway: use Api.FetchBlocks for NoFetch

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>

Łukasz Magiera committed Jan 4, 2019 at 15:56 UTC c9168ecf058af53adcb5712f3706af0a534df381
3 files changed +6 -6
commands/context.go
+3 -3
@@ -70,16 +70,16 @@ func (c *Context) GetAPI() (coreiface.CoreAPI, error) {
70 if err != nil {
71 return nil, err
72 }
73 - offline := false
73 + fetchBlocks := true
74 if c.Gateway {
75 cfg, err := c.GetConfig()
76 if err != nil {
77 return nil, err
78 }
79 - offline = cfg.Gateway.NoFetch
79 + fetchBlocks = !cfg.Gateway.NoFetch
80 }
81
82 - c.api, err = coreapi.NewCoreAPI(n, options.Api.Offline(offline))
82 + c.api, err = coreapi.NewCoreAPI(n, options.Api.FetchBlocks(fetchBlocks))
83 if err != nil {
84 return nil, err
85 }
core/corehttp/gateway.go
+1 -1
@@ -26,7 +26,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption {
26 return nil, err
27 }
28
29 - api, err := coreapi.NewCoreAPI(n, options.Api.Offline(cfg.Gateway.NoFetch))
29 + api, err := coreapi.NewCoreAPI(n, options.Api.FetchBlocks(!cfg.Gateway.NoFetch))
30 if err != nil {
31 return nil, err
32 }
test/sharness/t0110-gateway.sh
+2 -2
@@ -244,13 +244,13 @@ test_expect_success "try fetching not present ipns key from node 0" '
244 '
245
246 test_expect_success "try fetching present key from from node 0" '
247 - BAR=$(ipfsi 0 add -Q > bar.hash) &&
247 + BAR=$(echo "bar" | ipfsi 0 add -Q) &&
248 curl -f "http://127.0.0.1:$GWPORT/ipfs/$BAR"
249 '
250
251 test_expect_success "try fetching present ipns key from node 0" '
252 ipfsi 1 name publish /ipfs/$BAR &&
253 - test_expect_code 22 curl -f "http://127.0.0.1:$GWPORT/ipns/$PEERID_1"
253 + curl "http://127.0.0.1:$GWPORT/ipns/$PEERID_1"
254 '
255
256 test_expect_success "stop testbed" '