Inject hooks all the plugins into the appropriate subsystems.
()
| 267 | |
| 268 | // Inject hooks all the plugins into the appropriate subsystems. |
| 269 | func (loader *PluginLoader) Inject() error { |
| 270 | if err := loader.transition(loaderInitialized, loaderInjecting); err != nil { |
| 271 | return err |
| 272 | } |
| 273 | |
| 274 | for _, pl := range loader.plugins { |
| 275 | if pl, ok := pl.(plugin.PluginIPLD); ok { |
| 276 | err := injectIPLDPlugin(pl) |
| 277 | if err != nil { |
| 278 | loader.state = loaderFailed |
| 279 | return err |
| 280 | } |
| 281 | } |
| 282 | if pl, ok := pl.(plugin.PluginTracer); ok { |
| 283 | err := injectTracerPlugin(pl) |
| 284 | if err != nil { |
| 285 | loader.state = loaderFailed |
| 286 | return err |
| 287 | } |
| 288 | } |
| 289 | if pl, ok := pl.(plugin.PluginDatastore); ok { |
| 290 | err := injectDatastorePlugin(pl) |
| 291 | if err != nil { |
| 292 | loader.state = loaderFailed |
| 293 | return err |
| 294 | } |
| 295 | } |
| 296 | if pl, ok := pl.(plugin.PluginFx); ok { |
| 297 | err := injectFxPlugin(pl) |
| 298 | if err != nil { |
| 299 | loader.state = loaderFailed |
| 300 | return err |
| 301 | } |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | return loader.transition(loaderInjecting, loaderInjected) |
| 306 | } |
| 307 | |
| 308 | // Start starts all long-running plugins. |
| 309 | func (loader *PluginLoader) Start(node *core.IpfsNode) error { |