coreapi: FetchBlocks option

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


This commit was moved from ipfs/interface-go-ipfs-core@6800f56736

This commit was moved from ipfs/boxo@030083beef
This commit is contained in:
Łukasz Magiera 2019-01-04 15:40:15 +01:00
parent 80aace0fa2
commit 3702f185fb

View File

@ -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
}
}