mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
rpc: refactor for concision
Signed-off-by: meows <b5c6@protonmail.com>
This commit is contained in:
parent
ddaee90378
commit
fb6453db1d
1 changed files with 13 additions and 17 deletions
|
|
@ -28,29 +28,25 @@ import (
|
||||||
// then log.Crit is used to cause program to exit, logging the invalid module and a list of available
|
// then log.Crit is used to cause program to exit, logging the invalid module and a list of available
|
||||||
// API service names.
|
// API service names.
|
||||||
func mustAvailableModule(module string, apis []API) {
|
func mustAvailableModule(module string, apis []API) {
|
||||||
apiExists := false
|
|
||||||
for _, api := range apis {
|
for _, api := range apis {
|
||||||
if module == api.Namespace {
|
if module == api.Namespace {
|
||||||
apiExists = true
|
return
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !apiExists {
|
log.Crit("invalid api module", "module", module, "available", func() string {
|
||||||
log.Crit("invalid api module", "module", module, "available", func() string {
|
available := []string{}
|
||||||
available := []string{}
|
outer:
|
||||||
outer:
|
for _, api := range apis {
|
||||||
for _, api := range apis {
|
// Only include unique api names
|
||||||
// Only include unique api names
|
for _, av := range available {
|
||||||
for _, av := range available {
|
if av == api.Namespace {
|
||||||
if av == api.Namespace {
|
continue outer
|
||||||
continue outer
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
available = append(available, api.Namespace)
|
|
||||||
}
|
}
|
||||||
return strings.Join(available, ",")
|
available = append(available, api.Namespace)
|
||||||
}())
|
}
|
||||||
}
|
return strings.Join(available, ",")
|
||||||
|
}())
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartHTTPEndpoint starts the HTTP RPC endpoint, configured with cors/vhosts/modules
|
// StartHTTPEndpoint starts the HTTP RPC endpoint, configured with cors/vhosts/modules
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue