diagnostics - added query for bootnodes (#8344)

This commit is contained in:
Dmytro 2023-10-03 06:28:21 +03:00 committed by GitHub
parent 3d6d2a7c25
commit ae88a69511
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 0 deletions

25
diagnostics/bootnodes.go Normal file
View File

@ -0,0 +1,25 @@
package diagnostics
import (
"encoding/json"
"net/http"
"github.com/ledgerwatch/erigon/turbo/node"
)
func SetupBootnodesAccess(metricsMux *http.ServeMux, node *node.ErigonNode) {
metricsMux.HandleFunc("/bootnodes", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Content-Type", "application/json")
bootnodes := node.Node().Config().P2P.BootstrapNodesV5
btNodes := make([]string, 0, len(bootnodes))
for _, bootnode := range bootnodes {
btNodes = append(btNodes, bootnode.String())
}
json.NewEncoder(w).Encode(btNodes)
})
}

View File

@ -26,5 +26,6 @@ func Setup(ctx *cli.Context, metricsMux *http.ServeMux, node *node.ErigonNode) {
SetupHeaderDownloadStats(debugMux)
SetupNodeInfoAccess(debugMux, node)
SetupPeersAccess(ctx, debugMux, node)
SetupBootnodesAccess(debugMux, node)
}

View File

@ -38,6 +38,10 @@ func (eri *ErigonNode) Backend() *eth.Ethereum {
return eri.backend
}
func (eri *ErigonNode) Node() *node.Node {
return eri.stack
}
func (eri *ErigonNode) Close() {
eri.stack.Close()
}