diff options
author | obscuren <geffobscura@gmail.com> | 2014-09-28 20:52:58 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-09-28 20:52:58 +0800 |
commit | ea0357bf02b61db94bd0ad8806ba7337a55a4f79 (patch) | |
tree | 2d6604484b81687fb0a485040e0ba1346354fd71 /peer.go | |
parent | 44d50bc8d2e8bf4a87d01d6ded24d79eb50ee666 (diff) | |
download | dexon-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.go | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -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 |