BlockService creates new blockservice which provides an interface to fetch content-addressable blocks
(cfg *config.Config)
| 36 | |
| 37 | // BlockService creates new blockservice which provides an interface to fetch content-addressable blocks |
| 38 | func 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 | // |
no test coverage detected