From 3702f185fb7543de86260e52fb22b6a32add1bbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 4 Jan 2019 15:40:15 +0100 Subject: [PATCH] coreapi: FetchBlocks option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Ɓukasz Magiera This commit was moved from ipfs/interface-go-ipfs-core@6800f56736680add20352d2348a59a1a41f7808e This commit was moved from ipfs/boxo@030083beef42fd48df466a4a97ea0f51fb1dfbc6 --- core/coreiface/options/global.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/core/coreiface/options/global.go b/core/coreiface/options/global.go index 93d635e41..90e2586f1 100644 --- a/core/coreiface/options/global.go +++ b/core/coreiface/options/global.go @@ -1,14 +1,16 @@ package options type ApiSettings struct { - Offline bool + Offline bool + FetchBlocks bool } type ApiOption func(*ApiSettings) error func ApiOptions(opts ...ApiOption) (*ApiSettings, error) { options := &ApiSettings{ - Offline: false, + Offline: false, + FetchBlocks: true, } return ApiOptionsTo(options, opts...) @@ -34,3 +36,12 @@ func (apiOpts) Offline(offline bool) ApiOption { 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 + } +}