Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
feat(proposer): improved shuffle function to preserve original prover…
Browse files Browse the repository at this point in the history
… endpoints slice (#475)

Co-authored-by: David <[email protected]>
  • Loading branch information
airdrop-monster and davidtaikocha authored Dec 24, 2023
1 parent c656ddb commit 6b25d9d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions proposer/prover_selector/eth_fee_eoa_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,14 @@ func (s *ETHFeeEOASelector) AssignProver(

// shuffleProverEndpoints shuffles the current selector's prover endpoints.
func (s *ETHFeeEOASelector) shuffleProverEndpoints() []*url.URL {
rand.Shuffle(len(s.proverEndpoints), func(i, j int) {
s.proverEndpoints[i], s.proverEndpoints[j] = s.proverEndpoints[j], s.proverEndpoints[i]
// Clone the slice to avoid modifying the original proverEndpoints
shuffledEndpoints := make([]*url.URL, len(s.proverEndpoints))
copy(shuffledEndpoints, s.proverEndpoints)

rand.Shuffle(len(shuffledEndpoints), func(i, j int) {
shuffledEndpoints[i], shuffledEndpoints[j] = shuffledEndpoints[j], shuffledEndpoints[i]
})
return s.proverEndpoints
return shuffledEndpoints
}

// assignProver tries to assign a proof generation task to the given prover by HTTP API.
Expand Down

0 comments on commit 6b25d9d

Please sign in to comment.