Skip to content

Commit afc76ac

Browse files
committed
Revert "limit persistent peers to 20"
This reverts commit d340f2b.
1 parent bbaca50 commit afc76ac

File tree

1 file changed

+3
-25
lines changed

1 file changed

+3
-25
lines changed

cosmos/node/config.go

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@ import (
44
"bytes"
55
"context"
66
"fmt"
7-
"math/rand"
8-
"reflect"
9-
"strings"
10-
"time"
11-
127
toml "github.com/pelletier/go-toml/v2"
138
petritypes "github.com/skip-mev/petri/core/v2/types"
9+
"reflect"
10+
"time"
1411
)
1512

1613
type Toml map[string]any
@@ -167,12 +164,8 @@ func (n *Node) SetDefaultConfigs(ctx context.Context) error {
167164
func (n *Node) SetPersistentPeers(ctx context.Context, peers string) error {
168165
cometBftConfig := make(Toml)
169166

170-
allPeers := strings.Split(peers, ",")
171-
172167
p2pConfig := make(Toml)
173-
174-
// return the filtered peers
175-
p2pConfig["persistent_peers"] = filterPeers(allPeers)
168+
p2pConfig["persistent_peers"] = peers
176169

177170
cometBftConfig["p2p"] = p2pConfig
178171

@@ -182,18 +175,3 @@ func (n *Node) SetPersistentPeers(ctx context.Context, peers string) error {
182175
cometBftConfig,
183176
)
184177
}
185-
186-
// filter peers returns a random subset of the given peers. The subset is determined as follows:
187-
// 1. If the number of peers is less than or equal to 20, return all peers.
188-
// 2. If the number of peers is greater than 20, return a random subset of 20 peers.
189-
func filterPeers(allPeers []string) string {
190-
if len(allPeers) <= 20 {
191-
return strings.Join(allPeers, ",")
192-
}
193-
194-
rand.Shuffle(len(allPeers), func(i, j int) {
195-
allPeers[i], allPeers[j] = allPeers[j], allPeers[i]
196-
})
197-
198-
return strings.Join(allPeers[:20], ",")
199-
}

0 commit comments

Comments
 (0)