Periodic bootstrap

This commit is contained in:
Łukasz Magiera
2019-10-11 02:31:26 +02:00
parent fef544f88e
commit c0179bd4fa
3 changed files with 56 additions and 28 deletions
+4 -25
View File
@@ -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
}