node.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. // Copyright 2015 The go-ethereum Authors
  2. // This file is part of the go-ethereum library.
  3. //
  4. // The go-ethereum library is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Lesser General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // The go-ethereum library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
  16. package node
  17. import (
  18. "errors"
  19. "fmt"
  20. "net"
  21. "os"
  22. "path/filepath"
  23. "reflect"
  24. "strings"
  25. "sync"
  26. "syscall"
  27. "github.com/ethereum/go-ethereum/accounts"
  28. "github.com/ethereum/go-ethereum/ethdb"
  29. "github.com/ethereum/go-ethereum/event"
  30. "github.com/ethereum/go-ethereum/internal/debug"
  31. "github.com/ethereum/go-ethereum/log"
  32. "github.com/ethereum/go-ethereum/p2p"
  33. "github.com/ethereum/go-ethereum/rpc"
  34. "github.com/syndtr/goleveldb/leveldb/storage"
  35. )
  36. var (
  37. ErrDatadirUsed = errors.New("datadir already used")
  38. ErrNodeStopped = errors.New("node not started")
  39. ErrNodeRunning = errors.New("node already running")
  40. ErrServiceUnknown = errors.New("unknown service")
  41. datadirInUseErrnos = map[uint]bool{11: true, 32: true, 35: true}
  42. )
  43. // Node is a container on which services can be registered.
  44. type Node struct {
  45. eventmux *event.TypeMux // Event multiplexer used between the services of a stack
  46. config *Config
  47. accman *accounts.Manager
  48. ephemeralKeystore string // if non-empty, the key directory that will be removed by Stop
  49. instanceDirLock storage.Storage // prevents concurrent use of instance directory
  50. serverConfig p2p.Config
  51. server *p2p.Server // Currently running P2P networking layer
  52. serviceFuncs []ServiceConstructor // Service constructors (in dependency order)
  53. services map[reflect.Type]Service // Currently running services
  54. rpcAPIs []rpc.API // List of APIs currently provided by the node
  55. inprocHandler *rpc.Server // In-process RPC request handler to process the API requests
  56. ipcEndpoint string // IPC endpoint to listen at (empty = IPC disabled)
  57. ipcListener net.Listener // IPC RPC listener socket to serve API requests
  58. ipcHandler *rpc.Server // IPC RPC request handler to process the API requests
  59. httpEndpoint string // HTTP endpoint (interface + port) to listen at (empty = HTTP disabled)
  60. httpWhitelist []string // HTTP RPC modules to allow through this endpoint
  61. httpListener net.Listener // HTTP RPC listener socket to server API requests
  62. httpHandler *rpc.Server // HTTP RPC request handler to process the API requests
  63. wsEndpoint string // Websocket endpoint (interface + port) to listen at (empty = websocket disabled)
  64. wsListener net.Listener // Websocket RPC listener socket to server API requests
  65. wsHandler *rpc.Server // Websocket RPC request handler to process the API requests
  66. stop chan struct{} // Channel to wait for termination notifications
  67. lock sync.RWMutex
  68. }
  69. // New creates a new P2P node, ready for protocol registration.
  70. func New(conf *Config) (*Node, error) {
  71. // Copy config and resolve the datadir so future changes to the current
  72. // working directory don't affect the node.
  73. confCopy := *conf
  74. conf = &confCopy
  75. if conf.DataDir != "" {
  76. absdatadir, err := filepath.Abs(conf.DataDir)
  77. if err != nil {
  78. return nil, err
  79. }
  80. conf.DataDir = absdatadir
  81. }
  82. // Ensure that the instance name doesn't cause weird conflicts with
  83. // other files in the data directory.
  84. if strings.ContainsAny(conf.Name, `/\`) {
  85. return nil, errors.New(`Config.Name must not contain '/' or '\'`)
  86. }
  87. if conf.Name == datadirDefaultKeyStore {
  88. return nil, errors.New(`Config.Name cannot be "` + datadirDefaultKeyStore + `"`)
  89. }
  90. if strings.HasSuffix(conf.Name, ".ipc") {
  91. return nil, errors.New(`Config.Name cannot end in ".ipc"`)
  92. }
  93. // Ensure that the AccountManager method works before the node has started.
  94. // We rely on this in cmd/geth.
  95. am, ephemeralKeystore, err := makeAccountManager(conf)
  96. if err != nil {
  97. return nil, err
  98. }
  99. // Note: any interaction with Config that would create/touch files
  100. // in the data directory or instance directory is delayed until Start.
  101. return &Node{
  102. accman: am,
  103. ephemeralKeystore: ephemeralKeystore,
  104. config: conf,
  105. serviceFuncs: []ServiceConstructor{},
  106. ipcEndpoint: conf.IPCEndpoint(),
  107. httpEndpoint: conf.HTTPEndpoint(),
  108. wsEndpoint: conf.WSEndpoint(),
  109. eventmux: new(event.TypeMux),
  110. }, nil
  111. }
  112. // Register injects a new service into the node's stack. The service created by
  113. // the passed constructor must be unique in its type with regard to sibling ones.
  114. func (n *Node) Register(constructor ServiceConstructor) error {
  115. n.lock.Lock()
  116. defer n.lock.Unlock()
  117. if n.server != nil {
  118. return ErrNodeRunning
  119. }
  120. n.serviceFuncs = append(n.serviceFuncs, constructor)
  121. return nil
  122. }
  123. // Start create a live P2P node and starts running it.
  124. func (n *Node) Start() error {
  125. n.lock.Lock()
  126. defer n.lock.Unlock()
  127. // Short circuit if the node's already running
  128. if n.server != nil {
  129. return ErrNodeRunning
  130. }
  131. if err := n.openDataDir(); err != nil {
  132. return err
  133. }
  134. // Initialize the p2p server. This creates the node key and
  135. // discovery databases.
  136. n.serverConfig = n.config.P2P
  137. n.serverConfig.PrivateKey = n.config.NodeKey()
  138. n.serverConfig.Name = n.config.NodeName()
  139. if n.serverConfig.StaticNodes == nil {
  140. n.serverConfig.StaticNodes = n.config.StaticNodes()
  141. }
  142. if n.serverConfig.TrustedNodes == nil {
  143. n.serverConfig.TrustedNodes = n.config.TrusterNodes()
  144. }
  145. if n.serverConfig.NodeDatabase == "" {
  146. n.serverConfig.NodeDatabase = n.config.NodeDB()
  147. }
  148. running := &p2p.Server{Config: n.serverConfig}
  149. log.Info("Starting peer-to-peer node", "instance", n.serverConfig.Name)
  150. // Otherwise copy and specialize the P2P configuration
  151. services := make(map[reflect.Type]Service)
  152. for _, constructor := range n.serviceFuncs {
  153. // Create a new context for the particular service
  154. ctx := &ServiceContext{
  155. config: n.config,
  156. services: make(map[reflect.Type]Service),
  157. EventMux: n.eventmux,
  158. AccountManager: n.accman,
  159. }
  160. for kind, s := range services { // copy needed for threaded access
  161. ctx.services[kind] = s
  162. }
  163. // Construct and save the service
  164. service, err := constructor(ctx)
  165. if err != nil {
  166. return err
  167. }
  168. kind := reflect.TypeOf(service)
  169. if _, exists := services[kind]; exists {
  170. return &DuplicateServiceError{Kind: kind}
  171. }
  172. services[kind] = service
  173. }
  174. // Gather the protocols and start the freshly assembled P2P server
  175. for _, service := range services {
  176. running.Protocols = append(running.Protocols, service.Protocols()...)
  177. }
  178. if err := running.Start(); err != nil {
  179. if errno, ok := err.(syscall.Errno); ok && datadirInUseErrnos[uint(errno)] {
  180. return ErrDatadirUsed
  181. }
  182. return err
  183. }
  184. // Start each of the services
  185. started := []reflect.Type{}
  186. for kind, service := range services {
  187. // Start the next service, stopping all previous upon failure
  188. if err := service.Start(running); err != nil {
  189. for _, kind := range started {
  190. services[kind].Stop()
  191. }
  192. running.Stop()
  193. return err
  194. }
  195. // Mark the service started for potential cleanup
  196. started = append(started, kind)
  197. }
  198. // Lastly start the configured RPC interfaces
  199. if err := n.startRPC(services); err != nil {
  200. for _, service := range services {
  201. service.Stop()
  202. }
  203. running.Stop()
  204. return err
  205. }
  206. // Finish initializing the startup
  207. n.services = services
  208. n.server = running
  209. n.stop = make(chan struct{})
  210. return nil
  211. }
  212. func (n *Node) openDataDir() error {
  213. if n.config.DataDir == "" {
  214. return nil // ephemeral
  215. }
  216. instdir := filepath.Join(n.config.DataDir, n.config.name())
  217. if err := os.MkdirAll(instdir, 0700); err != nil {
  218. return err
  219. }
  220. // Try to open the instance directory as LevelDB storage. This creates a lock file
  221. // which prevents concurrent use by another instance as well as accidental use of the
  222. // instance directory as a database.
  223. storage, err := storage.OpenFile(instdir, true)
  224. if err != nil {
  225. return err
  226. }
  227. n.instanceDirLock = storage
  228. return nil
  229. }
  230. // startRPC is a helper method to start all the various RPC endpoint during node
  231. // startup. It's not meant to be called at any time afterwards as it makes certain
  232. // assumptions about the state of the node.
  233. func (n *Node) startRPC(services map[reflect.Type]Service) error {
  234. // Gather all the possible APIs to surface
  235. apis := n.apis()
  236. for _, service := range services {
  237. apis = append(apis, service.APIs()...)
  238. }
  239. // Start the various API endpoints, terminating all in case of errors
  240. if err := n.startInProc(apis); err != nil {
  241. return err
  242. }
  243. if err := n.startIPC(apis); err != nil {
  244. n.stopInProc()
  245. return err
  246. }
  247. if err := n.startHTTP(n.httpEndpoint, apis, n.config.HTTPModules, n.config.HTTPCors); err != nil {
  248. n.stopIPC()
  249. n.stopInProc()
  250. return err
  251. }
  252. if err := n.startWS(n.wsEndpoint, apis, n.config.WSModules, n.config.WSOrigins); err != nil {
  253. n.stopHTTP()
  254. n.stopIPC()
  255. n.stopInProc()
  256. return err
  257. }
  258. // All API endpoints started successfully
  259. n.rpcAPIs = apis
  260. return nil
  261. }
  262. // startInProc initializes an in-process RPC endpoint.
  263. func (n *Node) startInProc(apis []rpc.API) error {
  264. // Register all the APIs exposed by the services
  265. handler := rpc.NewServer()
  266. for _, api := range apis {
  267. if err := handler.RegisterName(api.Namespace, api.Service); err != nil {
  268. return err
  269. }
  270. log.Debug(fmt.Sprintf("InProc registered %T under '%s'", api.Service, api.Namespace))
  271. }
  272. n.inprocHandler = handler
  273. return nil
  274. }
  275. // stopInProc terminates the in-process RPC endpoint.
  276. func (n *Node) stopInProc() {
  277. if n.inprocHandler != nil {
  278. n.inprocHandler.Stop()
  279. n.inprocHandler = nil
  280. }
  281. }
  282. // startIPC initializes and starts the IPC RPC endpoint.
  283. func (n *Node) startIPC(apis []rpc.API) error {
  284. // Short circuit if the IPC endpoint isn't being exposed
  285. if n.ipcEndpoint == "" {
  286. return nil
  287. }
  288. // Register all the APIs exposed by the services
  289. handler := rpc.NewServer()
  290. for _, api := range apis {
  291. if err := handler.RegisterName(api.Namespace, api.Service); err != nil {
  292. return err
  293. }
  294. log.Debug(fmt.Sprintf("IPC registered %T under '%s'", api.Service, api.Namespace))
  295. }
  296. // All APIs registered, start the IPC listener
  297. var (
  298. listener net.Listener
  299. err error
  300. )
  301. if listener, err = rpc.CreateIPCListener(n.ipcEndpoint); err != nil {
  302. return err
  303. }
  304. go func() {
  305. log.Info(fmt.Sprintf("IPC endpoint opened: %s", n.ipcEndpoint))
  306. for {
  307. conn, err := listener.Accept()
  308. if err != nil {
  309. // Terminate if the listener was closed
  310. n.lock.RLock()
  311. closed := n.ipcListener == nil
  312. n.lock.RUnlock()
  313. if closed {
  314. return
  315. }
  316. // Not closed, just some error; report and continue
  317. log.Error(fmt.Sprintf("IPC accept failed: %v", err))
  318. continue
  319. }
  320. go handler.ServeCodec(rpc.NewJSONCodec(conn), rpc.OptionMethodInvocation|rpc.OptionSubscriptions)
  321. }
  322. }()
  323. // All listeners booted successfully
  324. n.ipcListener = listener
  325. n.ipcHandler = handler
  326. return nil
  327. }
  328. // stopIPC terminates the IPC RPC endpoint.
  329. func (n *Node) stopIPC() {
  330. if n.ipcListener != nil {
  331. n.ipcListener.Close()
  332. n.ipcListener = nil
  333. log.Info(fmt.Sprintf("IPC endpoint closed: %s", n.ipcEndpoint))
  334. }
  335. if n.ipcHandler != nil {
  336. n.ipcHandler.Stop()
  337. n.ipcHandler = nil
  338. }
  339. }
  340. // startHTTP initializes and starts the HTTP RPC endpoint.
  341. func (n *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, cors []string) error {
  342. // Short circuit if the HTTP endpoint isn't being exposed
  343. if endpoint == "" {
  344. return nil
  345. }
  346. // Generate the whitelist based on the allowed modules
  347. whitelist := make(map[string]bool)
  348. for _, module := range modules {
  349. whitelist[module] = true
  350. }
  351. // Register all the APIs exposed by the services
  352. handler := rpc.NewServer()
  353. for _, api := range apis {
  354. if whitelist[api.Namespace] || (len(whitelist) == 0 && api.Public) {
  355. if err := handler.RegisterName(api.Namespace, api.Service); err != nil {
  356. return err
  357. }
  358. log.Debug(fmt.Sprintf("HTTP registered %T under '%s'", api.Service, api.Namespace))
  359. }
  360. }
  361. // All APIs registered, start the HTTP listener
  362. var (
  363. listener net.Listener
  364. err error
  365. )
  366. if listener, err = net.Listen("tcp", endpoint); err != nil {
  367. return err
  368. }
  369. go rpc.NewHTTPServer(cors, handler).Serve(listener)
  370. log.Info(fmt.Sprintf("HTTP endpoint opened: http://%s", endpoint))
  371. // All listeners booted successfully
  372. n.httpEndpoint = endpoint
  373. n.httpListener = listener
  374. n.httpHandler = handler
  375. return nil
  376. }
  377. // stopHTTP terminates the HTTP RPC endpoint.
  378. func (n *Node) stopHTTP() {
  379. if n.httpListener != nil {
  380. n.httpListener.Close()
  381. n.httpListener = nil
  382. log.Info(fmt.Sprintf("HTTP endpoint closed: http://%s", n.httpEndpoint))
  383. }
  384. if n.httpHandler != nil {
  385. n.httpHandler.Stop()
  386. n.httpHandler = nil
  387. }
  388. }
  389. // startWS initializes and starts the websocket RPC endpoint.
  390. func (n *Node) startWS(endpoint string, apis []rpc.API, modules []string, wsOrigins []string) error {
  391. // Short circuit if the WS endpoint isn't being exposed
  392. if endpoint == "" {
  393. return nil
  394. }
  395. // Generate the whitelist based on the allowed modules
  396. whitelist := make(map[string]bool)
  397. for _, module := range modules {
  398. whitelist[module] = true
  399. }
  400. // Register all the APIs exposed by the services
  401. handler := rpc.NewServer()
  402. for _, api := range apis {
  403. if whitelist[api.Namespace] || (len(whitelist) == 0 && api.Public) {
  404. if err := handler.RegisterName(api.Namespace, api.Service); err != nil {
  405. return err
  406. }
  407. log.Debug(fmt.Sprintf("WebSocket registered %T under '%s'", api.Service, api.Namespace))
  408. }
  409. }
  410. // All APIs registered, start the HTTP listener
  411. var (
  412. listener net.Listener
  413. err error
  414. )
  415. if listener, err = net.Listen("tcp", endpoint); err != nil {
  416. return err
  417. }
  418. go rpc.NewWSServer(wsOrigins, handler).Serve(listener)
  419. log.Info(fmt.Sprintf("WebSocket endpoint opened: ws://%s", endpoint))
  420. // All listeners booted successfully
  421. n.wsEndpoint = endpoint
  422. n.wsListener = listener
  423. n.wsHandler = handler
  424. return nil
  425. }
  426. // stopWS terminates the websocket RPC endpoint.
  427. func (n *Node) stopWS() {
  428. if n.wsListener != nil {
  429. n.wsListener.Close()
  430. n.wsListener = nil
  431. log.Info(fmt.Sprintf("WebSocket endpoint closed: ws://%s", n.wsEndpoint))
  432. }
  433. if n.wsHandler != nil {
  434. n.wsHandler.Stop()
  435. n.wsHandler = nil
  436. }
  437. }
  438. // Stop terminates a running node along with all it's services. In the node was
  439. // not started, an error is returned.
  440. func (n *Node) Stop() error {
  441. n.lock.Lock()
  442. defer n.lock.Unlock()
  443. // Short circuit if the node's not running
  444. if n.server == nil {
  445. return ErrNodeStopped
  446. }
  447. // Terminate the API, services and the p2p server.
  448. n.stopWS()
  449. n.stopHTTP()
  450. n.stopIPC()
  451. n.rpcAPIs = nil
  452. failure := &StopError{
  453. Services: make(map[reflect.Type]error),
  454. }
  455. for kind, service := range n.services {
  456. if err := service.Stop(); err != nil {
  457. failure.Services[kind] = err
  458. }
  459. }
  460. n.server.Stop()
  461. n.services = nil
  462. n.server = nil
  463. // Release instance directory lock.
  464. if n.instanceDirLock != nil {
  465. n.instanceDirLock.Close()
  466. n.instanceDirLock = nil
  467. }
  468. // unblock n.Wait
  469. close(n.stop)
  470. // Remove the keystore if it was created ephemerally.
  471. var keystoreErr error
  472. if n.ephemeralKeystore != "" {
  473. keystoreErr = os.RemoveAll(n.ephemeralKeystore)
  474. }
  475. if len(failure.Services) > 0 {
  476. return failure
  477. }
  478. if keystoreErr != nil {
  479. return keystoreErr
  480. }
  481. return nil
  482. }
  483. // Wait blocks the thread until the node is stopped. If the node is not running
  484. // at the time of invocation, the method immediately returns.
  485. func (n *Node) Wait() {
  486. n.lock.RLock()
  487. if n.server == nil {
  488. n.lock.RUnlock()
  489. return
  490. }
  491. stop := n.stop
  492. n.lock.RUnlock()
  493. <-stop
  494. }
  495. // Restart terminates a running node and boots up a new one in its place. If the
  496. // node isn't running, an error is returned.
  497. func (n *Node) Restart() error {
  498. if err := n.Stop(); err != nil {
  499. return err
  500. }
  501. if err := n.Start(); err != nil {
  502. return err
  503. }
  504. return nil
  505. }
  506. // Attach creates an RPC client attached to an in-process API handler.
  507. func (n *Node) Attach() (*rpc.Client, error) {
  508. n.lock.RLock()
  509. defer n.lock.RUnlock()
  510. if n.server == nil {
  511. return nil, ErrNodeStopped
  512. }
  513. return rpc.DialInProc(n.inprocHandler), nil
  514. }
  515. // Server retrieves the currently running P2P network layer. This method is meant
  516. // only to inspect fields of the currently running server, life cycle management
  517. // should be left to this Node entity.
  518. func (n *Node) Server() *p2p.Server {
  519. n.lock.RLock()
  520. defer n.lock.RUnlock()
  521. return n.server
  522. }
  523. // Service retrieves a currently running service registered of a specific type.
  524. func (n *Node) Service(service interface{}) error {
  525. n.lock.RLock()
  526. defer n.lock.RUnlock()
  527. // Short circuit if the node's not running
  528. if n.server == nil {
  529. return ErrNodeStopped
  530. }
  531. // Otherwise try to find the service to return
  532. element := reflect.ValueOf(service).Elem()
  533. if running, ok := n.services[element.Type()]; ok {
  534. element.Set(reflect.ValueOf(running))
  535. return nil
  536. }
  537. return ErrServiceUnknown
  538. }
  539. // DataDir retrieves the current datadir used by the protocol stack.
  540. // Deprecated: No files should be stored in this directory, use InstanceDir instead.
  541. func (n *Node) DataDir() string {
  542. return n.config.DataDir
  543. }
  544. // InstanceDir retrieves the instance directory used by the protocol stack.
  545. func (n *Node) InstanceDir() string {
  546. return n.config.instanceDir()
  547. }
  548. // AccountManager retrieves the account manager used by the protocol stack.
  549. func (n *Node) AccountManager() *accounts.Manager {
  550. return n.accman
  551. }
  552. // IPCEndpoint retrieves the current IPC endpoint used by the protocol stack.
  553. func (n *Node) IPCEndpoint() string {
  554. return n.ipcEndpoint
  555. }
  556. // HTTPEndpoint retrieves the current HTTP endpoint used by the protocol stack.
  557. func (n *Node) HTTPEndpoint() string {
  558. return n.httpEndpoint
  559. }
  560. // WSEndpoint retrieves the current WS endpoint used by the protocol stack.
  561. func (n *Node) WSEndpoint() string {
  562. return n.wsEndpoint
  563. }
  564. // EventMux retrieves the event multiplexer used by all the network services in
  565. // the current protocol stack.
  566. func (n *Node) EventMux() *event.TypeMux {
  567. return n.eventmux
  568. }
  569. // OpenDatabase opens an existing database with the given name (or creates one if no
  570. // previous can be found) from within the node's instance directory. If the node is
  571. // ephemeral, a memory database is returned.
  572. func (n *Node) OpenDatabase(name string, cache, handles int) (ethdb.Database, error) {
  573. if n.config.DataDir == "" {
  574. return ethdb.NewMemDatabase()
  575. }
  576. return ethdb.NewLDBDatabase(n.config.resolvePath(name), cache, handles)
  577. }
  578. // ResolvePath returns the absolute path of a resource in the instance directory.
  579. func (n *Node) ResolvePath(x string) string {
  580. return n.config.resolvePath(x)
  581. }
  582. // apis returns the collection of RPC descriptors this node offers.
  583. func (n *Node) apis() []rpc.API {
  584. return []rpc.API{
  585. {
  586. Namespace: "admin",
  587. Version: "1.0",
  588. Service: NewPrivateAdminAPI(n),
  589. }, {
  590. Namespace: "admin",
  591. Version: "1.0",
  592. Service: NewPublicAdminAPI(n),
  593. Public: true,
  594. }, {
  595. Namespace: "debug",
  596. Version: "1.0",
  597. Service: debug.Handler,
  598. }, {
  599. Namespace: "debug",
  600. Version: "1.0",
  601. Service: NewPublicDebugAPI(n),
  602. Public: true,
  603. }, {
  604. Namespace: "web3",
  605. Version: "1.0",
  606. Service: NewPublicWeb3API(n),
  607. Public: true,
  608. },
  609. }
  610. }