all: remove public
field from rpc.API
(#25059)
all: remove public field from rpc.API
This commit is contained in:
parent
c7f485d9e5
commit
119f955686
@ -647,7 +647,6 @@ func signer(c *cli.Context) error {
|
|||||||
rpcAPI := []rpc.API{
|
rpcAPI := []rpc.API{
|
||||||
{
|
{
|
||||||
Namespace: "account",
|
Namespace: "account",
|
||||||
Public: true,
|
|
||||||
Service: api,
|
Service: api,
|
||||||
Version: "1.0"},
|
Version: "1.0"},
|
||||||
}
|
}
|
||||||
@ -656,7 +655,7 @@ func signer(c *cli.Context) error {
|
|||||||
cors := utils.SplitAndTrim(c.GlobalString(utils.HTTPCORSDomainFlag.Name))
|
cors := utils.SplitAndTrim(c.GlobalString(utils.HTTPCORSDomainFlag.Name))
|
||||||
|
|
||||||
srv := rpc.NewServer()
|
srv := rpc.NewServer()
|
||||||
err := node.RegisterApis(rpcAPI, []string{"account"}, srv, false)
|
err := node.RegisterApis(rpcAPI, []string{"account"}, srv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("Could not register API: %w", err)
|
utils.Fatalf("Could not register API: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -699,7 +699,6 @@ func (c *Clique) APIs(chain consensus.ChainHeaderReader) []rpc.API {
|
|||||||
Namespace: "clique",
|
Namespace: "clique",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: &API{chain: chain, clique: c},
|
Service: &API{chain: chain, clique: c},
|
||||||
Public: false,
|
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -680,13 +680,11 @@ func (ethash *Ethash) APIs(chain consensus.ChainHeaderReader) []rpc.API {
|
|||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: &API{ethash},
|
Service: &API{ethash},
|
||||||
Public: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Namespace: "ethash",
|
Namespace: "ethash",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: &API{ethash},
|
Service: &API{ethash},
|
||||||
Public: true,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -310,22 +310,18 @@ func (s *Ethereum) APIs() []rpc.API {
|
|||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewEthereumAPI(s),
|
Service: NewEthereumAPI(s),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "miner",
|
Namespace: "miner",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewMinerAPI(s),
|
Service: NewMinerAPI(s),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: downloader.NewDownloaderAPI(s.handler.downloader, s.eventMux),
|
Service: downloader.NewDownloaderAPI(s.handler.downloader, s.eventMux),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: filters.NewFilterAPI(s.APIBackend, false, 5*time.Minute),
|
Service: filters.NewFilterAPI(s.APIBackend, false, 5*time.Minute),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "admin",
|
Namespace: "admin",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
@ -334,12 +330,10 @@ func (s *Ethereum) APIs() []rpc.API {
|
|||||||
Namespace: "debug",
|
Namespace: "debug",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewDebugAPI(s),
|
Service: NewDebugAPI(s),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "net",
|
Namespace: "net",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: s.netRPCService,
|
Service: s.netRPCService,
|
||||||
Public: true,
|
|
||||||
},
|
},
|
||||||
}...)
|
}...)
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,6 @@ func Register(stack *node.Node, backend *eth.Ethereum) error {
|
|||||||
Namespace: "engine",
|
Namespace: "engine",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewConsensusAPI(backend),
|
Service: NewConsensusAPI(backend),
|
||||||
Public: true,
|
|
||||||
Authenticated: true,
|
Authenticated: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -920,7 +920,6 @@ func APIs(backend Backend) []rpc.API {
|
|||||||
Namespace: "debug",
|
Namespace: "debug",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewAPI(backend),
|
Service: NewAPI(backend),
|
||||||
Public: false,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,37 +103,30 @@ func GetAPIs(apiBackend Backend) []rpc.API {
|
|||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewEthereumAPI(apiBackend),
|
Service: NewEthereumAPI(apiBackend),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewBlockChainAPI(apiBackend),
|
Service: NewBlockChainAPI(apiBackend),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewTransactionAPI(apiBackend, nonceLock),
|
Service: NewTransactionAPI(apiBackend, nonceLock),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "txpool",
|
Namespace: "txpool",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewTxPoolAPI(apiBackend),
|
Service: NewTxPoolAPI(apiBackend),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "debug",
|
Namespace: "debug",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewDebugAPI(apiBackend),
|
Service: NewDebugAPI(apiBackend),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewEthereumAccountAPI(apiBackend.AccountManager()),
|
Service: NewEthereumAccountAPI(apiBackend.AccountManager()),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "personal",
|
Namespace: "personal",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewPersonalAccountAPI(apiBackend, nonceLock),
|
Service: NewPersonalAccountAPI(apiBackend, nonceLock),
|
||||||
Public: false,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,6 @@ func Register(stack *node.Node, backend *les.LightEthereum) error {
|
|||||||
Namespace: "engine",
|
Namespace: "engine",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewConsensusAPI(backend),
|
Service: NewConsensusAPI(backend),
|
||||||
Public: true,
|
|
||||||
Authenticated: true,
|
Authenticated: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -296,32 +296,26 @@ func (s *LightEthereum) APIs() []rpc.API {
|
|||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: &LightDummyAPI{},
|
Service: &LightDummyAPI{},
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: downloader.NewDownloaderAPI(s.handler.downloader, s.eventMux),
|
Service: downloader.NewDownloaderAPI(s.handler.downloader, s.eventMux),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: filters.NewFilterAPI(s.ApiBackend, true, 5*time.Minute),
|
Service: filters.NewFilterAPI(s.ApiBackend, true, 5*time.Minute),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "net",
|
Namespace: "net",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: s.netRPCService,
|
Service: s.netRPCService,
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "les",
|
Namespace: "les",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewLightAPI(&s.lesCommons),
|
Service: NewLightAPI(&s.lesCommons),
|
||||||
Public: false,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "vflux",
|
Namespace: "vflux",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: s.serverPool.API(),
|
Service: s.serverPool.API(),
|
||||||
Public: false,
|
|
||||||
},
|
},
|
||||||
}...)
|
}...)
|
||||||
}
|
}
|
||||||
|
@ -161,19 +161,16 @@ func (s *LesServer) APIs() []rpc.API {
|
|||||||
Namespace: "les",
|
Namespace: "les",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewLightAPI(&s.lesCommons),
|
Service: NewLightAPI(&s.lesCommons),
|
||||||
Public: false,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Namespace: "les",
|
Namespace: "les",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewLightServerAPI(s),
|
Service: NewLightServerAPI(s),
|
||||||
Public: false,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Namespace: "debug",
|
Namespace: "debug",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewDebugAPI(s),
|
Service: NewDebugAPI(s),
|
||||||
Public: false,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,6 @@ func (n *Node) apis() []rpc.API {
|
|||||||
Namespace: "admin",
|
Namespace: "admin",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: &adminAPI{n},
|
Service: &adminAPI{n},
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "debug",
|
Namespace: "debug",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
@ -46,7 +45,6 @@ func (n *Node) apis() []rpc.API {
|
|||||||
Namespace: "web3",
|
Namespace: "web3",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: &web3API{n},
|
Service: &web3API{n},
|
||||||
Public: true,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -281,7 +281,7 @@ func (h *httpServer) enableRPC(apis []rpc.API, config httpConfig) error {
|
|||||||
|
|
||||||
// Create RPC server and handler.
|
// Create RPC server and handler.
|
||||||
srv := rpc.NewServer()
|
srv := rpc.NewServer()
|
||||||
if err := RegisterApis(apis, config.Modules, srv, false); err != nil {
|
if err := RegisterApis(apis, config.Modules, srv); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
h.httpConfig = config
|
h.httpConfig = config
|
||||||
@ -312,7 +312,7 @@ func (h *httpServer) enableWS(apis []rpc.API, config wsConfig) error {
|
|||||||
}
|
}
|
||||||
// Create RPC server and handler.
|
// Create RPC server and handler.
|
||||||
srv := rpc.NewServer()
|
srv := rpc.NewServer()
|
||||||
if err := RegisterApis(apis, config.Modules, srv, false); err != nil {
|
if err := RegisterApis(apis, config.Modules, srv); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
h.wsConfig = config
|
h.wsConfig = config
|
||||||
@ -528,7 +528,7 @@ func (is *ipcServer) stop() error {
|
|||||||
|
|
||||||
// RegisterApis checks the given modules' availability, generates an allowlist based on the allowed modules,
|
// RegisterApis checks the given modules' availability, generates an allowlist based on the allowed modules,
|
||||||
// and then registers all of the APIs exposed by the services.
|
// and then registers all of the APIs exposed by the services.
|
||||||
func RegisterApis(apis []rpc.API, modules []string, srv *rpc.Server, exposeAll bool) error {
|
func RegisterApis(apis []rpc.API, modules []string, srv *rpc.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 HTTP API list", "unavailable", bad, "available", available)
|
log.Error("Unavailable modules in HTTP API list", "unavailable", bad, "available", available)
|
||||||
}
|
}
|
||||||
@ -539,7 +539,7 @@ func RegisterApis(apis []rpc.API, modules []string, srv *rpc.Server, exposeAll b
|
|||||||
}
|
}
|
||||||
// Register all the APIs exposed by the services
|
// Register all the APIs exposed by the services
|
||||||
for _, api := range apis {
|
for _, api := range apis {
|
||||||
if exposeAll || allowList[api.Namespace] || (len(allowList) == 0 && api.Public) {
|
if allowList[api.Namespace] || len(allowList) == 0 {
|
||||||
if err := srv.RegisterName(api.Namespace, api.Service); err != nil {
|
if err := srv.RegisterName(api.Namespace, api.Service); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -100,12 +100,10 @@ func (f *FullService) APIs() []rpc.API {
|
|||||||
{
|
{
|
||||||
Namespace: "debug",
|
Namespace: "debug",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Public: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Namespace: "net",
|
Namespace: "net",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Public: true,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ type API struct {
|
|||||||
Namespace string // namespace under which the rpc methods of Service are exposed
|
Namespace string // namespace under which the rpc methods of Service are exposed
|
||||||
Version string // api version for DApp's
|
Version string // api version for DApp's
|
||||||
Service interface{} // receiver instance which holds the methods
|
Service interface{} // receiver instance which holds the methods
|
||||||
Public bool // indication if the methods must be considered safe for public use
|
Public bool // deprecated - this field is no longer used, but retained for compatibility
|
||||||
Authenticated bool // whether the api should only be available behind authentication.
|
Authenticated bool // whether the api should only be available behind authentication.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user