@@ -24,7 +24,7 @@ const (
2424 // The size of the output buffer for writing messages
2525 outputBufferSize = 50
2626 // Current protocol version
27- ProtocolVersion = 47
27+ ProtocolVersion = 48
2828 // Current P2P version
2929 P2PVersion = 2
3030 // Ethereum network version
@@ -129,9 +129,11 @@ type Peer struct {
129129 statusKnown bool
130130
131131 // Last received pong message
132- lastPong int64
133- lastBlockReceived time.Time
134- doneFetchingHashes bool
132+ lastPong int64
133+ lastBlockReceived time.Time
134+ doneFetchingHashes bool
135+ lastHashAt time.Time
136+ lastHashRequestedAt time.Time
135137
136138 host []byte
137139 port uint16
@@ -327,19 +329,16 @@ out:
327329 }
328330 }
329331
332+ switch msg .Type {
333+ case wire .MsgGetBlockHashesTy :
334+ p .lastHashRequestedAt = time .Now ()
335+ }
336+
330337 p .writeMessage (msg )
331338 p .lastSend = time .Now ()
332339
333340 // Ping timer
334341 case <- pingTimer .C :
335- /*
336- timeSince := time.Since(time.Unix(p.lastPong, 0))
337- if !p.pingStartTime.IsZero() && p.lastPong != 0 && timeSince > (pingPongTimer+30*time.Second) {
338- peerlogger.Infof("Peer did not respond to latest pong fast enough, it took %s, disconnecting.\n", timeSince)
339- p.Stop()
340- return
341- }
342- */
343342 p .writeMessage (wire .NewMessage (wire .MsgPingTy , "" ))
344343 p .pingStartTime = time .Now ()
345344
@@ -462,18 +461,6 @@ func (p *Peer) HandleInbound() {
462461 // TMP
463462 if p .statusKnown {
464463 switch msg .Type {
465- /*
466- case wire.MsgGetTxsTy:
467- // Get the current transactions of the pool
468- txs := p.ethereum.TxPool().CurrentTransactions()
469- // Get the RlpData values from the txs
470- txsInterface := make([]interface{}, len(txs))
471- for i, tx := range txs {
472- txsInterface[i] = tx.RlpData()
473- }
474- // Broadcast it back to the peer
475- p.QueueMessage(wire.NewMessage(wire.MsgTxTy, txsInterface))
476- */
477464
478465 case wire .MsgGetBlockHashesTy :
479466 if msg .Data .Len () < 2 {
@@ -508,6 +495,7 @@ func (p *Peer) HandleInbound() {
508495 blockPool := p .ethereum .blockPool
509496
510497 foundCommonHash := false
498+ p .lastHashAt = time .Now ()
511499
512500 it := msg .Data .NewIterator ()
513501 for it .Next () {
@@ -524,9 +512,6 @@ func (p *Peer) HandleInbound() {
524512 }
525513
526514 if ! foundCommonHash {
527- //if !p.FetchHashes() {
528- // p.doneFetchingHashes = true
529- //}
530515 p .FetchHashes ()
531516 } else {
532517 peerlogger .Infof ("Found common hash (%x...)\n " , p .lastReceivedHash [0 :4 ])
0 commit comments