@@ -40,6 +40,7 @@ type Options struct {
4040 BinPath string // pchaind path
4141 SnapshotRPC string // e.g., https://donut.rpc.push.org
4242 Progress func (string ) // optional callback for progress messages
43+ Attempt int // Retry attempt number (0-based), used to rotate fullnode RPCs
4344}
4445
4546type Service interface {
@@ -199,7 +200,7 @@ func (s *svc) Init(ctx context.Context, opts Options) error {
199200 TrustHash : tp .Hash ,
200201 RPCServers : rpcServers ,
201202 TrustPeriod : "336h0m0s" ,
202- ChunkFetchers : 12 , // Aggressive: 3x parallel downloads for faster sync
203+ ChunkFetchers : 6 , // Balanced: 3 per peer when 2 peers share snapshot
203204 ChunkRequestTimeout : "60m0s" , // Extended timeout for slow/congested networks
204205 DiscoveryTime : "90s" , // More time to discover all available snapshots
205206 }); err != nil {
@@ -217,14 +218,19 @@ func (s *svc) Init(ctx context.Context, opts Options) error {
217218
218219// ReconfigureStateSync updates state sync configuration with fresh trust parameters.
219220// This is used during retry logic when the previous sync attempt failed.
221+ // The Attempt field in opts is used to rotate through fullnode RPCs, so each retry
222+ // uses a different peer's snapshot (which may be available from multiple peers).
220223func (s * svc ) ReconfigureStateSync (ctx context.Context , opts Options ) error {
221224 if opts .HomeDir == "" {
222225 return errors .New ("HomeDir required" )
223226 }
224227
225228 snapshotRPC := opts .SnapshotRPC
226229 if snapshotRPC == "" {
227- snapshotRPC = fullnodeRPCs [0 ]
230+ // Rotate through fullnode RPCs based on attempt number
231+ // This ensures each retry uses a different peer's trust height/snapshot
232+ rpcIndex := opts .Attempt % len (fullnodeRPCs )
233+ snapshotRPC = fullnodeRPCs [rpcIndex ]
228234 }
229235
230236 // Compute fresh trust parameters
@@ -245,7 +251,7 @@ func (s *svc) ReconfigureStateSync(ctx context.Context, opts Options) error {
245251 TrustHash : tp .Hash ,
246252 RPCServers : rpcServers ,
247253 TrustPeriod : "336h0m0s" ,
248- ChunkFetchers : 12 ,
254+ ChunkFetchers : 6 ,
249255 ChunkRequestTimeout : "60m0s" ,
250256 DiscoveryTime : "90s" ,
251257 })
0 commit comments