p2p: limit rate of dialing new peers (#6485)

This commit is contained in:
Sam Kleinman
2021-05-26 14:39:04 -04:00
committed by GitHub
parent 68f4a210d3
commit e9928f6186
6 changed files with 162 additions and 58 deletions
+7
View File
@@ -2,6 +2,7 @@ package http
import (
"context"
"errors"
"fmt"
"math/rand"
"net/url"
@@ -122,6 +123,12 @@ func (p *http) LightBlock(ctx context.Context, height int64) (*types.LightBlock,
}
}
if sh.Header == nil {
return nil, provider.ErrBadLightBlock{
Reason: errors.New("header is nil unexpectedly"),
}
}
vs, err := p.validatorSet(ctx, &sh.Height)
if err != nil {
return nil, err