mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 18:30:45 +00:00
parent
175ef934ed
commit
4fb622bfd0
10 changed files with 7 additions and 30 deletions
|
|
@ -146,7 +146,6 @@ func (XDCx *XDCX) APIs() []rpc.API {
|
||||||
Namespace: ProtocolName,
|
Namespace: ProtocolName,
|
||||||
Version: ProtocolVersionStr,
|
Version: ProtocolVersionStr,
|
||||||
Service: NewPublicXDCXAPI(XDCx),
|
Service: NewPublicXDCXAPI(XDCx),
|
||||||
Public: true,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,6 @@ func (l *Lending) APIs() []rpc.API {
|
||||||
Namespace: ProtocolName,
|
Namespace: ProtocolName,
|
||||||
Version: ProtocolVersionStr,
|
Version: ProtocolVersionStr,
|
||||||
Service: NewPublicXDCXLendingAPI(l),
|
Service: NewPublicXDCXLendingAPI(l),
|
||||||
Public: true,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,6 @@ func (x *XDPoS) APIs(chain consensus.ChainReader) []rpc.API {
|
||||||
Namespace: "XDPoS",
|
Namespace: "XDPoS",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: &API{chain: chain, XDPoS: x},
|
Service: &API{chain: chain, XDPoS: x},
|
||||||
Public: true,
|
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -695,6 +695,5 @@ func (c *Clique) APIs(chain consensus.ChainReader) []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,
|
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -402,27 +402,22 @@ func (e *Ethereum) APIs() []rpc.API {
|
||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewPublicEthereumAPI(e),
|
Service: NewPublicEthereumAPI(e),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewPublicMinerAPI(e),
|
Service: NewPublicMinerAPI(e),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: downloader.NewPublicDownloaderAPI(e.protocolManager.downloader, e.eventMux),
|
Service: downloader.NewPublicDownloaderAPI(e.protocolManager.downloader, e.eventMux),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "miner",
|
Namespace: "miner",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewPrivateMinerAPI(e),
|
Service: NewPrivateMinerAPI(e),
|
||||||
Public: false,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: filters.NewFilterAPI(filters.NewFilterSystem(e.ApiBackend, filters.Config{LogCacheSize: e.config.FilterLogCacheSize}), false),
|
Service: filters.NewFilterAPI(filters.NewFilterSystem(e.ApiBackend, filters.Config{LogCacheSize: e.config.FilterLogCacheSize}), false),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "admin",
|
Namespace: "admin",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
|
|
@ -431,7 +426,6 @@ func (e *Ethereum) APIs() []rpc.API {
|
||||||
Namespace: "debug",
|
Namespace: "debug",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewPublicDebugAPI(e),
|
Service: NewPublicDebugAPI(e),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "debug",
|
Namespace: "debug",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
|
|
@ -440,7 +434,6 @@ func (e *Ethereum) APIs() []rpc.API {
|
||||||
Namespace: "net",
|
Namespace: "net",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: e.netRPCService,
|
Service: e.netRPCService,
|
||||||
Public: true,
|
|
||||||
},
|
},
|
||||||
}...)
|
}...)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -126,32 +126,26 @@ func GetAPIs(apiBackend Backend, chainReader consensus.ChainReader) []rpc.API {
|
||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewPublicEthereumAPI(apiBackend),
|
Service: NewPublicEthereumAPI(apiBackend),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewPublicBlockChainAPI(apiBackend, chainReader),
|
Service: NewPublicBlockChainAPI(apiBackend, chainReader),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewPublicTransactionPoolAPI(apiBackend, nonceLock),
|
Service: NewPublicTransactionPoolAPI(apiBackend, nonceLock),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "XDCx",
|
Namespace: "XDCx",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewPublicXDCXTransactionPoolAPI(apiBackend, nonceLock),
|
Service: NewPublicXDCXTransactionPoolAPI(apiBackend, nonceLock),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "txpool",
|
Namespace: "txpool",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewPublicTxPoolAPI(apiBackend),
|
Service: NewPublicTxPoolAPI(apiBackend),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "debug",
|
Namespace: "debug",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewPublicDebugAPI(apiBackend),
|
Service: NewPublicDebugAPI(apiBackend),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "debug",
|
Namespace: "debug",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
|
|
@ -160,12 +154,10 @@ func GetAPIs(apiBackend Backend, chainReader consensus.ChainReader) []rpc.API {
|
||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewPublicAccountAPI(apiBackend.AccountManager()),
|
Service: NewPublicAccountAPI(apiBackend.AccountManager()),
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "personal",
|
Namespace: "personal",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: NewPrivateAccountAPI(apiBackend, nonceLock),
|
Service: NewPrivateAccountAPI(apiBackend, nonceLock),
|
||||||
Public: false,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ func (n *Node) apis() []rpc.API {
|
||||||
Namespace: "admin",
|
Namespace: "admin",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: &publicAdminAPI{n},
|
Service: &publicAdminAPI{n},
|
||||||
Public: true,
|
|
||||||
}, {
|
}, {
|
||||||
Namespace: "debug",
|
Namespace: "debug",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
|
|
@ -49,7 +48,6 @@ func (n *Node) apis() []rpc.API {
|
||||||
Namespace: "web3",
|
Namespace: "web3",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: &publicWeb3API{n},
|
Service: &publicWeb3API{n},
|
||||||
Public: true,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -276,7 +276,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 := RegisterApisFromWhitelist(apis, config.Modules, srv, false); err != nil {
|
if err := RegisterApisFromWhitelist(apis, config.Modules, srv); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
h.httpConfig = config
|
h.httpConfig = config
|
||||||
|
|
@ -308,7 +308,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 := RegisterApisFromWhitelist(apis, config.Modules, srv, false); err != nil {
|
if err := RegisterApisFromWhitelist(apis, config.Modules, srv); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
h.wsConfig = config
|
h.wsConfig = config
|
||||||
|
|
@ -521,7 +521,7 @@ func (is *ipcServer) stop() error {
|
||||||
|
|
||||||
// RegisterApisFromWhitelist checks the given modules' availability, generates a whitelist based on the allowed modules,
|
// RegisterApisFromWhitelist checks the given modules' availability, generates a whitelist 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 RegisterApisFromWhitelist(apis []rpc.API, modules []string, srv *rpc.Server, exposeAll bool) error {
|
func RegisterApisFromWhitelist(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)
|
||||||
}
|
}
|
||||||
|
|
@ -532,7 +532,7 @@ func RegisterApisFromWhitelist(apis []rpc.API, modules []string, srv *rpc.Server
|
||||||
}
|
}
|
||||||
// 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 || whitelist[api.Namespace] || (len(whitelist) == 0 && api.Public) {
|
if whitelist[api.Namespace] || len(whitelist) == 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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,11 +82,11 @@ func (f *FullService) Stop() error { return nil }
|
||||||
|
|
||||||
func (f *FullService) Protocols() []p2p.Protocol {
|
func (f *FullService) Protocols() []p2p.Protocol {
|
||||||
return []p2p.Protocol{
|
return []p2p.Protocol{
|
||||||
p2p.Protocol{
|
{
|
||||||
Name: "test1",
|
Name: "test1",
|
||||||
Version: uint(1),
|
Version: uint(1),
|
||||||
},
|
},
|
||||||
p2p.Protocol{
|
{
|
||||||
Name: "test2",
|
Name: "test2",
|
||||||
Version: uint(2),
|
Version: uint(2),
|
||||||
},
|
},
|
||||||
|
|
@ -102,12 +102,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,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,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
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServerCodec implements reading, parsing and writing RPC messages for the server side of
|
// ServerCodec implements reading, parsing and writing RPC messages for the server side of
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue