Merge PR #2919: Refactor Gaia Lite bootstrapping

* Refactor Gaia Lite bootstrapping
* Update examples
* Add pending log entry
This commit is contained in:
Christopher Goes 2018-11-28 00:07:28 +01:00 committed by GitHub
commit 6a74cd0920
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 22 deletions

View File

@ -87,7 +87,8 @@ IMPROVEMENTS
BUG FIXES
* Gaia REST API (`gaiacli advanced rest-server`)
- [gaia-lite] #2868 Added handler for governance tally endpoit
- [gaia-lite] #2868 Added handler for governance tally endpoint
* #2907 Refactor and fix the way Gaia Lite is started.
* Gaia CLI (`gaiacli`)

View File

@ -145,15 +145,19 @@ func (rs *RestServer) Start(listenAddr string, sslHosts string,
return nil
}
// ServeCommand will generate a long-running rest server
// (aka Light Client Daemon) that exposes functionality similar
// to the cli, but over rest
func (rs *RestServer) ServeCommand() *cobra.Command {
// ServeCommand will start a Gaia Lite REST service as a blocking process. It
// takes a codec to create a RestServer object and a function to register all
// necessary routes.
func ServeCommand(cdc *codec.Codec, registerRoutesFn func(*RestServer)) *cobra.Command {
cmd := &cobra.Command{
Use: "rest-server",
Short: "Start LCD (light-client daemon), a local REST server",
RunE: func(cmd *cobra.Command, args []string) (err error) {
rs := NewRestServer(cdc)
rs.setKeybase(nil)
registerRoutesFn(rs)
// Start the rest server and return error if one exists
err = rs.Start(
viper.GetString(client.FlagListenAddr),

View File

@ -60,12 +60,6 @@ func main() {
config.SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub)
config.Seal()
// Create a new RestServer instance to serve the light client routes
rs := lcd.NewRestServer(cdc)
// registerRoutes registers the routes on the rest server
registerRoutes(rs)
// TODO: setup keybase, viper object, etc. to be passed into
// the below functions and eliminate global vars, like we do
// with the cdc
@ -92,7 +86,7 @@ func main() {
queryCmd(cdc, mc),
txCmd(cdc, mc),
client.LineBreak,
rs.ServeCommand(),
lcd.ServeCommand(cdc, registerRoutes),
client.LineBreak,
keys.Commands(),
client.LineBreak,

View File

@ -52,10 +52,6 @@ func main() {
config.SetBech32PrefixForConsensusNode("basecons", "baseconspub")
config.Seal()
rs := lcd.NewRestServer(cdc)
registerRoutes(rs)
// TODO: Setup keybase, viper object, etc. to be passed into
// the below functions and eliminate global vars, like we do
// with the cdc.
@ -104,7 +100,7 @@ func main() {
// add proxy, version and key info
rootCmd.AddCommand(
client.LineBreak,
rs.ServeCommand(),
lcd.ServeCommand(cdc, registerRoutes),
keys.Commands(),
client.LineBreak,
version.VersionCmd,

View File

@ -48,10 +48,6 @@ func main() {
config.SetBech32PrefixForConsensusNode("democons", "democonspub")
config.Seal()
rs := lcd.NewRestServer(cdc)
registerRoutes(rs)
// TODO: setup keybase, viper object, etc. to be passed into
// the below functions and eliminate global vars, like we do
// with the cdc
@ -94,7 +90,7 @@ func main() {
// add proxy, version and key info
rootCmd.AddCommand(
client.LineBreak,
rs.ServeCommand(),
lcd.ServeCommand(cdc, registerRoutes),
keys.Commands(),
client.LineBreak,
version.VersionCmd,