aboutsummaryrefslogtreecommitdiffstats
path: root/peer.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-09-28 20:52:58 +0800
committerobscuren <geffobscura@gmail.com>2014-09-28 20:52:58 +0800
commitea0357bf02b61db94bd0ad8806ba7337a55a4f79 (patch)
tree2d6604484b81687fb0a485040e0ba1346354fd71 /peer.go
parent44d50bc8d2e8bf4a87d01d6ded24d79eb50ee666 (diff)
downloaddexon-ea0357bf02b61db94bd0ad8806ba7337a55a4f79.tar
dexon-ea0357bf02b61db94bd0ad8806ba7337a55a4f79.tar.gz
dexon-ea0357bf02b61db94bd0ad8806ba7337a55a4f79.tar.bz2
dexon-ea0357bf02b61db94bd0ad8806ba7337a55a4f79.tar.lz
dexon-ea0357bf02b61db94bd0ad8806ba7337a55a4f79.tar.xz
dexon-ea0357bf02b61db94bd0ad8806ba7337a55a4f79.tar.zst
dexon-ea0357bf02b61db94bd0ad8806ba7337a55a4f79.zip
Block pool is thread safe
Diffstat (limited to 'peer.go')
-rw-r--r--peer.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/peer.go b/peer.go
index e3c4c9e10..11ec6e003 100644
--- a/peer.go
+++ b/peer.go
@@ -503,16 +503,15 @@ func (p *Peer) HandleInbound() {
it := msg.Data.NewIterator()
for it.Next() {
hash := it.Value().Bytes()
-
- p.lastReceivedHash = hash
- p.LastHashReceived = time.Now()
-
if blockPool.HasCommonHash(hash) {
foundCommonHash = true
break
}
+ p.lastReceivedHash = hash
+ p.LastHashReceived = time.Now()
+
blockPool.AddHash(hash, p)
}
@@ -530,7 +529,7 @@ func (p *Peer) HandleInbound() {
block := ethchain.NewBlockFromRlpValue(it.Value())
//fmt.Printf("%v %x - %x\n", block.Number, block.Hash()[0:4], block.PrevHash[0:4])
- blockPool.SetBlock(block, p)
+ blockPool.Add(block, p)
p.lastBlockReceived = time.Now()
}
@@ -561,7 +560,7 @@ func (self *Peer) FetchHashes() {
}
func (self *Peer) FetchingHashes() bool {
- return time.Since(self.LastHashReceived) < 5*time.Second
+ return time.Since(self.LastHashReceived) < 200*time.Millisecond
}
// General update method