diff --git a/core/kernel.go b/core/kernel.go index f73125f64232d05e3cd0c18084c4c51ed4c6499e..316da522473efa8bbec83bd829360de26c40ab18 100644 --- a/core/kernel.go +++ b/core/kernel.go @@ -197,10 +197,10 @@ func NewKernel(ctx context.Context, keyClient keys.KeyClient, privValidator tmTy }, }, { - Name: "RPC/tm", - Enabled: rpcConfig.TM.Enabled, + Name: "RPC/info", + Enabled: rpcConfig.Info.Enabled, Launch: func() (process.Process, error) { - server, err := rpcinfo.StartServer(kern.Service, "/websocket", rpcConfig.TM.ListenAddress, kern.Logger) + server, err := rpcinfo.StartServer(kern.Service, "/websocket", rpcConfig.Info.ListenAddress, kern.Logger) if err != nil { return nil, err } diff --git a/integration/integration.go b/integration/integration.go index 7c136f8ad9648ef1901add2894c48f599c5385da..883afde425dc66ea9e047267f500b2099ab59996 100644 --- a/integration/integration.go +++ b/integration/integration.go @@ -170,7 +170,7 @@ func NewTestConfig(genesisDoc *genesis.GenesisDoc) *config.BurrowConfig { cnf.Tendermint.ExternalAddress = cnf.Tendermint.ListenAddress cnf.RPC.GRPC.ListenAddress = GetLocalAddress() cnf.RPC.Metrics.ListenAddress = GetTCPLocalAddress() - cnf.RPC.TM.ListenAddress = GetTCPLocalAddress() + cnf.RPC.Info.ListenAddress = GetTCPLocalAddress() cnf.Keys.RemoteAddress = "" return cnf } diff --git a/integration/rpcinfo/main_test.go b/integration/rpcinfo/main_test.go index 29f3f4749c79b13150830d69f0b10dab1b0fdfe9..dfd581c97302c84e644f9e46c76bb7ea26832d31 100644 --- a/integration/rpcinfo/main_test.go +++ b/integration/rpcinfo/main_test.go @@ -32,8 +32,8 @@ import ( var kern *core.Kernel var _ = integration.ClaimPorts() var testConfig = integration.NewTestConfig(rpctest.GenesisDoc) -var jsonRpcClient = rpcClient.NewJSONRPCClient(testConfig.RPC.TM.ListenAddress) -var httpClient = rpcClient.NewURIClient(testConfig.RPC.TM.ListenAddress) +var jsonRpcClient = rpcClient.NewJSONRPCClient(testConfig.RPC.Info.ListenAddress) +var httpClient = rpcClient.NewURIClient(testConfig.RPC.Info.ListenAddress) var clients = map[string]tmClient.RPCClient{ "JSONRPC": jsonRpcClient, "HTTP": httpClient, diff --git a/rpc/config.go b/rpc/config.go index 23bfbdbb763c48fae661f22ae9d686147866b45d..3763bb7985a9e92c617e4c4076c9f435c66ea4a8 100644 --- a/rpc/config.go +++ b/rpc/config.go @@ -7,7 +7,7 @@ import "fmt" const localhost = "127.0.0.1" type RPCConfig struct { - TM *ServerConfig `json:",omitempty" toml:",omitempty"` + Info *ServerConfig `json:",omitempty" toml:",omitempty"` Profiler *ServerConfig `json:",omitempty" toml:",omitempty"` GRPC *ServerConfig `json:",omitempty" toml:",omitempty"` Metrics *MetricsConfig `json:",omitempty" toml:",omitempty"` @@ -37,14 +37,14 @@ type MetricsConfig struct { func DefaultRPCConfig() *RPCConfig { return &RPCConfig{ - TM: DefaultTMConfig(), + Info: DefaultInfoConfig(), Profiler: DefaultProfilerConfig(), GRPC: DefaultGRPCConfig(), Metrics: DefaultMetricsConfig(), } } -func DefaultTMConfig() *ServerConfig { +func DefaultInfoConfig() *ServerConfig { return &ServerConfig{ Enabled: true, ListenAddress: fmt.Sprintf("tcp://%s:26658", localhost), diff --git a/rpc/metrics/export.go b/rpc/metrics/export.go index 2487a0f746ea56639c345c6070072f642282850d..2ea9d7b7ee80a773a0603f0f0086df7ff94ccf88 100644 --- a/rpc/metrics/export.go +++ b/rpc/metrics/export.go @@ -14,6 +14,7 @@ package metrics import ( + "fmt" "math" "github.com/hyperledger/burrow/rpc" @@ -107,6 +108,10 @@ func (e *Exporter) getBlocks() (*rpc.ResultBlocks, error) { return nil, err } + if !(len(res.BlockMetas) > 0) { + return nil, fmt.Errorf("no blocks returned") + } + return res, nil } diff --git a/rpc/metrics/server.go b/rpc/metrics/server.go index 5eab0754c58a243ebb9c6c1bda12515c3ebcc71f..b6dbe8b1280187e02e946a91b8f99211ee870384 100644 --- a/rpc/metrics/server.go +++ b/rpc/metrics/server.go @@ -71,7 +71,7 @@ func StartServer(service *rpc.Service, pattern, listenAddress string, blockSampl prometheus.MustRegister(&exporter) mux := http.NewServeMux() - mux.Handle(pattern, prometheus.Handler()) + mux.Handle(pattern, server.RecoverAndLogHandler(prometheus.Handler(), logger)) srv, err := server.StartHTTPServer(listenAddress, mux, logger) if err != nil { diff --git a/rpc/rpcinfo/info_server.go b/rpc/rpcinfo/info_server.go index ff500e1bb96a164fbc561ac782e57588bc6fc6fb..3f51321fb80820620dfa663cbfa42724b2e1141f 100644 --- a/rpc/rpcinfo/info_server.go +++ b/rpc/rpcinfo/info_server.go @@ -24,7 +24,7 @@ import ( ) func StartServer(service *rpc.Service, pattern, listenAddress string, logger *logging.Logger) (*http.Server, error) { - logger = logger.With(structure.ComponentKey, "RPC_TM") + logger = logger.With(structure.ComponentKey, "RPC_Info") routes := GetRoutes(service, logger) mux := http.NewServeMux() wm := server.NewWebsocketManager(routes, logger)