Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

P2P:support circuit config #602

Merged
merged 1 commit into from Sep 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions config/config.go
Expand Up @@ -91,6 +91,7 @@ type Config struct {
Whitelist []string `long:"whitelist" description:"Add an IP network or IP,PeerID that will not be banned or ignore dual channel mode detection. (eg. 192.168.1.0/24 or ::1 or [peer id])"`
Blacklist []string `long:"blacklist" description:"Add some IP network or IP that will be banned. (eg. 192.168.1.0/24 or ::1)"`
MaxBadResp int `long:"maxbadresp" description:"maxbadresp is the maximum number of bad responses from a peer before we stop talking to it."`
Circuit bool `long:"circuit" description:"All peers will ignore dual channel mode detection"`
}

func (c *Config) GetMinningAddrs() []types.Address {
Expand Down
1 change: 1 addition & 0 deletions p2p/common/config.go
Expand Up @@ -47,4 +47,5 @@ type Config struct {
Banning bool // Open or not ban module
DisableListen bool
LANPeers []string
IsCircuit bool
}
1 change: 1 addition & 0 deletions p2p/service.go
Expand Up @@ -626,6 +626,7 @@ func NewService(cfg *config.Config, events *event.Feed, param *params.Params) (*
Banning: cfg.Banning,
DisableListen: cfg.DisableListen,
LANPeers: lanPeers,
IsCircuit: cfg.Circuit,
},
ctx: ctx,
cancel: cancel,
Expand Down
10 changes: 6 additions & 4 deletions p2p/synch/handshake.go
Expand Up @@ -203,16 +203,18 @@ func (s *Sync) bidirectionalChannelCapacity(pe *peers.Peer, conn network.Conn) b
pe.SetBidChanCap(time.Now())
return true
}
if s.p2p.Config().IsCircuit || s.IsWhitePeer(pe.GetID()) {
pe.SetBidChanCap(time.Now())
return true
}

bidChanLife := pe.GetBidChanCap()
if !bidChanLife.IsZero() {
if time.Since(bidChanLife) < timeForBidirChanLife {
return true
}
}
if s.IsWhitePeer(pe.GetID()) {
pe.SetBidChanCap(time.Time{})
return true
}

//
peAddr := conn.RemoteMultiaddr()
ipAddr := ""
Expand Down