Merge PR #7191: Fix Legacy API Server Client Context

This commit is contained in:
Alexander Bezobchuk 2020-08-28 13:25:10 -04:00 committed by GitHub
parent f652ba4288
commit 4de5e28a3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 6 deletions

View File

@ -117,6 +117,7 @@ func (s *Server) Start(cfg config.Config) error {
return tmrpcserver.Serve(s.listener, allowAllCORS(h), s.logger, tmCfg) return tmrpcserver.Serve(s.listener, allowAllCORS(h), s.logger, tmCfg)
} }
s.logger.Info("starting API server...")
return tmrpcserver.Serve(s.listener, s.Router, s.logger, tmCfg) return tmrpcserver.Serve(s.listener, s.Router, s.logger, tmCfg)
} }

View File

@ -21,7 +21,6 @@ import (
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server/api" "github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config" "github.com/cosmos/cosmos-sdk/server/config"
servergrpc "github.com/cosmos/cosmos-sdk/server/grpc" servergrpc "github.com/cosmos/cosmos-sdk/server/grpc"
@ -108,7 +107,7 @@ which accepts a path for the resulting pprof file.
serverCtx.Logger.Info("starting ABCI with Tendermint") serverCtx.Logger.Info("starting ABCI with Tendermint")
// amino is needed here for backwards compatibility of REST routes // amino is needed here for backwards compatibility of REST routes
err := startInProcess(serverCtx, clientCtx.LegacyAmino, appCreator) err := startInProcess(serverCtx, clientCtx, appCreator)
return err return err
}, },
} }
@ -180,7 +179,7 @@ func startStandAlone(ctx *Context, appCreator types.AppCreator) error {
} }
// legacyAminoCdc is used for the legacy REST API // legacyAminoCdc is used for the legacy REST API
func startInProcess(ctx *Context, legacyAminoCdc *codec.LegacyAmino, appCreator types.AppCreator) error { func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.AppCreator) error {
cfg := ctx.Config cfg := ctx.Config
home := cfg.RootDir home := cfg.RootDir
@ -230,11 +229,9 @@ func startInProcess(ctx *Context, legacyAminoCdc *codec.LegacyAmino, appCreator
return err return err
} }
clientCtx := client.Context{}. clientCtx := clientCtx.
WithHomeDir(home). WithHomeDir(home).
WithChainID(genDoc.ChainID). WithChainID(genDoc.ChainID).
// amino is needed here for backwards compatibility of REST routes
WithLegacyAmino(legacyAminoCdc).
WithClient(local.New(tmNode)) WithClient(local.New(tmNode))
apiSrv = api.New(clientCtx, ctx.Logger.With("module", "api-server")) apiSrv = api.New(clientCtx, ctx.Logger.With("module", "api-server"))