Periodic bootstrap
This commit is contained in:
+4
-25
@@ -94,37 +94,16 @@ var DaemonCmd = &cli.Command{
|
||||
}
|
||||
return lr.SetAPIEndpoint(apima)
|
||||
}),
|
||||
|
||||
node.ApplyIf(func(s *node.Settings) bool { return cctx.Bool("bootstrap") },
|
||||
node.Override(node.BootstrapKey, modules.Bootstrap),
|
||||
),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
go func() {
|
||||
if !cctx.Bool("bootstrap") {
|
||||
return
|
||||
}
|
||||
err := bootstrap(ctx, api)
|
||||
if err != nil {
|
||||
log.Error("Bootstrap failed: ", err)
|
||||
}
|
||||
}()
|
||||
|
||||
// TODO: properly parse api endpoint (or make it a URL)
|
||||
return serveRPC(api, stop, "127.0.0.1:"+cctx.String("api"))
|
||||
},
|
||||
}
|
||||
|
||||
func bootstrap(ctx context.Context, api api.FullNode) error {
|
||||
pis, err := build.BuiltinBootstrap()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, pi := range pis {
|
||||
if err := api.NetConnect(ctx, pi); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user