diff options
author | zelig <viktor.tron@gmail.com> | 2014-07-21 20:26:29 +0800 |
---|---|---|
committer | zelig <viktor.tron@gmail.com> | 2014-07-21 20:26:29 +0800 |
commit | 1e4af85a380977233a3bceaf5e2a020a281aa19a (patch) | |
tree | acf6f1506952e9edc400d3b450d153db90ce536e /peer.go | |
parent | 017d36e6b2e127084448dfb38bd1b8de7424e1c9 (diff) | |
parent | 2762ec22d0693b406ead2f0c07b62e9b66d395e4 (diff) | |
download | go-tangerine-1e4af85a380977233a3bceaf5e2a020a281aa19a.tar go-tangerine-1e4af85a380977233a3bceaf5e2a020a281aa19a.tar.gz go-tangerine-1e4af85a380977233a3bceaf5e2a020a281aa19a.tar.bz2 go-tangerine-1e4af85a380977233a3bceaf5e2a020a281aa19a.tar.lz go-tangerine-1e4af85a380977233a3bceaf5e2a020a281aa19a.tar.xz go-tangerine-1e4af85a380977233a3bceaf5e2a020a281aa19a.tar.zst go-tangerine-1e4af85a380977233a3bceaf5e2a020a281aa19a.zip |
merge upstream
Diffstat (limited to 'peer.go')
-rw-r--r-- | peer.go | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -319,7 +319,7 @@ func (p *Peer) HandleInbound() { for atomic.LoadInt32(&p.disconnect) == 0 { // HMM? - time.Sleep(500 * time.Millisecond) + time.Sleep(50 * time.Millisecond) // Wait for a message from the peer msgs, err := ethwire.ReadMessages(p.conn) if err != nil { @@ -328,6 +328,7 @@ func (p *Peer) HandleInbound() { for _, msg := range msgs { peerlogger.DebugDetailf("(%v) => %v %v\n", p.conn.RemoteAddr(), msg.Type, msg.Data) + nextMsg: switch msg.Type { case ethwire.MsgHandshakeTy: // Version message @@ -373,6 +374,7 @@ func (p *Peer) HandleInbound() { p.diverted = false if !p.ethereum.StateManager().BlockChain().FindCanonicalChainFromMsg(msg, block.PrevHash) { p.SyncWithPeerToLastKnown() + break nextMsg } break } @@ -385,10 +387,11 @@ func (p *Peer) HandleInbound() { p.blocksRequested = p.blocksRequested * 2 peerlogger.Infof("No common ancestor found, requesting %d more blocks.\n", p.blocksRequested) - p.catchingUp = false p.FindCommonParentBlock() - break + break nextMsg } + + p.catchingUp = false } for i := msg.Data.Len() - 1; i >= 0; i-- { @@ -410,7 +413,7 @@ func (p *Peer) HandleInbound() { } } - if msg.Data.Len() == 0 { + if msg.Data.Len() <= 1 { // Set catching up to false if // the peer has nothing left to give p.catchingUp = false @@ -754,7 +757,7 @@ func (p *Peer) CatchupWithPeer(blockHash []byte) { if !p.catchingUp { // Make sure nobody else is catching up when you want to do this p.catchingUp = true - msg := ethwire.NewMessage(ethwire.MsgGetChainTy, []interface{}{blockHash, uint64(10)}) + msg := ethwire.NewMessage(ethwire.MsgGetChainTy, []interface{}{blockHash, uint64(30)}) p.QueueMessage(msg) peerlogger.DebugDetailf("Requesting blockchain %x... from peer %s\n", p.ethereum.BlockChain().CurrentBlock.Hash()[:4], p.conn.RemoteAddr()) |