node.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  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. "net"
  20. "os"
  21. "path/filepath"
  22. "reflect"
  23. "strings"
  24. "sync"
  25. "syscall"
  26. "github.com/ethereum/go-ethereum/accounts"
  27. "github.com/ethereum/go-ethereum/ethdb"
  28. "github.com/ethereum/go-ethereum/event"
  29. "github.com/ethereum/go-ethereum/internal/debug"
  30. "github.com/ethereum/go-ethereum/logger"
  31. "github.com/ethereum/go-ethereum/logger/glog"
  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 = p2p.Config{
  137. PrivateKey: n.config.NodeKey(),
  138. Name: n.config.NodeName(),
  139. Discovery: !n.config.NoDiscovery,
  140. BootstrapNodes: n.config.BootstrapNodes,
  141. StaticNodes: n.config.StaticNodes(),
  142. TrustedNodes: n.config.TrusterNodes(),
  143. NodeDatabase: n.config.NodeDB(),
  144. ListenAddr: n.config.ListenAddr,
  145. NAT: n.config.NAT,
  146. Dialer: n.config.Dialer,
  147. NoDial: n.config.NoDial,
  148. MaxPeers: n.config.MaxPeers,
  149. MaxPendingPeers: n.config.MaxPendingPeers,
  150. }
  151. running := &p2p.Server{Config: n.serverConfig}
  152. glog.V(logger.Info).Infoln("instance:", n.serverConfig.Name)
  153. // Otherwise copy and specialize the P2P configuration
  154. services := make(map[reflect.Type]Service)
  155. for _, constructor := range n.serviceFuncs {
  156. // Create a new context for the particular service
  157. ctx := &ServiceContext{
  158. config: n.config,
  159. services: make(map[reflect.Type]Service),
  160. EventMux: n.eventmux,
  161. AccountManager: n.accman,
  162. }
  163. for kind, s := range services { // copy needed for threaded access
  164. ctx.services[kind] = s
  165. }
  166. // Construct and save the service
  167. service, err := constructor(ctx)
  168. if err != nil {
  169. return err
  170. }
  171. kind := reflect.TypeOf(service)
  172. if _, exists := services[kind]; exists {
  173. return &DuplicateServiceError{Kind: kind}
  174. }
  175. services[kind] = service
  176. }
  177. // Gather the protocols and start the freshly assembled P2P server
  178. for _, service := range services {
  179. running.Protocols = append(running.Protocols, service.Protocols()...)
  180. }
  181. if err := running.Start(); err != nil {
  182. if errno, ok := err.(syscall.Errno); ok && datadirInUseErrnos[uint(errno)] {
  183. return ErrDatadirUsed
  184. }
  185. return err
  186. }
  187. // Start each of the services
  188. started := []reflect.Type{}
  189. for kind, service := range services {
  190. // Start the next service, stopping all previous upon failure
  191. if err := service.Start(running); err != nil {
  192. for _, kind := range started {
  193. services[kind].Stop()
  194. }
  195. running.Stop()
  196. return err
  197. }
  198. // Mark the service started for potential cleanup
  199. started = append(started, kind)
  200. }
  201. // Lastly start the configured RPC interfaces
  202. if err := n.startRPC(services); err != nil {
  203. for _, service := range services {
  204. service.Stop()
  205. }
  206. running.Stop()
  207. return err
  208. }
  209. // Finish initializing the startup
  210. n.services = services
  211. n.server = running
  212. n.stop = make(chan struct{})
  213. return nil
  214. }
  215. func (n *Node) openDataDir() error {
  216. if n.config.DataDir == "" {
  217. return nil // ephemeral
  218. }
  219. instdir := filepath.Join(n.config.DataDir, n.config.name())
  220. if err := os.MkdirAll(instdir, 0700); err != nil {
  221. return err
  222. }
  223. // Try to open the instance directory as LevelDB storage. This creates a lock file
  224. // which prevents concurrent use by another instance as well as accidental use of the
  225. // instance directory as a database.
  226. storage, err := storage.OpenFile(instdir, true)
  227. if err != nil {
  228. return err
  229. }
  230. n.instanceDirLock = storage
  231. return nil
  232. }
  233. // startRPC is a helper method to start all the various RPC endpoint during node
  234. // startup. It's not meant to be called at any time afterwards as it makes certain
  235. // assumptions about the state of the node.
  236. func (n *Node) startRPC(services map[reflect.Type]Service) error {
  237. // Gather all the possible APIs to surface
  238. apis := n.apis()
  239. for _, service := range services {
  240. apis = append(apis, service.APIs()...)
  241. }
  242. // Start the various API endpoints, terminating all in case of errors
  243. if err := n.startInProc(apis); err != nil {
  244. return err
  245. }
  246. if err := n.startIPC(apis); err != nil {
  247. n.stopInProc()
  248. return err
  249. }
  250. if err := n.startHTTP(n.httpEndpoint, apis, n.config.HTTPModules, n.config.HTTPCors); err != nil {
  251. n.stopIPC()
  252. n.stopInProc()
  253. return err
  254. }
  255. if err := n.startWS(n.wsEndpoint, apis, n.config.WSModules, n.config.WSOrigins); err != nil {
  256. n.stopHTTP()
  257. n.stopIPC()
  258. n.stopInProc()
  259. return err
  260. }
  261. // All API endpoints started successfully
  262. n.rpcAPIs = apis
  263. return nil
  264. }
  265. // startInProc initializes an in-process RPC endpoint.
  266. func (n *Node) startInProc(apis []rpc.API) error {
  267. // Register all the APIs exposed by the services
  268. handler := rpc.NewServer()
  269. for _, api := range apis {
  270. if err := handler.RegisterName(api.Namespace, api.Service); err != nil {
  271. return err
  272. }
  273. glog.V(logger.Debug).Infof("InProc registered %T under '%s'", api.Service, api.Namespace)
  274. }
  275. n.inprocHandler = handler
  276. return nil
  277. }
  278. // stopInProc terminates the in-process RPC endpoint.
  279. func (n *Node) stopInProc() {
  280. if n.inprocHandler != nil {
  281. n.inprocHandler.Stop()
  282. n.inprocHandler = nil
  283. }
  284. }
  285. // startIPC initializes and starts the IPC RPC endpoint.
  286. func (n *Node) startIPC(apis []rpc.API) error {
  287. // Short circuit if the IPC endpoint isn't being exposed
  288. if n.ipcEndpoint == "" {
  289. return nil
  290. }
  291. // Register all the APIs exposed by the services
  292. handler := rpc.NewServer()
  293. for _, api := range apis {
  294. if err := handler.RegisterName(api.Namespace, api.Service); err != nil {
  295. return err
  296. }
  297. glog.V(logger.Debug).Infof("IPC registered %T under '%s'", api.Service, api.Namespace)
  298. }
  299. // All APIs registered, start the IPC listener
  300. var (
  301. listener net.Listener
  302. err error
  303. )
  304. if listener, err = rpc.CreateIPCListener(n.ipcEndpoint); err != nil {
  305. return err
  306. }
  307. go func() {
  308. glog.V(logger.Info).Infof("IPC endpoint opened: %s", n.ipcEndpoint)
  309. for {
  310. conn, err := listener.Accept()
  311. if err != nil {
  312. // Terminate if the listener was closed
  313. n.lock.RLock()
  314. closed := n.ipcListener == nil
  315. n.lock.RUnlock()
  316. if closed {
  317. return
  318. }
  319. // Not closed, just some error; report and continue
  320. glog.V(logger.Error).Infof("IPC accept failed: %v", err)
  321. continue
  322. }
  323. go handler.ServeCodec(rpc.NewJSONCodec(conn), rpc.OptionMethodInvocation|rpc.OptionSubscriptions)
  324. }
  325. }()
  326. // All listeners booted successfully
  327. n.ipcListener = listener
  328. n.ipcHandler = handler
  329. return nil
  330. }
  331. // stopIPC terminates the IPC RPC endpoint.
  332. func (n *Node) stopIPC() {
  333. if n.ipcListener != nil {
  334. n.ipcListener.Close()
  335. n.ipcListener = nil
  336. glog.V(logger.Info).Infof("IPC endpoint closed: %s", n.ipcEndpoint)
  337. }
  338. if n.ipcHandler != nil {
  339. n.ipcHandler.Stop()
  340. n.ipcHandler = nil
  341. }
  342. }
  343. // startHTTP initializes and starts the HTTP RPC endpoint.
  344. func (n *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, cors string) error {
  345. // Short circuit if the HTTP endpoint isn't being exposed
  346. if endpoint == "" {
  347. return nil
  348. }
  349. // Generate the whitelist based on the allowed modules
  350. whitelist := make(map[string]bool)
  351. for _, module := range modules {
  352. whitelist[module] = true
  353. }
  354. // Register all the APIs exposed by the services
  355. handler := rpc.NewServer()
  356. for _, api := range apis {
  357. if whitelist[api.Namespace] || (len(whitelist) == 0 && api.Public) {
  358. if err := handler.RegisterName(api.Namespace, api.Service); err != nil {
  359. return err
  360. }
  361. glog.V(logger.Debug).Infof("HTTP registered %T under '%s'", api.Service, api.Namespace)
  362. }
  363. }
  364. // All APIs registered, start the HTTP listener
  365. var (
  366. listener net.Listener
  367. err error
  368. )
  369. if listener, err = net.Listen("tcp", endpoint); err != nil {
  370. return err
  371. }
  372. go rpc.NewHTTPServer(cors, handler).Serve(listener)
  373. glog.V(logger.Info).Infof("HTTP endpoint opened: http://%s", endpoint)
  374. // All listeners booted successfully
  375. n.httpEndpoint = endpoint
  376. n.httpListener = listener
  377. n.httpHandler = handler
  378. return nil
  379. }
  380. // stopHTTP terminates the HTTP RPC endpoint.
  381. func (n *Node) stopHTTP() {
  382. if n.httpListener != nil {
  383. n.httpListener.Close()
  384. n.httpListener = nil
  385. glog.V(logger.Info).Infof("HTTP endpoint closed: http://%s", n.httpEndpoint)
  386. }
  387. if n.httpHandler != nil {
  388. n.httpHandler.Stop()
  389. n.httpHandler = nil
  390. }
  391. }
  392. // startWS initializes and starts the websocket RPC endpoint.
  393. func (n *Node) startWS(endpoint string, apis []rpc.API, modules []string, wsOrigins string) error {
  394. // Short circuit if the WS endpoint isn't being exposed
  395. if endpoint == "" {
  396. return nil
  397. }
  398. // Generate the whitelist based on the allowed modules
  399. whitelist := make(map[string]bool)
  400. for _, module := range modules {
  401. whitelist[module] = true
  402. }
  403. // Register all the APIs exposed by the services
  404. handler := rpc.NewServer()
  405. for _, api := range apis {
  406. if whitelist[api.Namespace] || (len(whitelist) == 0 && api.Public) {
  407. if err := handler.RegisterName(api.Namespace, api.Service); err != nil {
  408. return err
  409. }
  410. glog.V(logger.Debug).Infof("WebSocket registered %T under '%s'", api.Service, api.Namespace)
  411. }
  412. }
  413. // All APIs registered, start the HTTP listener
  414. var (
  415. listener net.Listener
  416. err error
  417. )
  418. if listener, err = net.Listen("tcp", endpoint); err != nil {
  419. return err
  420. }
  421. go rpc.NewWSServer(wsOrigins, handler).Serve(listener)
  422. glog.V(logger.Info).Infof("WebSocket endpoint opened: ws://%s", endpoint)
  423. // All listeners booted successfully
  424. n.wsEndpoint = endpoint
  425. n.wsListener = listener
  426. n.wsHandler = handler
  427. return nil
  428. }
  429. // stopWS terminates the websocket RPC endpoint.
  430. func (n *Node) stopWS() {
  431. if n.wsListener != nil {
  432. n.wsListener.Close()
  433. n.wsListener = nil
  434. glog.V(logger.Info).Infof("WebSocket endpoint closed: ws://%s", n.wsEndpoint)
  435. }
  436. if n.wsHandler != nil {
  437. n.wsHandler.Stop()
  438. n.wsHandler = nil
  439. }
  440. }
  441. // Stop terminates a running node along with all it's services. In the node was
  442. // not started, an error is returned.
  443. func (n *Node) Stop() error {
  444. n.lock.Lock()
  445. defer n.lock.Unlock()
  446. // Short circuit if the node's not running
  447. if n.server == nil {
  448. return ErrNodeStopped
  449. }
  450. // Terminate the API, services and the p2p server.
  451. n.stopWS()
  452. n.stopHTTP()
  453. n.stopIPC()
  454. n.rpcAPIs = nil
  455. failure := &StopError{
  456. Services: make(map[reflect.Type]error),
  457. }
  458. for kind, service := range n.services {
  459. if err := service.Stop(); err != nil {
  460. failure.Services[kind] = err
  461. }
  462. }
  463. n.server.Stop()
  464. n.services = nil
  465. n.server = nil
  466. // Release instance directory lock.
  467. if n.instanceDirLock != nil {
  468. n.instanceDirLock.Close()
  469. n.instanceDirLock = nil
  470. }
  471. // unblock n.Wait
  472. close(n.stop)
  473. // Remove the keystore if it was created ephemerally.
  474. var keystoreErr error
  475. if n.ephemeralKeystore != "" {
  476. keystoreErr = os.RemoveAll(n.ephemeralKeystore)
  477. }
  478. if len(failure.Services) > 0 {
  479. return failure
  480. }
  481. if keystoreErr != nil {
  482. return keystoreErr
  483. }
  484. return nil
  485. }
  486. // Wait blocks the thread until the node is stopped. If the node is not running
  487. // at the time of invocation, the method immediately returns.
  488. func (n *Node) Wait() {
  489. n.lock.RLock()
  490. if n.server == nil {
  491. return
  492. }
  493. stop := n.stop
  494. n.lock.RUnlock()
  495. <-stop
  496. }
  497. // Restart terminates a running node and boots up a new one in its place. If the
  498. // node isn't running, an error is returned.
  499. func (n *Node) Restart() error {
  500. if err := n.Stop(); err != nil {
  501. return err
  502. }
  503. if err := n.Start(); err != nil {
  504. return err
  505. }
  506. return nil
  507. }
  508. // Attach creates an RPC client attached to an in-process API handler.
  509. func (n *Node) Attach() (*rpc.Client, error) {
  510. n.lock.RLock()
  511. defer n.lock.RUnlock()
  512. if n.server == nil {
  513. return nil, ErrNodeStopped
  514. }
  515. return rpc.DialInProc(n.inprocHandler), nil
  516. }
  517. // Server retrieves the currently running P2P network layer. This method is meant
  518. // only to inspect fields of the currently running server, life cycle management
  519. // should be left to this Node entity.
  520. func (n *Node) Server() *p2p.Server {
  521. n.lock.RLock()
  522. defer n.lock.RUnlock()
  523. return n.server
  524. }
  525. // Service retrieves a currently running service registered of a specific type.
  526. func (n *Node) Service(service interface{}) error {
  527. n.lock.RLock()
  528. defer n.lock.RUnlock()
  529. // Short circuit if the node's not running
  530. if n.server == nil {
  531. return ErrNodeStopped
  532. }
  533. // Otherwise try to find the service to return
  534. element := reflect.ValueOf(service).Elem()
  535. if running, ok := n.services[element.Type()]; ok {
  536. element.Set(reflect.ValueOf(running))
  537. return nil
  538. }
  539. return ErrServiceUnknown
  540. }
  541. // DataDir retrieves the current datadir used by the protocol stack.
  542. func (n *Node) DataDir() string {
  543. return n.config.DataDir
  544. }
  545. // AccountManager retrieves the account manager used by the protocol stack.
  546. func (n *Node) AccountManager() *accounts.Manager {
  547. return n.accman
  548. }
  549. // IPCEndpoint retrieves the current IPC endpoint used by the protocol stack.
  550. func (n *Node) IPCEndpoint() string {
  551. return n.ipcEndpoint
  552. }
  553. // HTTPEndpoint retrieves the current HTTP endpoint used by the protocol stack.
  554. func (n *Node) HTTPEndpoint() string {
  555. return n.httpEndpoint
  556. }
  557. // WSEndpoint retrieves the current WS endpoint used by the protocol stack.
  558. func (n *Node) WSEndpoint() string {
  559. return n.wsEndpoint
  560. }
  561. // EventMux retrieves the event multiplexer used by all the network services in
  562. // the current protocol stack.
  563. func (n *Node) EventMux() *event.TypeMux {
  564. return n.eventmux
  565. }
  566. // OpenDatabase opens an existing database with the given name (or creates one if no
  567. // previous can be found) from within the node's instance directory. If the node is
  568. // ephemeral, a memory database is returned.
  569. func (n *Node) OpenDatabase(name string, cache, handles int) (ethdb.Database, error) {
  570. if n.config.DataDir == "" {
  571. return ethdb.NewMemDatabase()
  572. }
  573. return ethdb.NewLDBDatabase(n.config.resolvePath(name), cache, handles)
  574. }
  575. // ResolvePath returns the absolute path of a resource in the instance directory.
  576. func (n *Node) ResolvePath(x string) string {
  577. return n.config.resolvePath(x)
  578. }
  579. // apis returns the collection of RPC descriptors this node offers.
  580. func (n *Node) apis() []rpc.API {
  581. return []rpc.API{
  582. {
  583. Namespace: "admin",
  584. Version: "1.0",
  585. Service: NewPrivateAdminAPI(n),
  586. }, {
  587. Namespace: "admin",
  588. Version: "1.0",
  589. Service: NewPublicAdminAPI(n),
  590. Public: true,
  591. }, {
  592. Namespace: "debug",
  593. Version: "1.0",
  594. Service: debug.Handler,
  595. }, {
  596. Namespace: "debug",
  597. Version: "1.0",
  598. Service: NewPublicDebugAPI(n),
  599. Public: true,
  600. }, {
  601. Namespace: "web3",
  602. Version: "1.0",
  603. Service: NewPublicWeb3API(n),
  604. Public: true,
  605. },
  606. }
  607. }