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

Commit

Permalink
Merge pull request #602 from lochjin/0.10.6
Browse files Browse the repository at this point in the history
P2P:support circuit config
  • Loading branch information
dindinw committed Sep 6, 2021
2 parents 8f3d305 + 50a125e commit 5900d0a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
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

0 comments on commit 5900d0a

Please sign in to comment.