coreapi: FetchBlocks option
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com> This commit was moved from ipfs/interface-go-ipfs-core@6800f56736680add20352d2348a59a1a41f7808e This commit was moved from ipfs/boxo@030083beef42fd48df466a4a97ea0f51fb1dfbc6
Łukasz Magiera committed
Jan 4, 2019 at 15:40 UTC
3702f185fb7543de86260e52fb22b6a32add1bbb
1 file changed
+13
-2
core/coreiface/options/global.go
+13
-2
@@ -1,14 +1,16 @@
1
package options
2
3
type ApiSettings struct {
4
- Offline bool
4
+ Offline bool
5
+ FetchBlocks bool
6
}
7
8
type ApiOption func(*ApiSettings) error
9
10
func ApiOptions(opts ...ApiOption) (*ApiSettings, error) {
11
options := &ApiSettings{
11
- Offline: false,
12
+ Offline: false,
13
+ FetchBlocks: true,
14
}
15
16
return ApiOptionsTo(options, opts...)
@@ -34,3 +36,12 @@ func (apiOpts) Offline(offline bool) ApiOption {
36
return nil
37
}
38
}
39
+
40
+// FetchBlocks when set to false prevents api from fetching blocks from the
41
+// network while allowing other services such as IPNS to still be online
42
+func (apiOpts) FetchBlocks(fetch bool) ApiOption {
43
+ return func(settings *ApiSettings) error {
44
+ settings.FetchBlocks = fetch
45
+ return nil
46
+ }
47
+}