MCPcopy
hub / github.com/ipfs/kubo / BlockService

Function BlockService

core/node/core.go:38–52  ·  view source on GitHub ↗

BlockService creates new blockservice which provides an interface to fetch content-addressable blocks

(cfg *config.Config)

Source from the content-addressed store, hash-verified

36
37// BlockService creates new blockservice which provides an interface to fetch content-addressable blocks
38func BlockService(cfg *config.Config) func(lc fx.Lifecycle, bs blockstore.Blockstore, rem exchange.Interface) blockservice.BlockService {
39 return func(lc fx.Lifecycle, bs blockstore.Blockstore, rem exchange.Interface) blockservice.BlockService {
40 bsvc := blockservice.New(bs, rem,
41 blockservice.WriteThrough(cfg.Datastore.WriteThrough.WithDefault(config.DefaultWriteThrough)),
42 )
43
44 lc.Append(fx.Hook{
45 OnStop: func(ctx context.Context) error {
46 return shutdown.CloseWithCtx(ctx, "blockservice", bsvc.Close)
47 },
48 })
49
50 return bsvc
51 }
52}
53
54// Pinning builds the pinner that GC uses to decide which blocks to keep.
55//

Callers 1

IPFSFunction · 0.85

Calls 3

CloseWithCtxFunction · 0.92
AppendMethod · 0.80
WithDefaultMethod · 0.45

Tested by

no test coverage detected