Skip to content

Commit

Permalink
les: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rjl493456442 committed Feb 24, 2020
1 parent 16d2323 commit 15d3b0a
Show file tree
Hide file tree
Showing 10 changed files with 227 additions and 200 deletions.
7 changes: 4 additions & 3 deletions les/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
type LightEthereum struct {
lesCommons

peers *serverPeerSet
reqDist *requestDistributor
retriever *retrieveManager
odr *LesOdr
Expand Down Expand Up @@ -80,17 +81,17 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*LightEthereum, error) {
}
log.Info("Initialised chain configuration", "config", chainConfig)

peers := newPeerSet(true)
peers := newServerPeerSet()
leth := &LightEthereum{
lesCommons: lesCommons{
genesis: genesisHash,
config: config,
chainConfig: chainConfig,
iConfig: light.DefaultClientIndexerConfig,
chainDb: chainDb,
peers: peers,
closeCh: make(chan struct{}),
},
peers: peers,
eventMux: ctx.EventMux,
reqDist: newRequestDistributor(peers, &mclock.System{}),
accountManager: ctx.AccountManager,
Expand Down Expand Up @@ -225,7 +226,7 @@ func (s *LightEthereum) EventMux() *event.TypeMux { return s.eventMux
// network protocols to start.
func (s *LightEthereum) Protocols() []p2p.Protocol {
return s.makeProtocols(ClientProtocolVersions, s.handler.runPeer, func(id enode.ID) interface{} {
if p := s.peers.serverPeer(peerIdToString(id)); p != nil {
if p := s.peers.peer(peerIdToString(id)); p != nil {
return p.Info()
}
return nil
Expand Down
1 change: 0 additions & 1 deletion les/commons.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ type lesCommons struct {
chainConfig *params.ChainConfig
iConfig *light.IndexerConfig
chainDb ethdb.Database
peers *peerSet
chainReader chainReader
chtIndexer, bloomTrieIndexer *core.ChainIndexer
oracle *checkpointoracle.CheckpointOracle
Expand Down
2 changes: 1 addition & 1 deletion les/distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ type distReq struct {
}

// newRequestDistributor creates a new request distributor
func newRequestDistributor(peers *peerSet, clock mclock.Clock) *requestDistributor {
func newRequestDistributor(peers *serverPeerSet, clock mclock.Clock) *requestDistributor {
d := &requestDistributor{
clock: clock,
reqQueue: list.New(),
Expand Down
Loading

0 comments on commit 15d3b0a

Please sign in to comment.