Skip to content

Commit ebd6199

Browse files
authored
Merge pull request ethereum#92 from ethersphere/swarm-pss-rpcclient
swarm/pss: rpcclient + pss test fixes
2 parents 63e84d4 + c15eba2 commit ebd6199

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3349
-2302
lines changed

cmd/swarm/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ func getPassPhrase(prompt string, i int, passwords []string) string {
459459
return password
460460
}
461461

462-
func injectBootnodes(srv p2p.Server, nodes []string) {
462+
func injectBootnodes(srv *p2p.Server, nodes []string) {
463463
for _, url := range nodes {
464464
n, err := discover.ParseNode(url)
465465
if err != nil {

cmd/wnode/main.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const quitCommand = "~Q"
5151

5252
// singletons
5353
var (
54-
server p2p.Server
54+
server *p2p.Server
5555
shh *whisper.Whisper
5656
done chan struct{}
5757
mailServer mailserver.WMailServer
@@ -253,17 +253,19 @@ func initialize() {
253253
maxPeers = 800
254254
}
255255

256-
server = p2p.NewServer(p2p.Config{
257-
PrivateKey: nodeid,
258-
MaxPeers: maxPeers,
259-
Name: common.MakeName("wnode", "5.0"),
260-
Protocols: shh.Protocols(),
261-
ListenAddr: *argIP,
262-
NAT: nat.Any(),
263-
BootstrapNodes: peers,
264-
StaticNodes: peers,
265-
TrustedNodes: peers,
266-
})
256+
server = &p2p.Server{
257+
Config: p2p.Config{
258+
PrivateKey: nodeid,
259+
MaxPeers: maxPeers,
260+
Name: common.MakeName("wnode", "5.0"),
261+
Protocols: shh.Protocols(),
262+
ListenAddr: *argIP,
263+
NAT: nat.Any(),
264+
BootstrapNodes: peers,
265+
StaticNodes: peers,
266+
TrustedNodes: peers,
267+
},
268+
}
267269
}
268270

269271
func startServer() {

contracts/release/release.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (r *ReleaseService) Protocols() []p2p.Protocol { return nil }
9494
func (r *ReleaseService) APIs() []rpc.API { return nil }
9595

9696
// Start spawns the periodic version checker goroutine
97-
func (r *ReleaseService) Start(server p2p.Server) error {
97+
func (r *ReleaseService) Start(server *p2p.Server) error {
9898
go r.checker()
9999
return nil
100100
}

eth/backend.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import (
4949
)
5050

5151
type LesServer interface {
52-
Start(srvr p2p.Server)
52+
Start(srvr *p2p.Server)
5353
Stop()
5454
Protocols() []p2p.Protocol
5555
}
@@ -362,7 +362,7 @@ func (s *Ethereum) Protocols() []p2p.Protocol {
362362

363363
// Start implements node.Service, starting all internal goroutines needed by the
364364
// Ethereum protocol implementation.
365-
func (s *Ethereum) Start(srvr p2p.Server) error {
365+
func (s *Ethereum) Start(srvr *p2p.Server) error {
366366
s.netRPCService = ethapi.NewPublicNetAPI(srvr, s.NetVersion())
367367

368368
s.protocolManager.Start()

ethstats/ethstats.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const historyUpdateRange = 50
5252
type Service struct {
5353
stack *node.Node // Temporary workaround, remove when API finalized
5454

55-
server p2p.Server // Peer-to-peer server to retrieve networking infos
55+
server *p2p.Server // Peer-to-peer server to retrieve networking infos
5656
eth *eth.Ethereum // Full Ethereum service if monitoring a full node
5757
les *les.LightEthereum // Light Ethereum service if monitoring a light node
5858
engine consensus.Engine // Consensus engine to retrieve variadic block fields
@@ -101,7 +101,7 @@ func (s *Service) Protocols() []p2p.Protocol { return nil }
101101
func (s *Service) APIs() []rpc.API { return nil }
102102

103103
// Start implements node.Service, starting up the monitoring and reporting daemon.
104-
func (s *Service) Start(server p2p.Server) error {
104+
func (s *Service) Start(server *p2p.Server) error {
105105
s.server = server
106106
go s.loop()
107107

internal/ethapi/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,12 +1434,12 @@ func (api *PrivateDebugAPI) SetHead(number hexutil.Uint64) {
14341434

14351435
// PublicNetAPI offers network related RPC methods
14361436
type PublicNetAPI struct {
1437-
net p2p.Server
1437+
net *p2p.Server
14381438
networkVersion uint64
14391439
}
14401440

14411441
// NewPublicNetAPI creates a new net API instance.
1442-
func NewPublicNetAPI(net p2p.Server, networkVersion uint64) *PublicNetAPI {
1442+
func NewPublicNetAPI(net *p2p.Server, networkVersion uint64) *PublicNetAPI {
14431443
return &PublicNetAPI{net, networkVersion}
14441444
}
14451445

les/backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func (s *LightEthereum) Protocols() []p2p.Protocol {
185185

186186
// Start implements node.Service, starting all internal goroutines needed by the
187187
// Ethereum protocol implementation.
188-
func (s *LightEthereum) Start(srvr p2p.Server) error {
188+
func (s *LightEthereum) Start(srvr *p2p.Server) error {
189189
log.Warn("Light client mode is an experimental feature")
190190
s.netRPCService = ethapi.NewPublicNetAPI(srvr, s.networkId)
191191
s.protocolManager.Start(srvr)

les/handler.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ const (
6161
disableClientRemovePeer = false
6262
)
6363

64-
type discV5Server interface {
65-
DiscV5() *discv5.Network
66-
}
67-
6864
// errIncompatibleConfig is returned if the requested protocols and configs are
6965
// not compatible (low protocol version restrictions and high requirements).
7066
var errIncompatibleConfig = errors.New("incompatible configuration")
@@ -260,10 +256,10 @@ func (pm *ProtocolManager) removePeer(id string) {
260256
}
261257
}
262258

263-
func (pm *ProtocolManager) Start(srvr p2p.Server) {
259+
func (pm *ProtocolManager) Start(srvr *p2p.Server) {
264260
var topicDisc *discv5.Network
265-
if v, ok := srvr.(discV5Server); ok {
266-
topicDisc = v.DiscV5()
261+
if srvr != nil {
262+
topicDisc = srvr.DiscV5
267263
}
268264
lesTopic := discv5.Topic("LES@" + common.Bytes2Hex(pm.blockchain.Genesis().Hash().Bytes()[0:8]))
269265
if pm.lightSync {

les/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (s *LesServer) Protocols() []p2p.Protocol {
6868
}
6969

7070
// Start starts the LES server
71-
func (s *LesServer) Start(srvr p2p.Server) {
71+
func (s *LesServer) Start(srvr *p2p.Server) {
7272
s.protocolManager.Start(srvr)
7373
}
7474

les/serverpool.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const (
9797
type serverPool struct {
9898
db ethdb.Database
9999
dbKey []byte
100-
server p2p.Server
100+
server *p2p.Server
101101
quit chan struct{}
102102
wg *sync.WaitGroup
103103
connWg sync.WaitGroup
@@ -118,7 +118,7 @@ type serverPool struct {
118118
}
119119

120120
// newServerPool creates a new serverPool instance
121-
func newServerPool(db ethdb.Database, dbPrefix []byte, server p2p.Server, topic discv5.Topic, quit chan struct{}, wg *sync.WaitGroup) *serverPool {
121+
func newServerPool(db ethdb.Database, dbPrefix []byte, server *p2p.Server, topic discv5.Topic, quit chan struct{}, wg *sync.WaitGroup) *serverPool {
122122
pool := &serverPool{
123123
db: db,
124124
dbKey: append(dbPrefix, []byte(topic)...),
@@ -139,11 +139,11 @@ func newServerPool(db ethdb.Database, dbPrefix []byte, server p2p.Server, topic
139139
pool.loadNodes()
140140
pool.checkDial()
141141

142-
if srv, ok := pool.server.(discV5Server); ok && srv.DiscV5() != nil {
142+
if pool.server.DiscV5 != nil {
143143
pool.discSetPeriod = make(chan time.Duration, 1)
144144
pool.discNodes = make(chan *discv5.Node, 100)
145145
pool.discLookups = make(chan bool, 100)
146-
go srv.DiscV5().SearchTopic(topic, pool.discSetPeriod, pool.discNodes, pool.discLookups)
146+
go pool.server.DiscV5.SearchTopic(topic, pool.discSetPeriod, pool.discNodes, pool.discLookups)
147147
}
148148

149149
go pool.eventLoop()

0 commit comments

Comments
 (0)