mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
dont overwrite registering apis
This commit is contained in:
parent
8adb2f2b1c
commit
74cd4f2fd0
2 changed files with 9 additions and 9 deletions
|
|
@ -372,7 +372,7 @@ func (n *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, cors
|
||||||
|
|
||||||
srv := rpc.NewServer()
|
srv := rpc.NewServer()
|
||||||
|
|
||||||
err := RegisterApisFromWhitelist(apis, modules, srv)
|
err := registerApisFromWhitelist(apis, modules, srv)
|
||||||
|
|
||||||
var ws http.Handler
|
var ws http.Handler
|
||||||
if n.httpEndpoint == n.wsEndpoint {
|
if n.httpEndpoint == n.wsEndpoint {
|
||||||
|
|
@ -697,7 +697,11 @@ func (n *Node) apis() []rpc.API {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterApisFromWhitelist(apis []rpc.API, modules []string, srv *rpc.Server) error {
|
func registerApisFromWhitelist(apis []rpc.API, modules []string, srv *rpc.Server) error {
|
||||||
|
if bad, available := rpc.CheckModuleAvailability(modules, apis); len(bad) > 0 {
|
||||||
|
log.Error("Unavailable modules in HTTP API list", "unavailable", bad, "available", available)
|
||||||
|
}
|
||||||
|
|
||||||
// Generate the whitelist based on the allowed modules
|
// Generate the whitelist based on the allowed modules
|
||||||
whitelist := make(map[string]bool)
|
whitelist := make(map[string]bool)
|
||||||
for _, module := range modules {
|
for _, module := range modules {
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,10 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// checkModuleAvailability checks that all names given in modules are actually
|
// CheckModuleAvailability checks that all names given in modules are actually
|
||||||
// available API services. It assumes that the MetadataApi module ("rpc") is always available;
|
// available API services. It assumes that the MetadataApi module ("rpc") is always available;
|
||||||
// the registration of this "rpc" module happens in NewServer() and is thus common to all endpoints.
|
// the registration of this "rpc" module happens in NewServer() and is thus common to all endpoints.
|
||||||
func checkModuleAvailability(modules []string, apis []API) (bad, available []string) {
|
func CheckModuleAvailability(modules []string, apis []API) (bad, available []string) {
|
||||||
availableSet := make(map[string]struct{})
|
availableSet := make(map[string]struct{})
|
||||||
for _, api := range apis {
|
for _, api := range apis {
|
||||||
if _, ok := availableSet[api.Namespace]; !ok {
|
if _, ok := availableSet[api.Namespace]; !ok {
|
||||||
|
|
@ -45,10 +45,6 @@ func checkModuleAvailability(modules []string, apis []API) (bad, available []str
|
||||||
|
|
||||||
// StartHTTPEndpoint starts the HTTP RPC endpoint, configured with cors/vhosts/modules.
|
// StartHTTPEndpoint starts the HTTP RPC endpoint, configured with cors/vhosts/modules.
|
||||||
func StartHTTPEndpoint(endpoint string, apis []API, modules []string, timeouts HTTPTimeouts, handler http.Handler) (net.Listener, error) {
|
func StartHTTPEndpoint(endpoint string, apis []API, modules []string, timeouts HTTPTimeouts, handler http.Handler) (net.Listener, error) {
|
||||||
if bad, available := checkModuleAvailability(modules, apis); len(bad) > 0 {
|
|
||||||
log.Error("Unavailable modules in HTTP API list", "unavailable", bad, "available", available)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start the HTTP listener
|
// Start the HTTP listener
|
||||||
var (
|
var (
|
||||||
listener net.Listener
|
listener net.Listener
|
||||||
|
|
@ -86,7 +82,7 @@ func StartHTTPEndpoint(endpoint string, apis []API, modules []string, timeouts H
|
||||||
|
|
||||||
// StartWSEndpoint starts a websocket endpoint.
|
// StartWSEndpoint starts a websocket endpoint.
|
||||||
func StartWSEndpoint(endpoint string, apis []API, modules []string, wsOrigins []string, exposeAll bool) (net.Listener, *Server, error) {
|
func StartWSEndpoint(endpoint string, apis []API, modules []string, wsOrigins []string, exposeAll bool) (net.Listener, *Server, error) {
|
||||||
if bad, available := checkModuleAvailability(modules, apis); len(bad) > 0 {
|
if bad, available := CheckModuleAvailability(modules, apis); len(bad) > 0 {
|
||||||
log.Error("Unavailable modules in WS API list", "unavailable", bad, "available", available)
|
log.Error("Unavailable modules in WS API list", "unavailable", bad, "available", available)
|
||||||
}
|
}
|
||||||
// Generate the whitelist based on the allowed modules
|
// Generate the whitelist based on the allowed modules
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue