mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-06 13:26:23 +00:00
Statesync:attempt to retry if only two peers and fail
This commit is contained in:
@@ -47,6 +47,7 @@ func (d *Dispatcher) LightBlock(ctx context.Context, height int64, peer types.No
|
||||
// dispatch the request to the peer
|
||||
callCh, err := d.dispatch(ctx, peer, height)
|
||||
if err != nil {
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -188,12 +189,13 @@ func (p *BlockProvider) LightBlock(ctx context.Context, height int64) (*types.Li
|
||||
switch err {
|
||||
case nil:
|
||||
if lb == nil {
|
||||
|
||||
return nil, provider.ErrLightBlockNotFound
|
||||
}
|
||||
case context.DeadlineExceeded, context.Canceled:
|
||||
return nil, err
|
||||
case errPeerAlreadyBusy:
|
||||
return nil, provider.ErrLightBlockNotFound
|
||||
return nil, err
|
||||
default:
|
||||
return nil, provider.ErrUnreliableProvider{Reason: err}
|
||||
}
|
||||
|
||||
@@ -279,7 +279,9 @@ func (r *Reactor) OnStart(ctx context.Context) error {
|
||||
"trustHeight", to.Height, "useP2P", r.cfg.UseP2P)
|
||||
|
||||
if r.cfg.UseP2P {
|
||||
if err := r.waitForEnoughPeers(ctx, 2); err != nil {
|
||||
WAIT:
|
||||
failed := 0
|
||||
if err := r.waitForEnoughPeers(ctx, 2+failed); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -291,8 +293,14 @@ func (r *Reactor) OnStart(ctx context.Context) error {
|
||||
|
||||
stateProvider, err := NewP2PStateProvider(ctx, chainID, initialHeight, providers, to, paramsCh, r.logger.With("module", "stateprovider"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to initialize P2P state provider: %w", err)
|
||||
failed++
|
||||
if len(peers) == 2 && failed == 1 {
|
||||
r.logger.Info("***** attempting to find more peers due to init error")
|
||||
goto WAIT
|
||||
}
|
||||
return fmt.Errorf("failed to initialize P2P state provider: %w %d %s %s", err, r.peers.Len(), providers[0].ID(), providers[1].ID())
|
||||
}
|
||||
|
||||
r.stateProvider = stateProvider
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user