mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 10:50:44 +00:00
parent
b15a8ac67e
commit
1c5b5ea883
5 changed files with 8 additions and 23 deletions
|
|
@ -80,10 +80,7 @@ func localConsole(ctx *cli.Context) error {
|
||||||
defer stack.Close()
|
defer stack.Close()
|
||||||
|
|
||||||
// Attach to the newly started node and start the JavaScript console
|
// Attach to the newly started node and start the JavaScript console
|
||||||
client, err := stack.Attach()
|
client := stack.Attach()
|
||||||
if err != nil {
|
|
||||||
utils.Fatalf("failed to attach to the inproc XDC: %v", err)
|
|
||||||
}
|
|
||||||
config := console.Config{
|
config := console.Config{
|
||||||
DataDir: utils.MakeDataDir(ctx),
|
DataDir: utils.MakeDataDir(ctx),
|
||||||
DocRoot: ctx.String(utils.JSpathFlag.Name),
|
DocRoot: ctx.String(utils.JSpathFlag.Name),
|
||||||
|
|
@ -185,10 +182,7 @@ func ephemeralConsole(ctx *cli.Context) error {
|
||||||
defer stack.Close()
|
defer stack.Close()
|
||||||
|
|
||||||
// Attach to the newly started node and start the JavaScript console
|
// Attach to the newly started node and start the JavaScript console
|
||||||
client, err := stack.Attach()
|
client := stack.Attach()
|
||||||
if err != nil {
|
|
||||||
utils.Fatalf("Failed to attach to the inproc XDC: %v", err)
|
|
||||||
}
|
|
||||||
config := console.Config{
|
config := console.Config{
|
||||||
DataDir: utils.MakeDataDir(ctx),
|
DataDir: utils.MakeDataDir(ctx),
|
||||||
DocRoot: ctx.String(utils.JSpathFlag.Name),
|
DocRoot: ctx.String(utils.JSpathFlag.Name),
|
||||||
|
|
|
||||||
|
|
@ -306,10 +306,7 @@ func startNode(ctx *cli.Context, stack *node.Node, backend ethapi.Backend, cfg X
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
// Create an chain state reader for self-derivation
|
// Create an chain state reader for self-derivation
|
||||||
rpcClient, err := stack.Attach()
|
rpcClient := stack.Attach()
|
||||||
if err != nil {
|
|
||||||
utils.Fatalf("Failed to attach to self: %v", err)
|
|
||||||
}
|
|
||||||
stateReader := ethclient.NewClient(rpcClient)
|
stateReader := ethclient.NewClient(rpcClient)
|
||||||
|
|
||||||
// Open any wallets already attached
|
// Open any wallets already attached
|
||||||
|
|
|
||||||
|
|
@ -112,10 +112,7 @@ func newTester(t *testing.T, confOverride func(*ethconfig.Config)) *tester {
|
||||||
if err = stack.Start(); err != nil {
|
if err = stack.Start(); err != nil {
|
||||||
t.Fatalf("failed to start test stack: %v", err)
|
t.Fatalf("failed to start test stack: %v", err)
|
||||||
}
|
}
|
||||||
client, err := stack.Attach()
|
client := stack.Attach()
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("failed to attach to node: %v", err)
|
|
||||||
}
|
|
||||||
prompter := &hookedPrompter{scheduler: make(chan string)}
|
prompter := &hookedPrompter{scheduler: make(chan string)}
|
||||||
printer := new(bytes.Buffer)
|
printer := new(bytes.Buffer)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -630,8 +630,8 @@ func (n *Node) RegisterHandler(name, path string, handler http.Handler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach creates an RPC client attached to an in-process API handler.
|
// Attach creates an RPC client attached to an in-process API handler.
|
||||||
func (n *Node) Attach() (*rpc.Client, error) {
|
func (n *Node) Attach() *rpc.Client {
|
||||||
return rpc.DialInProc(n.inprocHandler), nil
|
return rpc.DialInProc(n.inprocHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RPCHandler returns the in-process RPC request handler.
|
// RPCHandler returns the in-process RPC request handler.
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ func (sa *SimAdapter) DialRPC(id discover.NodeID) (*rpc.Client, error) {
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("unknown node: %s", id)
|
return nil, fmt.Errorf("unknown node: %s", id)
|
||||||
}
|
}
|
||||||
return node.node.Attach()
|
return node.node.Attach(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNode returns the node with the given ID if it exists
|
// GetNode returns the node with the given ID if it exists
|
||||||
|
|
@ -261,10 +261,7 @@ func (sn *SimNode) Start(snapshots map[string][]byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// create an in-process RPC client
|
// create an in-process RPC client
|
||||||
client, err := sn.node.Attach()
|
client := sn.node.Attach()
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
sn.lock.Lock()
|
sn.lock.Lock()
|
||||||
sn.client = client
|
sn.client = client
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue