Skip to content

Commit

Permalink
remove numinbound numoutbound counter
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic committed Jun 23, 2024
1 parent 6ef51be commit bb05ad7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 22 deletions.
1 change: 0 additions & 1 deletion cmd/cometbft/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ func ParseConfig(cmd *cobra.Command) (*cfg.Config, error) {
logger.Info("deprecated usage found in configuration file", "usage", warning)
}
}

return conf, nil
}

Expand Down
8 changes: 5 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ const (
// config/toml.go
// NOTE: libs/cli must know to look in the config dir!
var (
DefaultTendermintDir = ".cometbft"
DefaultMaxPercentPeersInSameRegion = float64(0.9)
defaultConfigDir = "config"
defaultDataDir = "data"

DefaultTendermintDir = ".cometbft"
defaultConfigDir = "config"
defaultDataDir = "data"

defaultConfigFileName = "config.toml"
defaultGenesisJSONName = "genesis.json"
Expand Down Expand Up @@ -632,6 +633,7 @@ type P2PConfig struct { //nolint: maligned
TestFuzz bool `mapstructure:"test_fuzz"`
TestFuzzConfig *FuzzConnConfig `mapstructure:"test_fuzz_config"`

// Configs for connecting to peers in the same region
SameRegion bool `mapstructure:"same_region"`
MyRegion string `mapstructure:"my_region"`
MaxPercentPeersInSameRegion float64 `mapstructure:"max_percent_peers_in_same_region"`
Expand Down
1 change: 0 additions & 1 deletion p2p/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,6 @@ func createMConnection(
)
}

// GetRegion
func (p *peer) GetRegion() string {
return p.region
}
20 changes: 3 additions & 17 deletions p2p/peer_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ type IPeerSet interface {
// PeerSet is a special structure for keeping a table of peers.
// Iteration over the peers is super fast and thread-safe.
type PeerSet struct {
mtx cmtsync.Mutex
lookup map[ID]*peerSetItem
list []Peer
numInbound int
numOutbound int
mtx cmtsync.Mutex
lookup map[ID]*peerSetItem
list []Peer
}

type peerSetItem struct {
Expand Down Expand Up @@ -59,12 +57,6 @@ func (ps *PeerSet) Add(peer Peer) error {
ps.list = append(ps.list, peer)
ps.lookup[peer.ID()] = &peerSetItem{peer, index}

if peer.IsOutbound() {
ps.numOutbound++
} else {
ps.numInbound++
}

return nil
}

Expand Down Expand Up @@ -149,12 +141,6 @@ func (ps *PeerSet) Remove(peer Peer) bool {
ps.list = newList
delete(ps.lookup, peer.ID())

if peer.IsOutbound() {
ps.numOutbound--
} else {
ps.numInbound--
}

return true
}

Expand Down

0 comments on commit bb05ad7

Please sign in to comment.