peer: Don't stall on pongs.
This commit is contained in:
parent
4a397d51d4
commit
5c50db5357
1 changed files with 5 additions and 6 deletions
11
peer/peer.go
11
peer/peer.go
|
@ -1261,6 +1261,11 @@ func (p *Peer) shouldHandleReadError(err error) bool {
|
||||||
// response for the passed wire protocol command to the pending responses map.
|
// response for the passed wire protocol command to the pending responses map.
|
||||||
func (p *Peer) maybeAddDeadline(pendingResponses map[string]time.Time, msgCmd string) {
|
func (p *Peer) maybeAddDeadline(pendingResponses map[string]time.Time, msgCmd string) {
|
||||||
// Setup a deadline for each message being sent that expects a response.
|
// Setup a deadline for each message being sent that expects a response.
|
||||||
|
//
|
||||||
|
// NOTE: Pings are intentionally ignored here since they are typically
|
||||||
|
// sent asynchronously and as a result of a long backlock of messages,
|
||||||
|
// such as is typical in the case of initial block download, the
|
||||||
|
// response won't be received in time.
|
||||||
deadline := time.Now().Add(stallResponseTimeout)
|
deadline := time.Now().Add(stallResponseTimeout)
|
||||||
switch msgCmd {
|
switch msgCmd {
|
||||||
case wire.CmdVersion:
|
case wire.CmdVersion:
|
||||||
|
@ -1271,12 +1276,6 @@ func (p *Peer) maybeAddDeadline(pendingResponses map[string]time.Time, msgCmd st
|
||||||
// Expects an addr message.
|
// Expects an addr message.
|
||||||
pendingResponses[wire.CmdAddr] = deadline
|
pendingResponses[wire.CmdAddr] = deadline
|
||||||
|
|
||||||
case wire.CmdPing:
|
|
||||||
// Expects a pong message in later protocol versions.
|
|
||||||
if p.ProtocolVersion() > wire.BIP0031Version {
|
|
||||||
pendingResponses[wire.CmdPong] = deadline
|
|
||||||
}
|
|
||||||
|
|
||||||
case wire.CmdMemPool:
|
case wire.CmdMemPool:
|
||||||
// Expects an inv message.
|
// Expects an inv message.
|
||||||
pendingResponses[wire.CmdInv] = deadline
|
pendingResponses[wire.CmdInv] = deadline
|
||||||
|
|
Loading…
Reference in a new issue