Skip to content

Commit

Permalink
initial request timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic committed Jun 22, 2024
1 parent 0559605 commit 39e4192
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion blocksync/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ func (bpr *bpRequester) redo(peerID p2p.ID) {
}

func (bpr *bpRequester) pickPeerAndSendRequest() {
fmt.Println("pickPeerAndSendRequest")
bpr.mtx.Lock()
secondPeerID := bpr.secondPeerID
bpr.mtx.Unlock()
Expand Down Expand Up @@ -721,6 +722,7 @@ PICK_PEER_LOOP:
// Picks a second peer and sends a request to it. If the second peer is already
// set, does nothing.
func (bpr *bpRequester) pickSecondPeerAndSendRequest() (picked bool) {
fmt.Println("pickSecondPeerAndSendRequest")
bpr.mtx.Lock()
if bpr.secondPeerID != "" {
bpr.mtx.Unlock()
Expand Down Expand Up @@ -760,11 +762,15 @@ OUTER_LOOP:
bpr.pickPeerAndSendRequest()

poolHeight := bpr.pool.Height()
fmt.Println("poolHeight", poolHeight)
var retryTimer *time.Timer
if bpr.height-poolHeight < minBlocksForSingleRequest {
bpr.pickSecondPeerAndSendRequest()
retryTimer = time.NewTimer(requestRetrySeconds * time.Second)
} else {
retryTimer = time.NewTimer(5 * time.Second)
}

retryTimer := time.NewTimer(requestRetrySeconds * time.Second)
defer retryTimer.Stop()

for {
Expand Down

0 comments on commit 39e4192

Please sign in to comment.