aboutsummaryrefslogtreecommitdiffstats
path: root/eth/downloader/peer.go
diff options
context:
space:
mode:
Diffstat (limited to 'eth/downloader/peer.go')
-rw-r--r--eth/downloader/peer.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/eth/downloader/peer.go b/eth/downloader/peer.go
index f66e5afd8..4cd306a05 100644
--- a/eth/downloader/peer.go
+++ b/eth/downloader/peer.go
@@ -95,3 +95,23 @@ func (p *peer) fetch(chunk *chunk) error {
return nil
}
+
+// promote increases the peer's reputation
+func (p *peer) promote() {
+ p.mu.Lock()
+ defer p.mu.Unlock()
+
+ p.rep++
+}
+
+// demote decreases the peer's reputation or leaves it at 0
+func (p *peer) demote() {
+ p.mu.Lock()
+ defer p.mu.Unlock()
+
+ if p.rep > 1 {
+ p.rep -= 2
+ } else {
+ p.rep = 0
+ }
+}