aboutsummaryrefslogtreecommitdiffstats
path: root/peer.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-05 19:32:47 +0800
committerobscuren <geffobscura@gmail.com>2014-12-05 19:32:47 +0800
commitd80f8bda940a8ae8f6dab1502a46054c06cee5cc (patch)
tree3397c3d58bcef44840de4098c23d5ef93056a7f3 /peer.go
parent3cf0477c21376b16492cb0b8705b9c7b951e2fb8 (diff)
downloaddexon-d80f8bda940a8ae8f6dab1502a46054c06cee5cc.tar
dexon-d80f8bda940a8ae8f6dab1502a46054c06cee5cc.tar.gz
dexon-d80f8bda940a8ae8f6dab1502a46054c06cee5cc.tar.bz2
dexon-d80f8bda940a8ae8f6dab1502a46054c06cee5cc.tar.lz
dexon-d80f8bda940a8ae8f6dab1502a46054c06cee5cc.tar.xz
dexon-d80f8bda940a8ae8f6dab1502a46054c06cee5cc.tar.zst
dexon-d80f8bda940a8ae8f6dab1502a46054c06cee5cc.zip
Fixed issue in VM where LOG didn't pop anything of the stack
Diffstat (limited to 'peer.go')
-rw-r--r--peer.go39
1 files changed, 12 insertions, 27 deletions
diff --git a/peer.go b/peer.go
index 3b39e45c7..46ac65247 100644
--- a/peer.go
+++ b/peer.go
@@ -24,7 +24,7 @@ const (
// The size of the output buffer for writing messages
outputBufferSize = 50
// Current protocol version
- ProtocolVersion = 47
+ ProtocolVersion = 48
// Current P2P version
P2PVersion = 2
// Ethereum network version
@@ -129,9 +129,11 @@ type Peer struct {
statusKnown bool
// Last received pong message
- lastPong int64
- lastBlockReceived time.Time
- doneFetchingHashes bool
+ lastPong int64
+ lastBlockReceived time.Time
+ doneFetchingHashes bool
+ lastHashAt time.Time
+ lastHashRequestedAt time.Time
host []byte
port uint16
@@ -327,19 +329,16 @@ out:
}
}
+ switch msg.Type {
+ case wire.MsgGetBlockHashesTy:
+ p.lastHashRequestedAt = time.Now()
+ }
+
p.writeMessage(msg)
p.lastSend = time.Now()
// Ping timer
case <-pingTimer.C:
- /*
- timeSince := time.Since(time.Unix(p.lastPong, 0))
- if !p.pingStartTime.IsZero() && p.lastPong != 0 && timeSince > (pingPongTimer+30*time.Second) {
- peerlogger.Infof("Peer did not respond to latest pong fast enough, it took %s, disconnecting.\n", timeSince)
- p.Stop()
- return
- }
- */
p.writeMessage(wire.NewMessage(wire.MsgPingTy, ""))
p.pingStartTime = time.Now()
@@ -462,18 +461,6 @@ func (p *Peer) HandleInbound() {
// TMP
if p.statusKnown {
switch msg.Type {
- /*
- case wire.MsgGetTxsTy:
- // Get the current transactions of the pool
- txs := p.ethereum.TxPool().CurrentTransactions()
- // Get the RlpData values from the txs
- txsInterface := make([]interface{}, len(txs))
- for i, tx := range txs {
- txsInterface[i] = tx.RlpData()
- }
- // Broadcast it back to the peer
- p.QueueMessage(wire.NewMessage(wire.MsgTxTy, txsInterface))
- */
case wire.MsgGetBlockHashesTy:
if msg.Data.Len() < 2 {
@@ -508,6 +495,7 @@ func (p *Peer) HandleInbound() {
blockPool := p.ethereum.blockPool
foundCommonHash := false
+ p.lastHashAt = time.Now()
it := msg.Data.NewIterator()
for it.Next() {
@@ -524,9 +512,6 @@ func (p *Peer) HandleInbound() {
}
if !foundCommonHash {
- //if !p.FetchHashes() {
- // p.doneFetchingHashes = true
- //}
p.FetchHashes()
} else {
peerlogger.Infof("Found common hash (%x...)\n", p.lastReceivedHash[0:4])