mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
5345ddf686
* first pass, step 1 works * naive from finalized to head * delete commented code * checkpoint progress on tests * passing test * abstract code slightly * failure cases * chkpt * mostly working, missing a single block and having timeout * passing tests * comments * comments * gaz * clarify comments * progress on a few new cases * add back bootnode query tool * bootstrap from DHT * chunked responses in round robin * fix tests and deadlines * add basic counter, time estimation * hello -> handshakes * show peers in use during sync * just one last test failure * only request blocks starting in the finalized epoch for step 1 * revert that * comment out test and add better commentary * move requestBlocks out to pointer receiver * mathutil * Update beacon-chain/sync/initial-sync/round_robin.go Co-Authored-By: Raul Jordan <raul@prysmaticlabs.com> * PR feedback * PR feedback
28 lines
876 B
Go
28 lines
876 B
Go
package sync
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/libp2p/go-libp2p-core/network"
|
|
)
|
|
|
|
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) {
|
|
// libp2p uses the system clock time for determining the deadline so we use
|
|
// time.Now() instead of the synchronized roughtime.Now().
|
|
stream.SetReadDeadline(time.Now().Add(duration))
|
|
}
|
|
|
|
func setStreamWriteDeadline(stream network.Stream, duration time.Duration) {
|
|
// libp2p uses the system clock time for determining the deadline so we use
|
|
// time.Now() instead of the synchronized roughtime.Now().
|
|
stream.SetWriteDeadline(time.Now().Add(duration))
|
|
}
|