mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-12 04:41:22 +00:00
rename private_peers to private_peer_ids to distinguish from peers
This commit is contained in:
44
node/node.go
44
node/node.go
@ -281,8 +281,15 @@ func NewNode(config *cfg.Config,
|
||||
if config.P2P.Seeds != "" {
|
||||
seeds = strings.Split(config.P2P.Seeds, ",")
|
||||
}
|
||||
var privatePeerIDs []string
|
||||
if config.P2P.PrivatePeerIDs != "" {
|
||||
privatePeerIDs = strings.Split(config.P2P.PrivatePeerIDs, ",")
|
||||
}
|
||||
pexReactor := pex.NewPEXReactor(addrBook,
|
||||
&pex.PEXReactorConfig{Seeds: seeds, SeedMode: config.P2P.SeedMode})
|
||||
&pex.PEXReactorConfig{
|
||||
Seeds: seeds,
|
||||
SeedMode: config.P2P.SeedMode,
|
||||
PrivatePeerIDs: privatePeerIDs})
|
||||
pexReactor.SetLogger(p2pLogger)
|
||||
sw.AddReactor("PEX", pexReactor)
|
||||
}
|
||||
@ -415,17 +422,38 @@ func (n *Node) OnStart() error {
|
||||
|
||||
// Always connect to persistent peers
|
||||
if n.config.P2P.PersistentPeers != "" {
|
||||
err = n.sw.DialPeersAsync(n.addrBook, strings.Split(n.config.P2P.PersistentPeers, ","), true)
|
||||
// are any of the persistent peers private?
|
||||
persistentPeers := []string{}
|
||||
persistentAndPrivatePeers := []string{}
|
||||
var privatePeerIDs []string
|
||||
if n.config.P2P.PrivatePeerIDs != "" {
|
||||
privatePeerIDs = strings.Split(n.config.P2P.PrivatePeerIDs, ",")
|
||||
}
|
||||
PP_LOOP:
|
||||
for _, peer := range strings.Split(n.config.P2P.PersistentPeers, ",") {
|
||||
spl := strings.Split(peer, "@")
|
||||
if len(spl) == 2 {
|
||||
for _, ppID := range privatePeerIDs {
|
||||
if spl[0] == ppID {
|
||||
persistentAndPrivatePeers = append(persistentAndPrivatePeers, peer)
|
||||
continue PP_LOOP
|
||||
}
|
||||
}
|
||||
}
|
||||
persistentPeers = append(persistentPeers, peer)
|
||||
}
|
||||
|
||||
err = n.sw.DialPeersAsync(n.addrBook, persistentPeers, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Always connect to private peers, but do not add them to addrbook
|
||||
if n.config.P2P.PrivatePeers != "" {
|
||||
err = n.sw.DialPeersAsync(nil, strings.Split(n.config.P2P.PrivatePeers, ","), true)
|
||||
if err != nil {
|
||||
return err
|
||||
// if any of the persistent peers are private, do not add them to addrbook
|
||||
if len(persistentAndPrivatePeers) > 0 {
|
||||
err = n.sw.DialPeersAsync(nil, persistentAndPrivatePeers, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user