Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Commit

Permalink
WIP: moving pivot and capped mem usage
Browse files Browse the repository at this point in the history
  • Loading branch information
whilei committed May 28, 2018
1 parent 4167fa8 commit b39e149
Show file tree
Hide file tree
Showing 7 changed files with 1,730 additions and 1,407 deletions.
700 changes: 361 additions & 339 deletions eth/downloader/downloader.go

Large diffs are not rendered by default.

1,385 changes: 531 additions & 854 deletions eth/downloader/downloader_test.go

Large diffs are not rendered by default.

17 changes: 15 additions & 2 deletions eth/downloader/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"time"

"github.com/ethereumproject/go-ethereum/common"
"github.com/ethereumproject/go-ethereum/event"
)

const (
Expand Down Expand Up @@ -345,8 +346,10 @@ func (p *peer) String() string {
// peerSet represents the collection of active peer participating in the chain
// download procedure.
type peerSet struct {
peers map[string]*peer
lock sync.RWMutex
peers map[string]*peer
newPeerFeed event.Feed
peerDropFeed event.Feed
lock sync.RWMutex
}

// newPeerSet creates a new peer set top track the active download sources.
Expand All @@ -356,6 +359,16 @@ func newPeerSet() *peerSet {
}
}

// SubscribeNewPeers subscribes to peer arrival events.
func (ps *peerSet) SubscribeNewPeers(ch chan<- *peer) event.Subscription {
return ps.newPeerFeed.Subscribe(ch)
}

// SubscribePeerDrops subscribes to peer departure events.
func (ps *peerSet) SubscribePeerDrops(ch chan<- *peer) event.Subscription {
return ps.peerDropFeed.Subscribe(ch)
}

// Reset iterates over the current peer set, and resets each of the known peers
// to prepare for a next batch of block retrieval.
func (ps *peerSet) Reset() {
Expand Down
Loading

0 comments on commit b39e149

Please sign in to comment.