add prometheus-middlewares for http and ws endpoint

This commit is contained in:
Ilnur Galiev
2020-10-19 18:00:55 +03:00
parent 1043df9156
commit f627c2edfa
7 changed files with 261 additions and 5 deletions
+21
View File
@@ -0,0 +1,21 @@
package rpc
import "github.com/ethereum/go-ethereum/rpc"
// checkModuleAvailability check that all names given in modules are actually
// available API services.
func checkModuleAvailability(modules []string, apis []rpc.API) (bad, available []string) {
availableSet := make(map[string]struct{})
for _, api := range apis {
if _, ok := availableSet[api.Namespace]; !ok {
availableSet[api.Namespace] = struct{}{}
available = append(available, api.Namespace)
}
}
for _, name := range modules {
if _, ok := availableSet[name]; !ok {
bad = append(bad, name)
}
}
return bad, available
}