prysm-pulse/beacon-chain/sync/deadlines.go
Nishant Das 0db690df75 Chunked Responses (#3528)
* 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
2019-09-24 07:56:50 -07:00

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))
}