mirror of https://github.com/status-im/op-geth.git
Increased deadline
This commit is contained in:
parent
0c1f732c64
commit
7c0df348f8
|
@ -69,6 +69,12 @@ func NewMessage(msgType MsgType, data interface{}) *Msg {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadMessage(data []byte) (msg *Msg, remaining []byte, done bool, err error) {
|
func ReadMessage(data []byte) (msg *Msg, remaining []byte, done bool, err error) {
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
panic(fmt.Sprintf("message error %d %v", len(data), data))
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
return nil, nil, true, nil
|
return nil, nil, true, nil
|
||||||
}
|
}
|
||||||
|
@ -124,7 +130,7 @@ func ReadMessages(conn net.Conn) (msgs []*Msg, err error) {
|
||||||
var totalBytes int
|
var totalBytes int
|
||||||
for {
|
for {
|
||||||
// Give buffering some time
|
// Give buffering some time
|
||||||
conn.SetReadDeadline(time.Now().Add(20 * time.Millisecond))
|
conn.SetReadDeadline(time.Now().Add(500 * time.Millisecond))
|
||||||
// Create a new temporarily buffer
|
// Create a new temporarily buffer
|
||||||
b := make([]byte, 1440)
|
b := make([]byte, 1440)
|
||||||
// Wait for a message from this peer
|
// Wait for a message from this peer
|
||||||
|
@ -134,7 +140,6 @@ func ReadMessages(conn net.Conn) (msgs []*Msg, err error) {
|
||||||
fmt.Println("err now", err)
|
fmt.Println("err now", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("IOF NOW")
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue