Skip to content

Commit 6e53498

Browse files
committed
rpc/api: fix #1972 api regression (nil eth panic) in attach
1 parent 6d09468 commit 6e53498

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

rpc/api/admin.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import (
3232
"github.com/ethereum/go-ethereum/crypto"
3333
"github.com/ethereum/go-ethereum/eth"
3434
"github.com/ethereum/go-ethereum/logger/glog"
35-
"github.com/ethereum/go-ethereum/p2p"
3635
"github.com/ethereum/go-ethereum/rlp"
3736
"github.com/ethereum/go-ethereum/rpc/codec"
3837
"github.com/ethereum/go-ethereum/rpc/comms"
@@ -81,17 +80,15 @@ type adminhandler func(*adminApi, *shared.Request) (interface{}, error)
8180
// admin api provider
8281
type adminApi struct {
8382
xeth *xeth.XEth
84-
network *p2p.Server
8583
ethereum *eth.Ethereum
8684
codec codec.Codec
8785
coder codec.ApiCoder
8886
}
8987

9088
// create a new admin api instance
91-
func NewAdminApi(xeth *xeth.XEth, network *p2p.Server, ethereum *eth.Ethereum, codec codec.Codec) *adminApi {
89+
func NewAdminApi(xeth *xeth.XEth, ethereum *eth.Ethereum, codec codec.Codec) *adminApi {
9290
return &adminApi{
9391
xeth: xeth,
94-
network: network,
9592
ethereum: ethereum,
9693
codec: codec,
9794
coder: codec.New(nil),
@@ -140,11 +137,11 @@ func (self *adminApi) AddPeer(req *shared.Request) (interface{}, error) {
140137
}
141138

142139
func (self *adminApi) Peers(req *shared.Request) (interface{}, error) {
143-
return self.network.PeersInfo(), nil
140+
return self.ethereum.Network().PeersInfo(), nil
144141
}
145142

146143
func (self *adminApi) NodeInfo(req *shared.Request) (interface{}, error) {
147-
return self.network.NodeInfo(), nil
144+
return self.ethereum.Network().NodeInfo(), nil
148145
}
149146

150147
func (self *adminApi) DataDir(req *shared.Request) (interface{}, error) {

rpc/api/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func ParseApiString(apistr string, codec codec.Codec, xeth *xeth.XEth, eth *eth.
165165
for i, name := range names {
166166
switch strings.ToLower(strings.TrimSpace(name)) {
167167
case shared.AdminApiName:
168-
apis[i] = NewAdminApi(xeth, eth.Network(), eth, codec)
168+
apis[i] = NewAdminApi(xeth, eth, codec)
169169
case shared.DebugApiName:
170170
apis[i] = NewDebugApi(xeth, eth, codec)
171171
case shared.DbApiName:

0 commit comments

Comments
 (0)