Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
1b8a3921
Unverified
Commit
1b8a3921
authored
Nov 28, 2022
by
Felix Lange
Committed by
GitHub
Nov 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
console: use default APIs when server doesn't have rpc_modules (#26267)
parent
743e4049
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
console.go
console/console.go
+12
-2
No files found.
console/console.go
View file @
1b8a3921
...
@@ -34,6 +34,7 @@ import (
...
@@ -34,6 +34,7 @@ import (
"github.com/ethereum/go-ethereum/internal/jsre"
"github.com/ethereum/go-ethereum/internal/jsre"
"github.com/ethereum/go-ethereum/internal/jsre/deps"
"github.com/ethereum/go-ethereum/internal/jsre/deps"
"github.com/ethereum/go-ethereum/internal/web3ext"
"github.com/ethereum/go-ethereum/internal/web3ext"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/rpc"
"github.com/mattn/go-colorable"
"github.com/mattn/go-colorable"
"github.com/peterh/liner"
"github.com/peterh/liner"
...
@@ -198,13 +199,22 @@ func (c *Console) initWeb3(bridge *bridge) error {
...
@@ -198,13 +199,22 @@ func (c *Console) initWeb3(bridge *bridge) error {
return
err
return
err
}
}
var
defaultAPIs
=
map
[
string
]
string
{
"eth"
:
"1.0"
,
"net"
:
"1.0"
,
"debug"
:
"1.0"
}
// initExtensions loads and registers web3.js extensions.
// initExtensions loads and registers web3.js extensions.
func
(
c
*
Console
)
initExtensions
()
error
{
func
(
c
*
Console
)
initExtensions
()
error
{
// Compute aliases from server-provided modules.
const
methodNotFound
=
-
32601
apis
,
err
:=
c
.
client
.
SupportedModules
()
apis
,
err
:=
c
.
client
.
SupportedModules
()
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"api modules: %v"
,
err
)
if
rpcErr
,
ok
:=
err
.
(
rpc
.
Error
);
ok
&&
rpcErr
.
ErrorCode
()
==
methodNotFound
{
log
.
Warn
(
"Server does not support method rpc_modules, using default API list."
)
apis
=
defaultAPIs
}
else
{
return
err
}
}
}
// Compute aliases from server-provided modules.
aliases
:=
map
[
string
]
struct
{}{
"eth"
:
{},
"personal"
:
{}}
aliases
:=
map
[
string
]
struct
{}{
"eth"
:
{},
"personal"
:
{}}
for
api
:=
range
apis
{
for
api
:=
range
apis
{
if
api
==
"web3"
{
if
api
==
"web3"
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment