aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
Diffstat (limited to 'eth')
-rw-r--r--eth/downloader/downloader.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index 7eda49186..92cb1a650 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -36,6 +36,7 @@ var (
errUnknownPeer = errors.New("peer is unknown or unhealthy")
ErrBadPeer = errors.New("action from bad peer ignored")
ErrStallingPeer = errors.New("peer is stalling")
+ errBannedHead = errors.New("peer head hash already banned")
errNoPeers = errors.New("no peers to keep download active")
ErrPendingQueue = errors.New("pending items in queue")
ErrTimeout = errors.New("timeout")
@@ -72,11 +73,10 @@ type crossCheck struct {
type Downloader struct {
mux *event.TypeMux
- mu sync.RWMutex
queue *queue // Scheduler for selecting the hashes to download
peers *peerSet // Set of active peers from which download can proceed
checks map[common.Hash]*crossCheck // Pending cross checks to verify a hash chain
- banned *set.SetNonTS // Set of hashes we've received and banned
+ banned *set.Set // Set of hashes we've received and banned
// Callbacks
hasBlock hashCheckFn
@@ -114,7 +114,7 @@ func New(mux *event.TypeMux, hasBlock hashCheckFn, getBlock getBlockFn) *Downloa
blockCh: make(chan blockPack, 1),
}
// Inject all the known bad hashes
- downloader.banned = set.NewNonTS()
+ downloader.banned = set.New()
for hash, _ := range core.BadHashes {
downloader.banned.Add(hash)
}
@@ -133,6 +133,12 @@ func (d *Downloader) Synchronising() bool {
// RegisterPeer injects a new download peer into the set of block source to be
// used for fetching hashes and blocks from.
func (d *Downloader) RegisterPeer(id string, head common.Hash, getHashes hashFetcherFn, getBlocks blockFetcherFn) error {
+ // If the peer wants to send a banned hash, reject
+ if d.banned.Has(head) {
+ glog.V(logger.Debug).Infoln("Register rejected, head hash banned:", id)
+ return errBannedHead
+ }
+ // Otherwise try to construct and register the peer
glog.V(logger.Detail).Infoln("Registering peer", id)
if err := d.peers.Register(newPeer(id, head, getHashes, getBlocks)); err != nil {
glog.V(logger.Error).Infoln("Register failed:", err)
@@ -199,6 +205,8 @@ func (d *Downloader) TakeBlocks() []*Block {
return d.queue.TakeBlocks()
}
+// Has checks if the downloader knows about a particular hash, meaning that its
+// either already downloaded of pending retrieval.
func (d *Downloader) Has(hash common.Hash) bool {
return d.queue.Has(hash)
}
@@ -604,14 +612,17 @@ func (d *Downloader) banBlocks(peerId string, head common.Hash) error {
// Ban the head hash and phase out any excess
d.banned.Add(blocks[index].Hash())
for d.banned.Size() > maxBannedHashes {
+ var evacuate common.Hash
+
d.banned.Each(func(item interface{}) bool {
// Skip any hard coded bans
if core.BadHashes[item.(common.Hash)] {
return true
}
- d.banned.Remove(item)
+ evacuate = item.(common.Hash)
return false
})
+ d.banned.Remove(evacuate)
}
glog.V(logger.Debug).Infof("Banned %d blocks from: %s", index+1, peerId)
return nil
n>1-4/+4 * This no longer compiles after the open-motif upgradekris2002-09-291-0/+2 * Add missing dependency on libglade.marcus2002-09-251-1/+1 * Don't declare malloc(), it's already in stdlib.halex2002-09-241-0/+5 * Fix fetching distfile: move download site to maintainer'spat2002-09-221-1/+1 * Remove QNX support.trevor2002-09-221-8/+0 * Fix pkg-plist.knu2002-09-212-2/+2 * mi's patch to use gettext as BUILD_DEPEND. If there's a PR I don't havealane2002-09-217-7/+7 * Allow gnomemedia to be detected.marcus2002-09-211-1/+1 * GNOME has just changed the layout of their FTP site. This resulted inmarcus2002-09-2119-19/+19 * Sanitize MASTER_SITESlioux2002-09-203-3/+0 * Update to 2.6.1.nobutaka2002-09-203-3/+3 * - Support CFLAGS/CXXFLAGS properlyijliao2002-09-201-18/+17 * - Support CFLAGS/CXXFLAGS properlyijliao2002-09-201-4/+5 * s/gnome-fifth-toe2/gnome2-fifth-toe/marcus2002-09-201-1/+1 * Add the gnome2-fifth-toe, a collection of GNOME 2 applications.marcus2002-09-204-45/+25 * * Make gdm read set the user environment from login.conf [1]marcus2002-09-194-13/+26 * Add patch to support XFree86-4-libraries and -clients on sparc64anholt2002-09-194-6/+46 * Add missing dependency on gnomecanvas.marcus2002-09-191-1/+1 * Add missing dependency on libghttp.marcus2002-09-191-1/+1 * Fix patchs to DATADIR and GNOME_ICONDIR. This should restore the mixermarcus2002-09-184-4/+56 * Actually remove these files.anholt2002-09-183-0/+0 * Update XFree86-4-* ports which share XFree86-4-libraries's patches:anholt2002-09-1821-342/+431 * Update to 1.4.2.sobomax2002-09-173-5/+4 * Update to 1.4.2.sobomax2002-09-172-2/+2 * Readd Galeon when building with mozilla-devel. Bump PORTREVISION.marcus2002-09-162-6/+6 * Update to 2.0.3.marcus2002-09-156-8/+30 * Due to popular demant into each port which might be inserted into dependencysobomax2002-09-143-2/+12 * Use KDE_DIST_VERSION.alane2002-09-122-4/+6 * Added KDE_DIST_VERSION var, set to KDE_VERSION by default.alane2002-09-122-0/+6 * add xautomation 0.86ijliao2002-09-116-0/+41 * Fix stupid error in dist subdir.alane2002-09-112-2/+2 * SECURITY FIX: UPDATE TO 3.0.3a.alane2002-09-116-20/+10 * texas chainsaw kde2 massacrealane2002-09-111-3/+0 * texas chainsaw kde2 massacrealane2002-09-1120-3388/+0 * Make fam an optional dependency. It may be having some gcc related problemsalane2002-09-102-2/+8 * Add wmoldmenu2new 20020609,obraun2002-09-107-0/+57 * Update to 2.0.5.marcus2002-09-102-2/+2 * KDE2 is dead. The source is no longer available.alane2002-09-0926-4379/+0 * Fix things after the GNOMENG commit.marcus2002-09-091-3/+4 * Add a missing dependency on gdkpixbuf.marcus2002-09-091-1/+1 * Add a missing dependency on gnomecanvas.marcus2002-09-091-1/+1 * Check to see if /usr/include/security/pam_misc.h exists. If it does,marcus2002-09-092-3/+11 * Add a missing dependency on libglade.marcus2002-09-091-1/+1 * Relinquish all my ports.ade2002-09-072-2/+2 * Update to 2.0.4.marcus2002-09-073-2/+3 * Update to 1.0.6.marcus2002-09-073-2/+5 * Update to 2.0.7.marcus2002-09-074-4/+4 * Update to 2.0.9.marcus2002-09-074-4/+4 * Update to 2.0.8.marcus2002-09-076-4/+6 * Set maintainership to ports@.obraun2002-09-052-2/+2 * Update XFree86-4-clients, -Servers, and -libraries to 4.2.1.anholt2002-09-055-51/+28 * Add a knob to allow building of mozilla-devel instead of mozilla. By default,marcus2002-09-042-6/+16 * o Drop PERL in favor of REINPLACE_CMDlioux2002-09-032-19/+11 * Update to 0.50.1perky2002-09-033-3/+2 * Update to the repacked 0.30 and call it 0.30p1.knu2002-09-024-4/+4 * Update MASTER_SITES.knu2002-09-021-1/+1 * Deploy USE_GNOMENG infrastructurelioux2002-09-021-1/+2 * ${PERL} -> ${REINPLACE_CMD}dwcjr2002-09-025-7/+12 * Deploy USE_GNOMENG infrastructurelioux2002-09-0116-21/+36 * Update WWW.knu2002-09-011-2/+1 * Update the Ruby/GNOME suite to 0.30.knu2002-09-016-4/+30 * Add back FreeBSD locales. Bump PORTREVISION.marcus2002-09-012-0/+90 * Update to 2.4.0.11.marcus2002-08-312-2/+2 * Update MASTER_SITES.naddy2002-08-301-1/+3 * Update to 2.0.3.marcus2002-08-293-3/+4 * Update to 2.4.0.10.marcus2002-08-292-2/+2 * Update to 1.0.5.marcus2002-08-292-2/+2 * Directory layouts of py-gtk and py-gnome packages have been changed, so thatsobomax2002-08-291-1/+1 * Update to 2.0.6.marcus2002-08-286-6/+8 * Update to 2.0.2.marcus2002-08-288-48/+34 * Update to 2.0.7.marcus2002-08-288-12/+12 * When initialising s3 driver call fbPictureInit() like other drivers do. Thissobomax2002-08-271-0/+25 * Remove dependency on blackbox, since this program can work with any window ma...trevor2002-08-261-1/+0 * Turn Miguel Mendez' ports over to Adam Weinberger.trevor2002-08-262-3/+1 * Update to 2.4.0.9.marcus2002-08-263-24/+15 * Fix a typo in one of the patches.marcus2002-08-261-1/+1 * Unbreak for 5-CURRENT C++, drop MAINTAINERship.bmah2002-08-262-1/+11 * Update to 3.0.3. Not much changed here: [1] i18n PKGNAMEs converted towill2002-08-2537-425/+86 * Set LATEST_LINK=kde2.petef2002-08-241-0/+1 * Fix a problem with word selection in gnome-terminal. Bump PORTREVISION.marcus2002-08-244-0/+24 * Update to 1.0.4.marcus2002-08-243-3/+4 * Don't try and guess prototypes, that's what system headers are for.kris2002-08-241-0/+22 * * Use USE_GNOMENGmarcus2002-08-222-97/+96 * patch against SSL man-in-the-middle attack, described intrevor2002-08-224-4/+62 * Update to 1.4.2.marcus2002-08-224-6/+4 * Fix the us_intl keymap.anholt2002-08-222-1/+31 * Change MAINTAINER to my FreeBSD address.obraun2002-08-212-2/+2 * Add LIB_DEPENDS for freetype and libGLU, both of which are required to compile.anholt2002-08-211-1/+4 * Update to 2.4.0.8.marcus2002-08-215-52/+56 * Marked FORBIDDEN due to Security Advisory on SSL bug.alane2002-08-201-0/+3 * Add eog to the list of GNOME 1 ports to remove before installing the GNOME 2marcus2002-08-191-1/+1 * Remove USE_GNOME.marcus2002-08-172-2/+0 * gzip the new patches to help users who are getting mangled text files fromanholt2002-08-162-2/+2 * Update to 0.9.2. Sort plist.markp2002-08-143-24/+21 * Update to 1.0.3.marcus2002-08-142-2/+2 * o Security fix: "Konqueror (kssl to be precisely) fails to detectlioux2002-08-138-0/+130 * Update to 2.0.6. This fixed the problem where launchers in drawers wouldn'tmarcus2002-08-134-4/+4 * Add gdm to the list of GNOME 1.4.1 packages that must be uninstalled beforemarcus2002-08-121-1/+1 * Add --without-kerberos to CONFIGURE_ARGS to prevent a build failure lookingmarcus2002-08-111-1/+2 * Add '\' continuation to end of gnomeaudio line.marcus2002-08-101-1/+1 * Add gnomeaudio as this is needed for general sounds. If you try to play withmarcus2002-08-101-1/+2 * * Change the uid:gid for gdm to 92 as mailman already has 91marcus2002-08-104-12/+112 * * Update to 2.4.0.7.marcus2002-08-109-24/+181 * Update to 2.0.6.marcus2002-08-104-4/+4 * Update to 2.0.5. Keep the tempoary patch to prevent nautilus from placeingmarcus2002-08-106-368/+344 * add peeper 0.1ijliao2002-08-096-0/+38 * Correct the category.trevor2002-08-081-1/+1 * Update to 2.0.5.sobomax2002-08-084-4/+4 * Update to 1.0.2.marcus2002-08-083-11/+8 * Update to 2.0.4.marcus2002-08-074-4/+4 * Update to 2.0.5.marcus2002-08-074-4/+4 * Update to 2.0.2.marcus2002-08-075-54/+37 * Make it actually working both with GNOME1 and GNOME2. Bump PORTREVISION.sobomax2002-08-064-2/+19 * Use x11/xscreensaver-gnome instead of x11/xscreensaver, because the formersobomax2002-08-051-1/+1 * Make the port working with both GNOME1 and GNOME2 desktop.sobomax2002-08-051-1/+17 * Fork off x11/xscreensaver port as of yesterday and add some long awaitedsobomax2002-08-0510-73/+483 * Bring this back from the dead toodougb2002-08-051-0/+11 * Finish restoring this port to it's previous statedougb2002-08-052-38/+3 * Take the unfortunate step of removing gnome support. The gnome teamdougb2002-08-053-38/+29 * Add patches for last commit (fixing scrollwheel on -current, and enablinganholt2002-08-052-0/+45 * 1. Use XlcDL.c from X CVS to help people with Korean or Japanese XIM and GTK+anholt2002-08-053-7/+9 * Update to 2.0.1.marcus2002-08-056-30/+28 * - fix build: add libgnugetopt dependpetef2002-08-051-2/+4 * XOpenOffice.org Quickstarter is a small application that runs in the KDEmbr2002-08-0411-0/+75 * 1. Explicitly added USE_QT_VER and USE_KDELIBS_VER.alane2002-08-042-6/+62 * MAINTEINER-suggested version up.mita2002-08-035-93/+108 * Don't use old USE_GNOME framework, as it is now being actively deorbited.sobomax2002-08-031-2/+3