提交 c9168ecf 作者: Łukasz Magiera

gateway: use Api.FetchBlocks for NoFetch

License: MIT
Signed-off-by: 's avatarŁukasz Magiera <magik6k@gmail.com>
上级 fea7b5da
...@@ -70,16 +70,16 @@ func (c *Context) GetAPI() (coreiface.CoreAPI, error) { ...@@ -70,16 +70,16 @@ func (c *Context) GetAPI() (coreiface.CoreAPI, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
offline := false fetchBlocks := true
if c.Gateway { if c.Gateway {
cfg, err := c.GetConfig() cfg, err := c.GetConfig()
if err != nil { if err != nil {
return nil, err return nil, err
} }
offline = cfg.Gateway.NoFetch fetchBlocks = !cfg.Gateway.NoFetch
} }
c.api, err = coreapi.NewCoreAPI(n, options.Api.Offline(offline)) c.api, err = coreapi.NewCoreAPI(n, options.Api.FetchBlocks(fetchBlocks))
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -26,7 +26,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption { ...@@ -26,7 +26,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption {
return nil, err return nil, err
} }
api, err := coreapi.NewCoreAPI(n, options.Api.Offline(cfg.Gateway.NoFetch)) api, err := coreapi.NewCoreAPI(n, options.Api.FetchBlocks(!cfg.Gateway.NoFetch))
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -244,13 +244,13 @@ test_expect_success "try fetching not present ipns key from node 0" ' ...@@ -244,13 +244,13 @@ test_expect_success "try fetching not present ipns key from node 0" '
' '
test_expect_success "try fetching present key from from node 0" ' test_expect_success "try fetching present key from from node 0" '
BAR=$(ipfsi 0 add -Q > bar.hash) && BAR=$(echo "bar" | ipfsi 0 add -Q) &&
curl -f "http://127.0.0.1:$GWPORT/ipfs/$BAR" curl -f "http://127.0.0.1:$GWPORT/ipfs/$BAR"
' '
test_expect_success "try fetching present ipns key from node 0" ' test_expect_success "try fetching present ipns key from node 0" '
ipfsi 1 name publish /ipfs/$BAR && ipfsi 1 name publish /ipfs/$BAR &&
test_expect_code 22 curl -f "http://127.0.0.1:$GWPORT/ipns/$PEERID_1" curl "http://127.0.0.1:$GWPORT/ipns/$PEERID_1"
' '
test_expect_success "stop testbed" ' test_expect_success "stop testbed" '
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论