mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 20:07:17 +00:00
0db690df75
* update naming * replace with updated version * more changes * fixed all tests * build and lint * regen protos * fix test * remove outdated code * prestons review * add chunk size * more fixes to chunked responses * handle eof * fix all tests * abstract into common method * add comment * preston's comments * preston's review * preston's review * lint * add encoding methods * gaz * simplify * simplify * lint * change naming * update * handle eof separately * Apply suggestions from code review Co-Authored-By: Preston Van Loon <preston@prysmaticlabs.com> * remove def * preston's review * preston's review * add unit tests * add delay to fix test
25 lines
663 B
Go
25 lines
663 B
Go
package sync
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/libp2p/go-libp2p-core/network"
|
|
"github.com/prysmaticlabs/prysm/shared/roughtime"
|
|
)
|
|
|
|
const defaultReadDuration = ttfbTimeout
|
|
const defaultWriteDuration = 10 * time.Second // RESP_TIMEOUT
|
|
|
|
func setRPCStreamDeadlines(stream network.Stream) {
|
|
setStreamReadDeadline(stream, defaultReadDuration)
|
|
setStreamWriteDeadline(stream, defaultWriteDuration)
|
|
}
|
|
|
|
func setStreamReadDeadline(stream network.Stream, duration time.Duration) {
|
|
stream.SetReadDeadline(roughtime.Now().Add(duration))
|
|
}
|
|
|
|
func setStreamWriteDeadline(stream network.Stream, duration time.Duration) {
|
|
stream.SetWriteDeadline(roughtime.Now().Add(duration))
|
|
}
|